From e751a1ddbf6986679e9a2e43f1b0229a20eab0b5 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 11 Sep 2021 21:05:35 +1000 Subject: [PATCH] Fixes for auto bill status of recurring invoices --- app/Traits/GenerateMigrationResources.php | 28 +++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 66b32c3c58..2e0deefd3a 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -791,7 +791,8 @@ trait GenerateMigrationResources 'due_date_days' => $this->transformDueDate($invoice), 'remaining_cycles' => $this->getRemainingCycles($invoice), 'invitations' => $this->getResourceInvitations($invoice->invitations, 'recurring_invoice_id'), - 'auto_bill_enabled' => $invoice->auto_bill, + 'auto_bill_enabled' => $this->calcAutoBillEnabled($invoice), + 'auto_bill' => $this->calcAutoBill($invoice), ]; } @@ -799,6 +800,29 @@ trait GenerateMigrationResources } + private function calcAutoBillEnabled($invoice) + { + if($invoice->auto_bill == 1) + return 'off'; + elseif($invoice->auto_bill == 2) + return 'optin'; + elseif($invoice->auto_bill == 3) + return 'optout'; + elseif($invoice->auto_bill == 4) + return 'always'; + else + return 'off'; + } + + private function calcAutoBill($invoice) + { + if($invoice->auto_bill == 4) + return 1; + + return $invoice->client_enable_auto_bill; + + } + private function getNextSendDateForMigration($invoice) { @@ -1213,7 +1237,7 @@ trait GenerateMigrationResources 'tax_name2' => $quote->tax_name2, 'tax_rate1' => $quote->tax_rate1, 'tax_rate2' => $quote->tax_rate2, - 'invoice_id' => $quote->quote_invoice_id, + 'invoice_id' => Quote::getPrivateId($quote->quote_invoice_id), 'custom_surcharge1' => $quote->custom_value1 ?: '', 'custom_surcharge2' => $quote->custom_value2 ?: '', 'custom_value1' => $quote->custom_text_value1 ?: '',