mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Merge pull request #6581 from turbo124/master
Minor fixes for migration
This commit is contained in:
commit
d5c264f540
@ -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");
|
||||
@ -826,8 +879,13 @@ trait GenerateMigrationResources
|
||||
|
||||
$due_date_parts = explode("-", $invoice->due_date);
|
||||
|
||||
if(is_array($due_date_parts) && count($due_date_parts) >=3)
|
||||
if(is_array($due_date_parts) && count($due_date_parts) >=3){
|
||||
|
||||
if($due_date_parts[2] == "00")
|
||||
return "0";
|
||||
|
||||
return (string)$due_date_parts[2];
|
||||
}
|
||||
|
||||
return 'terms';
|
||||
}
|
||||
@ -1970,7 +2028,7 @@ trait GenerateMigrationResources
|
||||
'custom_value4' => '',
|
||||
'email' => $contact->email,
|
||||
'is_primary' => (bool)$contact->is_primary,
|
||||
'send_email' => (bool)$contact->send_invoice ?: false,
|
||||
'send_email' => (bool)$contact->send_invoice ?: true,
|
||||
'confirmed' => $contact->confirmation_token ? true : false,
|
||||
'email_verified_at' => $contact->created_at->toDateTimeString(),
|
||||
'last_login' => $contact->last_login,
|
||||
|
Loading…
Reference in New Issue
Block a user