From 5b5fbd7555cfeecb62c5437fe2a1df1cc7808d07 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 9 Apr 2018 22:30:00 +0800 Subject: [PATCH] Add general service - under warranty service type #88 --- src/Ramcar/ServiceType.php | 2 ++ src/Service/InvoiceCreator.php | 12 ++++++++++++ templates/job-order/form.html.twig | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Ramcar/ServiceType.php b/src/Ramcar/ServiceType.php index abdc19e4..29bc03a7 100644 --- a/src/Ramcar/ServiceType.php +++ b/src/Ramcar/ServiceType.php @@ -7,6 +7,7 @@ class ServiceType extends NameValue const BATTERY_REPLACEMENT_NEW = 'battery_new'; const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty'; const JUMPSTART_TROUBLESHOOT = 'jumpstart_troubleshoot'; + const JUMPSTART_WARRANTY = 'jumpstart_warranty'; const POST_RECHARGED = 'post_recharged'; const POST_REPLACEMENT = 'post_replacement'; const TIRE_REPAIR = 'tire'; @@ -17,6 +18,7 @@ class ServiceType extends NameValue 'battery_new' => 'Battery Sales', 'battery_warranty' => 'Under Warranty', 'jumpstart_troubleshoot' => 'General Service', + 'jumpstart_warranty' => 'General Service - Warranty', 'post_recharged' => 'Post - Recharged', 'post_replacement' => 'Post - Replacement', 'tire' => 'Flat Tire', diff --git a/src/Service/InvoiceCreator.php b/src/Service/InvoiceCreator.php index fee5a02f..e5931062 100644 --- a/src/Service/InvoiceCreator.php +++ b/src/Service/InvoiceCreator.php @@ -203,6 +203,16 @@ class InvoiceCreator $total['total_price'] = 150.00; } + public function processJumpstartWarranty(&$total, $invoice) + { + $item = new InvoiceItem(); + $item->setInvoice($invoice) + ->setTitle('Troubleshooting fee') + ->setQuantity(1) + ->setPrice(0.00); + $invoice->addItem($item); + } + public function processRecharge(&$total, $invoice) { // add recharge fee @@ -265,6 +275,8 @@ class InvoiceCreator case ServiceType::JUMPSTART_TROUBLESHOOT: $this->processJumpstart($total, $invoice); break; + case ServiceType::JUMPSTART_WARRANTY: + $this->processJumpstartWarranty($total, $invoice); case ServiceType::BATTERY_REPLACEMENT_NEW: $this->processEntries($total, $criteria, $invoice); diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index fb71bc70..ce03c714 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -461,8 +461,8 @@ {% for item in obj.getInvoice.getItems %} {{ item.getTitle }} - {{ item.getPrice|number_format(2) }} {{ item.getQuantity|number_format }} + {{ item.getPrice|number_format(2) }} {{ (item.getPrice * item.getQuantity)|number_format(2) }} {% endfor %} -- 2.43.5