Fix issues found during testing. #744
This commit is contained in:
parent
b4bcc06e42
commit
2f3a77e96d
5 changed files with 54 additions and 49 deletions
|
|
@ -45,13 +45,14 @@ class TestInvoiceManagerCommand extends Command
|
||||||
$this->testBatterySalesNoTradeInNoDiscountWithTax();
|
$this->testBatterySalesNoTradeInNoDiscountWithTax();
|
||||||
$this->testBatterySalesQuantityNoTradeInNoDiscountWithTax();
|
$this->testBatterySalesQuantityNoTradeInNoDiscountWithTax();
|
||||||
|
|
||||||
/*
|
|
||||||
// battery sales without tax
|
// battery sales without tax
|
||||||
$this->testBatterySalesNoTradeInNoDiscountWithoutTax();
|
$this->testBatterySalesNoTradeInNoDiscountWithoutTax();
|
||||||
$this->testBatterySalesQuantityNoTradeInNoDiscountWithoutTax();
|
$this->testBatterySalesQuantityNoTradeInNoDiscountWithoutTax();
|
||||||
|
|
||||||
// battery sales with trade in with tax
|
// battery sales with trade in with tax
|
||||||
$this->testBatterySalesTradeInSameBatteryPremiumNoDiscountWithTax();
|
$this->testBatterySalesTradeInSameBatteryPremiumNoDiscountWithTax();
|
||||||
|
|
||||||
$this->testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithTax();
|
$this->testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithTax();
|
||||||
$this->testBatterySalesTradeInSameBatteryOtherNoDiscountWithTax();
|
$this->testBatterySalesTradeInSameBatteryOtherNoDiscountWithTax();
|
||||||
$this->testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithTax();
|
$this->testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithTax();
|
||||||
|
|
@ -154,7 +155,7 @@ class TestInvoiceManagerCommand extends Command
|
||||||
$this->testGenerateDraftInvoiceBatterySalesNoPromo();
|
$this->testGenerateDraftInvoiceBatterySalesNoPromo();
|
||||||
|
|
||||||
// test generateInvoiceInvoice call from ajax call
|
// test generateInvoiceInvoice call from ajax call
|
||||||
$this->testGenerateInvoice(); */
|
$this->testGenerateInvoice();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +176,7 @@ class TestInvoiceManagerCommand extends Command
|
||||||
|
|
||||||
$invoice_data = $this->inv_manager->compute($criteria);
|
$invoice_data = $this->inv_manager->compute($criteria);
|
||||||
|
|
||||||
// error_log(print_r(json_encode($invoice_data), true));
|
error_log(print_r(json_encode($invoice_data), true));
|
||||||
|
|
||||||
foreach ($invoice_data as $data)
|
foreach ($invoice_data as $data)
|
||||||
{
|
{
|
||||||
|
|
@ -303,6 +304,8 @@ class TestInvoiceManagerCommand extends Command
|
||||||
|
|
||||||
$invoice_data = $this->inv_manager->compute($criteria);
|
$invoice_data = $this->inv_manager->compute($criteria);
|
||||||
|
|
||||||
|
error_log(print_r(json_encode($invoice_data), true));
|
||||||
|
|
||||||
foreach ($invoice_data as $data)
|
foreach ($invoice_data as $data)
|
||||||
{
|
{
|
||||||
$invoice_items = $data['invoice_items'];
|
$invoice_items = $data['invoice_items'];
|
||||||
|
|
@ -805,6 +808,7 @@ class TestInvoiceManagerCommand extends Command
|
||||||
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($promo != null)
|
||||||
error_log('PROMO ' . $promo->getName());
|
error_log('PROMO ' . $promo->getName());
|
||||||
|
|
||||||
error_log('TOTAL ' . print_r(json_encode($total), true));
|
error_log('TOTAL ' . print_r(json_encode($total), true));
|
||||||
|
|
@ -844,6 +848,7 @@ class TestInvoiceManagerCommand extends Command
|
||||||
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($promo != null)
|
||||||
error_log('PROMO ' . $promo->getName());
|
error_log('PROMO ' . $promo->getName());
|
||||||
|
|
||||||
error_log('TOTAL ' . print_r(json_encode($total), true));
|
error_log('TOTAL ' . print_r(json_encode($total), true));
|
||||||
|
|
@ -888,8 +893,8 @@ class TestInvoiceManagerCommand extends Command
|
||||||
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($promo != null)
|
||||||
error_log('PROMO ' . $promo->getName());
|
error_log('PROMO ' . $promo->getName());
|
||||||
|
|
||||||
error_log('TOTAL ' . print_r(json_encode($total), true));
|
error_log('TOTAL ' . print_r(json_encode($total), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -972,6 +977,7 @@ class TestInvoiceManagerCommand extends Command
|
||||||
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($promo != null)
|
||||||
error_log('PROMO ' . $promo->getName());
|
error_log('PROMO ' . $promo->getName());
|
||||||
|
|
||||||
error_log('TOTAL ' . print_r(json_encode($total), true));
|
error_log('TOTAL ' . print_r(json_encode($total), true));
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,10 @@ class BatteryReplacementWarranty implements InvoiceRuleInterface
|
||||||
|
|
||||||
public function validateInvoiceItems($criteria, $invoice_items)
|
public function validateInvoiceItems($criteria, $invoice_items)
|
||||||
{
|
{
|
||||||
// check service type. Only battery sales and battery warranty should have invoice items
|
// check service type. Only battery sales and battery warranty should have invoice items. Since this is the
|
||||||
|
// battery replacement warranty rule, we only check for battery replacement warranty.
|
||||||
$stype = $criteria->getServiceType();
|
$stype = $criteria->getServiceType();
|
||||||
if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW && $stype != ServiceType::BATTERY_REPLACEMENT_WARRANTY)
|
if ($stype != ServiceType::BATTERY_REPLACEMENT_WARRANTY)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// return error if there's a problem, false otherwise
|
// return error if there's a problem, false otherwise
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,10 @@ class BatterySales implements InvoiceRuleInterface
|
||||||
|
|
||||||
public function validateInvoiceItems($criteria, $invoice_items)
|
public function validateInvoiceItems($criteria, $invoice_items)
|
||||||
{
|
{
|
||||||
// check service type. Only battery sales and battery warranty should have invoice items
|
// check service type. Only battery sales and battery warranty should have invoice items. Since this is the battery sales
|
||||||
|
// rule, we only check for battery sales.
|
||||||
$stype = $criteria->getServiceType();
|
$stype = $criteria->getServiceType();
|
||||||
if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW && $stype != ServiceType::BATTERY_REPLACEMENT_WARRANTY)
|
if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// return error if there's a problem, false otherwise
|
// return error if there's a problem, false otherwise
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Fuel implements InvoiceRuleInterface
|
||||||
case FuelType::GAS:
|
case FuelType::GAS:
|
||||||
case FuelType::DIESEL:
|
case FuelType::DIESEL:
|
||||||
$qty = 1;
|
$qty = 1;
|
||||||
$price = $this->getFuelFee();
|
$price = $this->getFuelFee($ftype);
|
||||||
$items[] = [
|
$items[] = [
|
||||||
'service_type' => $this->getID(),
|
'service_type' => $this->getID(),
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,8 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
|
|
||||||
$invoice = $this->createInvoice($invoice_data);
|
$invoice = $this->createInvoice($invoice_data);
|
||||||
|
|
||||||
|
$invoice_items = $invoice->getItems();
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,15 +190,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
$promos = $criteria->getPromos();
|
$promos = $criteria->getPromos();
|
||||||
$is_taxable = $criteria->isTaxable();
|
$is_taxable = $criteria->isTaxable();
|
||||||
|
|
||||||
$flag_trade_in = false;
|
|
||||||
foreach ($entries as $entry)
|
|
||||||
{
|
|
||||||
if ($entry['trade_in'] != null)
|
|
||||||
{
|
|
||||||
$flag_trade_in = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoice_items = [];
|
$invoice_items = [];
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($this->available_rules as $rule)
|
foreach ($this->available_rules as $rule)
|
||||||
|
|
@ -204,6 +197,9 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
$items = $rule->compute($criteria, $total);
|
$items = $rule->compute($criteria, $total);
|
||||||
|
|
||||||
$promo = null;
|
$promo = null;
|
||||||
|
|
||||||
|
if (count($items) > 0)
|
||||||
|
{
|
||||||
foreach ($items as $item)
|
foreach ($items as $item)
|
||||||
{
|
{
|
||||||
$title = $item['title'];
|
$title = $item['title'];
|
||||||
|
|
@ -226,6 +222,8 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
'promo' => $promo,
|
'promo' => $promo,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// also need to return the total and the promo
|
// also need to return the total and the promo
|
||||||
$data[] = [
|
$data[] = [
|
||||||
|
|
@ -233,7 +231,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
'invoice_items' => $invoice_items,
|
'invoice_items' => $invoice_items,
|
||||||
'total' => $total,
|
'total' => $total,
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue