mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'master' of https://github.com/turbo124/invoiceninja
This commit is contained in:
commit
e3039763c6
@ -7,6 +7,7 @@ use App\Models\User;
|
|||||||
use App\Traits\GenerateMigrationResources;
|
use App\Traits\GenerateMigrationResources;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ExportMigrations extends Command
|
class ExportMigrations extends Command
|
||||||
{
|
{
|
||||||
@ -63,12 +64,12 @@ class ExportMigrations extends Command
|
|||||||
|
|
||||||
|
|
||||||
if($this->option('email')) {
|
if($this->option('email')) {
|
||||||
$record = User::on(DB_NINJA_1)->where('email', $this->option('user'))->first();
|
$record = User::on(DB_NINJA_1)->where('email', $this->option('email'))->first();
|
||||||
|
|
||||||
if($record)
|
if($record)
|
||||||
return $this->export($record);
|
return $this->export($record);
|
||||||
|
|
||||||
$record = User::on(DB_NINJA_2)->where('email', $this->option('user'))->first();
|
$record = User::on(DB_NINJA_2)->where('email', $this->option('email'))->first();
|
||||||
|
|
||||||
if($record)
|
if($record)
|
||||||
return $this->export($record);
|
return $this->export($record);
|
||||||
@ -120,6 +121,7 @@ class ExportMigrations extends Command
|
|||||||
'products' => $this->getProducts(),
|
'products' => $this->getProducts(),
|
||||||
'credits' => $this->getCreditsNotes(),
|
'credits' => $this->getCreditsNotes(),
|
||||||
'invoices' => $this->getInvoices(),
|
'invoices' => $this->getInvoices(),
|
||||||
|
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||||
'quotes' => $this->getQuotes(),
|
'quotes' => $this->getQuotes(),
|
||||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||||
@ -132,6 +134,7 @@ class ExportMigrations extends Command
|
|||||||
'ninja_tokens' => $this->getNinjaToken(),
|
'ninja_tokens' => $this->getNinjaToken(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Storage::makeDirectory('migrations');
|
||||||
$file = storage_path("migrations/{$fileName}.zip");
|
$file = storage_path("migrations/{$fileName}.zip");
|
||||||
|
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
|
@ -322,6 +322,7 @@ class StepsController extends BaseController
|
|||||||
'products' => $this->getProducts(),
|
'products' => $this->getProducts(),
|
||||||
'credits' => $this->getCreditsNotes(),
|
'credits' => $this->getCreditsNotes(),
|
||||||
'invoices' => $this->getInvoices(),
|
'invoices' => $this->getInvoices(),
|
||||||
|
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||||
'quotes' => $this->getQuotes(),
|
'quotes' => $this->getQuotes(),
|
||||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||||
|
@ -141,6 +141,7 @@ class HostedMigration extends Job
|
|||||||
'products' => $this->getProducts(),
|
'products' => $this->getProducts(),
|
||||||
'credits' => $this->getCreditsNotes(),
|
'credits' => $this->getCreditsNotes(),
|
||||||
'invoices' => $this->getInvoices(),
|
'invoices' => $this->getInvoices(),
|
||||||
|
'recurring_expenses' => $this->getRecurringExpenses(),
|
||||||
'recurring_invoices' => $this->getRecurringInvoices(),
|
'recurring_invoices' => $this->getRecurringInvoices(),
|
||||||
'quotes' => $this->getQuotes(),
|
'quotes' => $this->getQuotes(),
|
||||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||||
|
@ -20,6 +20,7 @@ use App\Models\PaymentMethod;
|
|||||||
use App\Models\PaymentTerm;
|
use App\Models\PaymentTerm;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
|
use App\Models\RecurringExpense;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TaskStatus;
|
use App\Models\TaskStatus;
|
||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
@ -682,6 +683,57 @@ trait GenerateMigrationResources
|
|||||||
return $design_id;
|
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()
|
protected function getRecurringInvoices()
|
||||||
{
|
{
|
||||||
info("get recurring invoices");
|
info("get recurring invoices");
|
||||||
@ -827,8 +879,13 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
$due_date_parts = explode("-", $invoice->due_date);
|
$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 (string)$due_date_parts[2];
|
||||||
|
}
|
||||||
|
|
||||||
return 'terms';
|
return 'terms';
|
||||||
}
|
}
|
||||||
@ -1971,7 +2028,7 @@ trait GenerateMigrationResources
|
|||||||
'custom_value4' => '',
|
'custom_value4' => '',
|
||||||
'email' => $contact->email,
|
'email' => $contact->email,
|
||||||
'is_primary' => (bool)$contact->is_primary,
|
'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,
|
'confirmed' => $contact->confirmation_token ? true : false,
|
||||||
'email_verified_at' => $contact->created_at->toDateTimeString(),
|
'email_verified_at' => $contact->created_at->toDateTimeString(),
|
||||||
'last_login' => $contact->last_login,
|
'last_login' => $contact->last_login,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user