From 687f1b0ff97c13aa0e6568df63ea69ef1f2f1fbf Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Thu, 1 Feb 2018 23:12:50 +0800 Subject: [PATCH] Add more work on InvoiceCreator --- src/Service/InvoiceCreator.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Service/InvoiceCreator.php b/src/Service/InvoiceCreator.php index 3c3c3e1f..bf5fdd00 100644 --- a/src/Service/InvoiceCreator.php +++ b/src/Service/InvoiceCreator.php @@ -8,6 +8,8 @@ use App\Entity\Invoice; use App\Entity\InvoiceItem; use App\Entity\User; +use Doctrine\Common\Util\Debug; + class InvoiceCreator { const VAT_RATE = 0.12; @@ -65,6 +67,13 @@ class InvoiceCreator $total['vat_ex_price'] += $vat_ex_price; $total['total_price'] += $sell_price; + + // add item + $item = new InvoiceItem(); + $item->setInvoice($invoice) + ->setTitle($batt->getModel() . ' ' . $batt->getSize()) + ->setQuantity(1) + ->setPrice($sell_price); } // get trade-ins @@ -76,6 +85,13 @@ class InvoiceCreator $total['ti_rate'] += $ti_rate; $total['total_price'] -= $ti_rate; + + // add item + $item = new InvoiceItem(); + $item->setInvoice($invoice) + ->setTitle('Trade-in battery') + ->setQuantity(1) + ->setPrice($ti_rate); } // TODO: check if any promo is applied @@ -86,6 +102,10 @@ class InvoiceCreator ->setVAT($total['vat']) ->setDiscount($total['ti_rate']); + + // dump + Debug::dump($invoice, 1); + return $invoice; } }