mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
Recurring Expenses migration
This commit is contained in:
parent
fd4cf13234
commit
a66b500fc6
@ -121,6 +121,7 @@ class ExportMigrations extends Command
|
||||
'products' => $this->getProducts(),
|
||||
'credits' => $this->getCreditsNotes(),
|
||||
'invoices' => $this->getInvoices(),
|
||||
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||
'quotes' => $this->getQuotes(),
|
||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||
|
@ -322,6 +322,7 @@ class StepsController extends BaseController
|
||||
'products' => $this->getProducts(),
|
||||
'credits' => $this->getCreditsNotes(),
|
||||
'invoices' => $this->getInvoices(),
|
||||
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||
'quotes' => $this->getQuotes(),
|
||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||
|
@ -141,6 +141,7 @@ class HostedMigration extends Job
|
||||
'products' => $this->getProducts(),
|
||||
'credits' => $this->getCreditsNotes(),
|
||||
'invoices' => $this->getInvoices(),
|
||||
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||
'quotes' => $this->getQuotes(),
|
||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||
|
@ -20,6 +20,7 @@ use App\Models\PaymentMethod;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\RecurringExpense;
|
||||
use App\Models\Task;
|
||||
use App\Models\TaskStatus;
|
||||
use App\Models\TaxRate;
|
||||
@ -656,6 +657,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,
|
||||
];
|
||||
}
|
||||
|
||||
@ -681,6 +683,57 @@ trait GenerateMigrationResources
|
||||
return $design_id;
|
||||
}
|
||||
|
||||
protected function getRecurringExpenses()
|
||||
{
|
||||
info("get recurring Expenses");
|
||||
|
||||
|
||||
$expenses = [];
|
||||
|
||||
$export_expenses = RecurringExpense::where('account_id', $this->account->id)
|
||||
->withTrashed()
|
||||
->get();
|
||||
|
||||
foreach ($export_expenses as $expense) {
|
||||
$invoices[] = [
|
||||
'id' => $expense->id,
|
||||
'amount' => $expense->amount,
|
||||
'company_id' => $this->account->id,
|
||||
'client_id' => $expense->client_id,
|
||||
'user_id' => $expense->user_id,
|
||||
'custom_value1' => '',
|
||||
'custom_value2' => '',
|
||||
'custom_value3' => '',
|
||||
'custom_value4' => '',
|
||||
'category_id' => $expense->expense_category_id,
|
||||
'currency_id' => $expense->expense_currency_id,
|
||||
'frequency_id' => $this->transformFrequencyId($expense->frequency_id),
|
||||
'invoice_currency_id' => $expense->invoice_currency_id,
|
||||
'private_notes' => $expense->private_notes,
|
||||
'public_notes' => $expense->public_notes,
|
||||
'should_be_invoiced' => $expense->should_be_invoiced,
|
||||
'tax_name1' => $expense->tax_name1,
|
||||
'tax_name2' => $expense->tax_name2,
|
||||
'tax_name3' => '',
|
||||
'tax_rate1' => $expense->tax_rate1,
|
||||
'tax_rate2' => $expense->tax_rate2,
|
||||
'tax_rate3' => 0,
|
||||
'vendor_id' => $expense->vendor_id,
|
||||
'is_deleted' => $expense->is_deleted,
|
||||
'next_send_date' => $this->getNextSendDateForMigration($expense),
|
||||
'remaining_cycles' => $this->getRemainingCycles($expense),
|
||||
'created_at' => $expense->created_at ? Carbon::parse($expense->created_at)->toDateString() : null,
|
||||
'updated_at' => $expense->updated_at ? Carbon::parse($expense->updated_at)->toDateString() : null,
|
||||
'deleted_at' => $expense->deleted_at ? Carbon::parse($expense->deleted_at)->toDateString() : null,
|
||||
];
|
||||
}
|
||||
|
||||
return $invoices;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getRecurringInvoices()
|
||||
{
|
||||
info("get recurring invoices");
|
||||
|
Loading…
Reference in New Issue
Block a user