From d6049b026ed7c83ad61ad7be753bf2d37c16c7f4 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 11 Sep 2021 20:35:23 +1000 Subject: [PATCH 1/4] Add recurring --- app/Traits/GenerateMigrationResources.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 5518c663af5c..8b20ff630be4 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -656,6 +656,7 @@ trait GenerateMigrationResources 'deleted_at' => $invoice->deleted_at ? Carbon::parse($invoice->deleted_at)->toDateString() : null, 'invitations' => $this->getResourceInvitations($invoice->invitations, 'invoice_id'), 'auto_bill_enabled' => $invoice->auto_bill, + 'recurring_id' => $invoice->recurring_invoice_id, ]; } From e751a1ddbf6986679e9a2e43f1b0229a20eab0b5 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 11 Sep 2021 21:05:35 +1000 Subject: [PATCH 2/4] 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 66b32c3c58c7..2e0deefd3a73 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 ?: '', From 37126963f635c4d3acf629dbb883db9569365855 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 11 Sep 2021 21:09:14 +1000 Subject: [PATCH 3/4] Adjustment for min/max of fee limits --- app/Traits/GenerateMigrationResources.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 2e0deefd3a73..67d6b596d60a 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -2108,8 +2108,8 @@ trait GenerateMigrationResources } $fees_and_limits = new \stdClass(); - $fees_and_limits->min_limit = $ags->min_limit ?: -1; - $fees_and_limits->max_limit = $ags->max_limit ?: -1; + $fees_and_limits->min_limit = $ags->min_limit > 0 ? $ags->min_limit : -1; + $fees_and_limits->max_limit = $ags->max_limit > 0 ? $ags->max_limit : -1; $fees_and_limits->fee_amount = $ags->fee_amount; $fees_and_limits->fee_percent = $ags->fee_percent; $fees_and_limits->fee_tax_name1 = $ags->tax_name1; From 4c6c71a85d4b3823732739ed0a8f1b71c7d60e3a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 12 Sep 2021 11:29:46 +1000 Subject: [PATCH 4/4] Add recurring expenses into export data --- app/Traits/GenerateMigrationResources.php | 92 +++++++++++++---------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 67d6b596d60a..c8eae3ec81a0 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -303,13 +303,13 @@ trait GenerateMigrationResources public function getTaxRates() { - info("get tax rates"); - $rates = TaxRate::where('account_id', $this->account->id) ->withTrashed() ->get(); + info("get tax rates => " . $rates->count()); + $transformed = []; foreach ($rates as $rate) { @@ -328,10 +328,12 @@ trait GenerateMigrationResources } protected function getClients() - {info("get clients"); + { $clients = []; + info("get clients => ". $this->account->clients()->count()); + foreach ($this->account->clients()->withTrashed()->get() as $client) { $number = $client->id_number; @@ -401,6 +403,8 @@ trait GenerateMigrationResources $transformed = []; + info("Importing contacts => " . $contacts->count()); + foreach ($contacts as $contact) { $transformed[] = [ 'id' => $contact->id, @@ -475,12 +479,13 @@ trait GenerateMigrationResources protected function getProducts() { - info("get products"); $products = Product::where('account_id', $this->account->id) ->withTrashed() ->get(); + info("get products " . $products->count()); + $transformed = []; foreach ($products as $product) { @@ -509,12 +514,13 @@ trait GenerateMigrationResources public function getUsers() { - info("get users"); $users = User::where('account_id', $this->account->id) ->withTrashed() ->get(); + info("get users " . $users->count()); + $transformed = []; foreach ($users as $user) { @@ -545,7 +551,6 @@ trait GenerateMigrationResources private function getCreditsNotes() { - info("get credit notes"); $credits = []; @@ -556,6 +561,8 @@ trait GenerateMigrationResources ->withTrashed() ->get(); + info("get credit notes => " . $export_credits->count()); + foreach ($export_credits as $credit) { $credits[] = [ 'id' => $credit->id, @@ -602,7 +609,7 @@ trait GenerateMigrationResources protected function getInvoices() - { info("get invoices"); + { $invoices = []; @@ -613,6 +620,8 @@ trait GenerateMigrationResources ->withTrashed() ->get(); + info("get invoices -> ". $export_invoices->count()); + foreach ($export_invoices as $invoice) { $invoices[] = [ 'id' => $invoice->id, @@ -685,8 +694,6 @@ trait GenerateMigrationResources protected function getRecurringExpenses() { - info("get recurring Expenses"); - $expenses = []; @@ -694,8 +701,10 @@ trait GenerateMigrationResources ->withTrashed() ->get(); + info("get recurring Expenses => " . $export_expenses->count()); + foreach ($export_expenses as $expense) { - $invoices[] = [ + $expenses[] = [ 'id' => $expense->id, 'amount' => $expense->amount, 'company_id' => $this->account->id, @@ -728,7 +737,7 @@ trait GenerateMigrationResources ]; } - return $invoices; + return $expenses; @@ -736,8 +745,6 @@ trait GenerateMigrationResources protected function getRecurringInvoices() { - info("get recurring invoices"); - $invoices = []; @@ -745,7 +752,9 @@ trait GenerateMigrationResources ->where('amount', '>=', 0) ->where('is_recurring', true) ->withTrashed() - ->get(); + ->get(); + + info("get recurring invoices => " . $export_invoices->count()); foreach ($export_invoices as $invoice) { $invoices[] = [ @@ -1202,8 +1211,6 @@ trait GenerateMigrationResources public function getQuotes() { - info("get quotes"); - $transformed = []; @@ -1212,6 +1219,8 @@ trait GenerateMigrationResources ->withTrashed() ->get(); + info("get quotes => " . $quotes->count()); + foreach ($quotes as $quote) { $transformed[] = [ 'id' => $quote->id, @@ -1237,7 +1246,7 @@ trait GenerateMigrationResources 'tax_name2' => $quote->tax_name2, 'tax_rate1' => $quote->tax_rate1, 'tax_rate2' => $quote->tax_rate2, - 'invoice_id' => Quote::getPrivateId($quote->quote_invoice_id), + 'invoice_id' => Invoice::getPrivateId($quote->quote_invoice_id), 'custom_surcharge1' => $quote->custom_value1 ?: '', 'custom_surcharge2' => $quote->custom_value2 ?: '', 'custom_value1' => $quote->custom_text_value1 ?: '', @@ -1287,7 +1296,6 @@ trait GenerateMigrationResources public function getPayments() { - info("get payments"); $transformed = []; @@ -1296,6 +1304,9 @@ trait GenerateMigrationResources ->withTrashed() ->get(); + info("get payments => " . $payments->count()); + + foreach ($payments as $payment) { $transformed[] = [ 'id' => $payment->id, @@ -1423,12 +1434,13 @@ trait GenerateMigrationResources private function getCredits() { - info("get credits"); $credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false) ->withTrashed() ->get(); + info("get credits => " . $credits->count()); + $transformed = []; foreach ($credits as $credit) { @@ -1453,10 +1465,12 @@ trait GenerateMigrationResources private function getDocuments() { - info("get documents"); $documents = Document::where('account_id', $this->account->id)->get(); + info("get documents => " . $documents->count()); + + $transformed = []; foreach ($documents as $document) { @@ -1508,10 +1522,11 @@ trait GenerateMigrationResources private function getCompanyGateways() { - info("get get company gateways"); $account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get(); + info("get get company gateways => " . $account_gateways->count()); + $transformed = []; foreach ($account_gateways as $account_gateway) { @@ -1708,11 +1723,10 @@ trait GenerateMigrationResources private function getClientGatewayTokens() { - info("get client gateway tokens"); - - $payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get(); + info("get client gateway tokens => " . $payment_methods->count()); + $transformed = []; $is_default = true; @@ -1744,11 +1758,11 @@ trait GenerateMigrationResources private function getPaymentTerms() { - info("get payment terms"); - $payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get(); + info("get payment terms => " . $payment_terms->count()); + $transformed = []; foreach($payment_terms as $payment_term) @@ -1775,10 +1789,10 @@ trait GenerateMigrationResources private function getTaskStatuses() { - info("get task statuses"); - $task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get(); + info("get task statuses => " . $task_statuses->count()); + if($task_statuses->count() == 0) { $defaults = [ @@ -1821,10 +1835,10 @@ trait GenerateMigrationResources private function getExpenseCategories() { - info("get expense categories"); - $expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get(); + info("get expense categories => " . $expense_categories->count()); + $transformed = []; foreach ($expense_categories as $category) @@ -1846,10 +1860,10 @@ trait GenerateMigrationResources private function getExpenses() { - info("get expenses"); - $expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get(); + info("get expenses => " . $expenses->count()); + $transformed = []; foreach ($expenses as $expense) @@ -1901,13 +1915,13 @@ trait GenerateMigrationResources private function getTasks() { - info("get tasks"); - $tasks = Task::where('account_id', $this->account->id) ->withTrashed() ->get(); + info("get tasks => " . $tasks->count()); + $transformed = []; foreach ($tasks as $task) @@ -1944,12 +1958,14 @@ trait GenerateMigrationResources private function getProjects() { - info("get projects"); $projects = Project::where('account_id', $this->account->id) ->withTrashed() ->get(); + info("get projects => " . $projects); + + $transformed = []; foreach ($projects as $project) @@ -1986,10 +2002,10 @@ trait GenerateMigrationResources protected function getVendors() { - info("get vendors"); - $vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get(); + info("get vendors => " . $vendor_query->count()); + $vendors = []; foreach ($vendor_query as $vendor) { @@ -2033,7 +2049,7 @@ trait GenerateMigrationResources protected function getVendorContacts($contacts) { - info("get vendor contacts"); + info("get vendor contacts => " . $contacts->count()); $transformed = [];