1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Model updates

This commit is contained in:
David Bomba 2019-05-30 08:22:25 +10:00
parent 32ca69bc52
commit f20183025b
5 changed files with 31 additions and 24 deletions

View File

@ -50,6 +50,7 @@ class InvoiceFactory
$invoice->partial = 0; $invoice->partial = 0;
$invoice->user_id = $user_id; $invoice->user_id = $user_id;
$invoice->company_id = $company_id; $invoice->company_id = $company_id;
$invoice->recurring_invoice_id = null;
return $invoice; return $invoice;
} }

View File

@ -24,6 +24,7 @@ class ProductFactory
$product->product_key = ''; $product->product_key = '';
$product->notes = ''; $product->notes = '';
$product->cost = 0; $product->cost = 0;
$product->price = 0;
$product->qty = 0; $product->qty = 0;
$product->tax_name1 = ''; $product->tax_name1 = '';
$product->tax_rate1 = 0; $product->tax_rate1 = 0;

View File

@ -16,7 +16,7 @@ use App\DataMapper\CompanySettings;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
class RecurringInvoiceToInvoiceFactory class recurring_invoiceToInvoiceFactory
{ {
public static function create(RecurringInvoice $recurring_invoice) :Invoice public static function create(RecurringInvoice $recurring_invoice) :Invoice
@ -24,30 +24,31 @@ class RecurringInvoiceToInvoiceFactory
$invoice = new Invoice(); $invoice = new Invoice();
$invoice->status_id = Invoice::STATUS_DRAFT; $invoice->status_id = Invoice::STATUS_DRAFT;
$invoice->discount = $recurring_invoice->discount; $invoice->discount = $recurring_invoice->discount;
$invoice->is_amount_discount = $recurringinvoice->is_amount_discount; $invoice->is_amount_discount = $recurring_invoice->is_amount_discount;
$invoice->po_number = $recurringinvoice->po_number; $invoice->po_number = $recurring_invoice->po_number;
$invoice->footer = $recurringinvoice->footer; $invoice->footer = $recurring_invoice->footer;
$invoice->terms = $recurringinvoice->terms; $invoice->terms = $recurring_invoice->terms;
$invoice->public_notes = $recurringinvoice->public_notes; $invoice->public_notes = $recurring_invoice->public_notes;
$invoice->private_notes = $recurringinvoice->private_notes; $invoice->private_notes = $recurring_invoice->private_notes;
$invoice->invoice_date = date_create()->format(config('ninja.date_format')); $invoice->invoice_date = date_create()->format(config('ninja.date_format'));
$invoice->due_date = $recurringinvoice->due_date; //todo calculate based on terms $invoice->due_date = $recurring_invoice->due_date; //todo calculate based on terms
$invoice->is_deleted = $recurringinvoice->is_deleted; $invoice->is_deleted = $recurring_invoice->is_deleted;
$invoice->line_items = $recurringinvoice->line_items; $invoice->line_items = $recurring_invoice->line_items;
$invoice->settings = $recurringinvoice->settings; $invoice->settings = $recurring_invoice->settings;
$invoice->backup = json_encode([]); $invoice->backup = json_encode([]);
$invoice->tax_name1 = $recurringinvoice->tax_name1; $invoice->tax_name1 = $recurring_invoice->tax_name1;
$invoice->tax_rate1 = $recurringinvoice->tax_rate1; $invoice->tax_rate1 = $recurring_invoice->tax_rate1;
$invoice->tax_name2 = $recurringinvoice->tax_name2; $invoice->tax_name2 = $recurring_invoice->tax_name2;
$invoice->tax_rate2 = $recurringinvoice->tax_rate2; $invoice->tax_rate2 = $recurring_invoice->tax_rate2;
$invoice->custom_value1 = $recurringinvoice->custom_value1; $invoice->custom_value1 = $recurring_invoice->custom_value1;
$invoice->custom_value2 = $recurringinvoice->custom_value2; $invoice->custom_value2 = $recurring_invoice->custom_value2;
$invoice->custom_value3 = $recurringinvoice->custom_value3; $invoice->custom_value3 = $recurring_invoice->custom_value3;
$invoice->custom_value4 = $recurringinvoice->custom_value4; $invoice->custom_value4 = $recurring_invoice->custom_value4;
$invoice->amount = $recurringinvoice->amount; $invoice->amount = $recurring_invoice->amount;
$invoice->balance = $recurringinvoice->balance; $invoice->balance = $recurring_invoice->balance;
$invoice->user_id = $recurringinvoice->user_id; $invoice->user_id = $recurring_invoice->user_id;
$invoice->company_id = $recurringinvoice->company_id; $invoice->company_id = $recurring_invoice->company_id;
$invoice->recurring_invoice_id = $recurring_invoice->id
return $invoice; return $invoice;
} }

View File

@ -7,6 +7,7 @@ $factory->define(App\Models\Product::class, function (Faker $faker) {
'product_key' => $faker->text(7), 'product_key' => $faker->text(7),
'notes' => $faker->text(20), 'notes' => $faker->text(20),
'cost' => $faker->numberBetween(1,1000), 'cost' => $faker->numberBetween(1,1000),
'price' => $faker->numberBetween(1,1000),
'qty' => $faker->numberBetween(1,100), 'qty' => $faker->numberBetween(1,100),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,

View File

@ -367,6 +367,8 @@ class CreateUsersTable extends Migration
$t->unsignedInteger('company_id')->index(); $t->unsignedInteger('company_id')->index();
$t->unsignedInteger('status_id'); $t->unsignedInteger('status_id');
$t->unsignedInteger('recurring_invoice_id')->nullable();
$t->string('invoice_number')->nullable(); $t->string('invoice_number')->nullable();
$t->float('discount'); $t->float('discount');
$t->boolean('is_amount_discount'); $t->boolean('is_amount_discount');
@ -648,6 +650,7 @@ class CreateUsersTable extends Migration
$t->string('product_key'); $t->string('product_key');
$t->text('notes'); $t->text('notes');
$t->decimal('cost', 13, 2); $t->decimal('cost', 13, 2);
$t->decimal('price', 13, 2);
$t->decimal('qty', 13, 2)->nullable(); $t->decimal('qty', 13, 2)->nullable();
$t->string('tax_name1')->nullable(); $t->string('tax_name1')->nullable();