diff --git a/app/Factory/InvoiceFactory.php b/app/Factory/InvoiceFactory.php index 428b5a2b7765..76f876788205 100644 --- a/app/Factory/InvoiceFactory.php +++ b/app/Factory/InvoiceFactory.php @@ -2,26 +2,36 @@ namespace App\Factory; +use App\Models\Invoice; + class InvoiceFactory { public static function create() :\stdClass { - $item = new \stdClass; - $item->qty = 0; - $item->cost = 0; - $item->product_key = ''; - $item->notes = ''; - $item->discount = 0; - $item->is_amount_discount = true; - $item->tax_name1 = ''; - $item->tax_rate1 = 0; - $item->tax_name2 = ''; - $item->tax_rate2 = 0; - $item->sort_id = 0; - $item->line_total = 0; - $item->invoice_item_type_id = 0; + $invoice = new \stdClass; + $invoice->invoice_status_id = Invoice::STATUS_DRAFT; + $invoice->invoice_number = ''; + $invoice->discount = 0; + $invoice->is_amount_discount = true; + $invoice->po_number = ''; + $invoice->invoice_date = null; + $invoice->due_date = null; + $invoice->is_deleted = false; + $invoice->line_items = json_encode([]); + $invoice->settings = json_encode([]); + $invoice->backup = json_encode([]); + $invoice->tax_name1 = ''; + $invoice->tax_rate1 = 0; + $invoice->tax_name2 = ''; + $invoice->tax_rate2 = 0; + $invoice->custom_value1 = ''; + $invoice->custom_value2 = ''; + $invoice->custom_value3 = ''; + $invoice->custom_value4 = ''; + $invoice->amount = 0; + $invoice->balance = 0; + $invoice->partial = 0; - return $item; + return $invoice; } } - diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 104f5088f010..a998503bf262 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -355,7 +355,7 @@ class CreateUsersTable extends Migration $t->boolean('is_deleted')->default(false); $t->text('line_items')->nullable(); - $t->text('options')->nullable(); + $t->text('settings')->nullable(); $t->text('backup')->nullable(); $t->string('tax_name1'); diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index 25e54a146fbf..74c1b892209a 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit; +use App\Factory\InvoiceFactory; use App\Factory\InvoiceItemFactory; use Tests\TestCase; @@ -11,11 +12,49 @@ use Tests\TestCase; */ class InvoiceTest extends TestCase { + + protected $invoice; + + protected $invoice_calc; + + private $settings; + public function setUp() { parent::setUp(); + $this->invoice = InvoiceFactory::create(); + $this->invoice->line_items = $this->buildLineItems(); + + $this->settings = $this->buildSettings(); + + $this->invoice_calc = new InvoiceCalc($this->invoice, $this->settings); } + + private function buildSettings() + { + + } + + private function buildLineItems() + { + $line_items = []; + + $item = InvoiceItemFactory::create(); + $item->qty = 1; + $item->cost =10; + + $line_items[] = $item; + + $item = InvoiceItemFactory::create(); + $item->qty = 1; + $item->cost =10; + + $line_items[] = $item; + + return $line_items; + + } } \ No newline at end of file