From 29cc7374cc5dffdf6b5f5e9461d051a3e91e1ee6 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 29 Oct 2019 04:54:51 +0000 Subject: [PATCH] Add custom trade in types, warranty class, and modes of payment. #270 --- src/Controller/JobOrderController.php | 2 -- src/Ramcar/CMBModeOfPayment.php | 16 ++++++++++++ src/Ramcar/CMBTradeInType.php | 4 +-- src/Ramcar/CMBWarrantyClass.php | 15 +++++++++++ .../InvoiceGenerator/CMBInvoiceGenerator.php | 4 +-- .../JobOrderHandler/CMBJobOrderHandler.php | 26 +++++++++---------- templates/job-order/form.html.twig | 2 +- 7 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 src/Ramcar/CMBModeOfPayment.php create mode 100644 src/Ramcar/CMBWarrantyClass.php diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 69fe7eb8..77fffe0f 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -2,9 +2,7 @@ namespace App\Controller; -use App\Ramcar\ServiceType; use App\Ramcar\JOStatus; -use App\Ramcar\TradeInType; use App\Ramcar\InvoiceCriteria; use App\Entity\CustomerVehicle; diff --git a/src/Ramcar/CMBModeOfPayment.php b/src/Ramcar/CMBModeOfPayment.php new file mode 100644 index 00000000..c7ae9908 --- /dev/null +++ b/src/Ramcar/CMBModeOfPayment.php @@ -0,0 +1,16 @@ + 'Cash', + 'credit_card' => 'Credit Card', + 'bank_transfer' => 'Bank Transfer', + ]; +} diff --git a/src/Ramcar/CMBTradeInType.php b/src/Ramcar/CMBTradeInType.php index 0510f928..8813f441 100644 --- a/src/Ramcar/CMBTradeInType.php +++ b/src/Ramcar/CMBTradeInType.php @@ -4,10 +4,10 @@ namespace App\Ramcar; class CMBTradeInType extends NameValue { - const REGULAR = 'regular'; + const YES = 'yes'; const COLLECTION = [ - 'regular' => 'Regular', + 'yes' => 'Yes', ]; } diff --git a/src/Ramcar/CMBWarrantyClass.php b/src/Ramcar/CMBWarrantyClass.php new file mode 100644 index 00000000..1e2c69b4 --- /dev/null +++ b/src/Ramcar/CMBWarrantyClass.php @@ -0,0 +1,15 @@ + 'Passenger', + 'commercial' => 'Commercial', + ]; + +} diff --git a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php index 92950ff4..f25348a4 100644 --- a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php @@ -215,9 +215,9 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface switch ($trade_in) { - // TODO: for now, REGULAR uses getTIPriceMotolite. + // TODO: for now, tradein uses getTIPriceMotolite. // Might need to modify later - case CMBTradeInType::REGULAR: + case CMBTradeInType::YES: return $size->getTIPriceMotolite(); } diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index 5ac7f4c1..8914bec5 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -30,9 +30,9 @@ use App\Ramcar\CMBServiceType; use App\Ramcar\CMBTradeInType; use App\Ramcar\JOEventType; use App\Ramcar\JOStatus; -use App\Ramcar\WarrantyClass; +use App\Ramcar\CMBWarrantyClass; use App\Ramcar\DiscountApply; -use App\Ramcar\ModeOfPayment; +use App\Ramcar\CMBModeOfPayment; use App\Ramcar\TransactionOrigin; use App\Ramcar\FacilitatedType; use App\Ramcar\JORejectionReason; @@ -1778,14 +1778,14 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $y = $pdf->GetY(); $pdf->Cell($label_width, $line_height, 'Warranty Class:'); - $pdf->MultiCell($val_width, $line_height, WarrantyClass::getName($obj->getWarrantyClass()), 0, 'L'); + $pdf->MultiCell($val_width, $line_height, CMBWarrantyClass::getName($obj->getWarrantyClass()), 0, 'L'); // get Y after left cell $y1 = $pdf->GetY(); $pdf->SetXY($col2_x, $y); $pdf->Cell($label_width, $line_height, 'Mode of Payment:'); - $pdf->MultiCell(0, $line_height, ModeOfPayment::getName($obj->getModeOfPayment()), 0, 'L'); + $pdf->MultiCell(0, $line_height, CMBModeOfPayment::getName($obj->getModeOfPayment()), 0, 'L'); // get Y after right cell $y2 = $pdf->GetY(); @@ -1974,8 +1974,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // name values $params['service_types'] = CMBServiceType::getCollection(); - $params['warranty_classes'] = WarrantyClass::getCollection(); - $params['modes_of_payment'] = ModeOfPayment::getCollection(); + $params['warranty_classes'] = CMBWarrantyClass::getCollection(); + $params['modes_of_payment'] = CMBModeOfPayment::getCollection(); $params['statuses'] = JOStatus::getCollection(); $params['discount_apply'] = DiscountApply::getCollection(); $params['trade_in_types'] = CMBTradeInType::getCollection(); @@ -2153,13 +2153,12 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface return; // warranty expiration + // use GetWarrantyPrivate for passenger warranty $warr = $jo->getWarrantyClass(); - if ($warr == WarrantyClass::WTY_PRIVATE) + if ($warr == CMBWarrantyClass::WTY_PASSENGER) $warr_months = $battery->getWarrantyPrivate(); - else if ($warr == WarrantyClass::WTY_COMMERCIAL) + else if ($warr == CMBWarrantyClass::WTY_COMMERCIAL) $warr_months = $battery->getWarrantyCommercial(); - else if ($warr == WarrantyClass::WTY_TNV) - $warr_months = $battery->getWarrantyTnv(); $warr_date = new DateTime(); $warr_date->add(new DateInterval('P' . $warr_months . 'M')); @@ -2199,12 +2198,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $warranty->setBatteryModel($battery->getModel()); $warranty->setBatterySize($battery->getSize()); - if ($warranty_class == WarrantyClass::WTY_PRIVATE) + // use getWarrantyPrivate for passenger warranty + if ($warranty_class == CMBWarrantyClass::WTY_PASSENGER) $warranty_period = $battery->getWarrantyPrivate(); - else if ($warranty_class == WarrantyClass::WTY_COMMERCIAL) + else if ($warranty_class == CMBWarrantyClass::WTY_COMMERCIAL) $warranty_period = $battery->getWarrantyCommercial(); - else if ($warranty_class == WarrantyClass::WTY_TNV) - $warranty_period = $battery->getWarrantyTnv(); } } diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 40186472..c8951932 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -492,7 +492,7 @@