Add custom trade in types, warranty class, and modes of payment. #270

This commit is contained in:
Korina Cordero 2019-10-29 04:54:51 +00:00
parent f5606d83c0
commit 29cc7374cc
7 changed files with 48 additions and 21 deletions

View file

@ -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;

View file

@ -0,0 +1,16 @@
<?php
namespace App\Ramcar;
class CMBModeOfPayment extends NameValue
{
const CASH = 'cash';
const CREDIT_CARD = 'credit_card';
const BANK_TRANSFER = 'bank_transfer';
const COLLECTION = [
'cash' => 'Cash',
'credit_card' => 'Credit Card',
'bank_transfer' => 'Bank Transfer',
];
}

View file

@ -4,10 +4,10 @@ namespace App\Ramcar;
class CMBTradeInType extends NameValue
{
const REGULAR = 'regular';
const YES = 'yes';
const COLLECTION = [
'regular' => 'Regular',
'yes' => 'Yes',
];
}

View file

@ -0,0 +1,15 @@
<?php
namespace App\Ramcar;
class CMBWarrantyClass extends NameValue
{
const WTY_PASSENGER = 'passenger';
const WTY_COMMERCIAL = 'commercial';
const COLLECTION = [
'passenger' => 'Passenger',
'commercial' => 'Commercial',
];
}

View file

@ -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();
}

View file

@ -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();
}
}

View file

@ -492,7 +492,7 @@
<div class="col-lg-2">
<label for="invoice-trade-in-type">Trade In</label>
<select class="form-control m-input" id="invoice-trade-in-type">
<option value="">None</option>
<option value="">No</option>
{% for key, type in trade_in_types %}
<option value="{{ key }}">{{ type }}</option>
{% endfor %}