621 lines
20 KiB
PHP
621 lines
20 KiB
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use App\Service\InvoiceManager;
|
|
use App\InvoiceCriteria;
|
|
|
|
use App\Ramcar\ServiceType;
|
|
|
|
use App\Entity\Battery;
|
|
use App\Entity\CustomerVehicle;
|
|
|
|
class TestInvoiceManagerCommand extends Command
|
|
{
|
|
protected $inv_manager;
|
|
protected $em;
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('test:generateinvoice')
|
|
->setDescription('Test invoice manager service.')
|
|
->setHelp('Test invoice manager service.');
|
|
}
|
|
|
|
public function __construct(InvoiceManager $inv_manager, EntityManagerInterface $em)
|
|
{
|
|
$this->em = $em;
|
|
$this->inv_manager = $inv_manager;
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
// battery sales
|
|
$this->testBatterySalesNoTradeInNoDiscount();
|
|
$this->testBatterySalesQuantityNoTradeInNoDiscount();
|
|
|
|
// battery sales with trade in
|
|
$this->testBatterySalesTradeInSameBatteryPremiumNoDiscount();
|
|
$this->testBatterySalesTradeInSameBatteryMotoliteNoDiscount();
|
|
$this->testBatterySalesTradeInSameBatteryOtherNoDiscount();
|
|
$this->testBatterySalesTradeInDifferentBatteryPremiumNoDiscount();
|
|
$this->testBatterySalesTradeInDifferentBatteryMotoliteNoDiscount();
|
|
$this->testBatterySalesTradeInDifferentBatteryOtherNoDiscount();
|
|
$this->testBatterySalesTradeInQuantityNoDiscount();
|
|
|
|
// battery sales with discount
|
|
|
|
// battery replacement warranty
|
|
$this->testBatteryReplacementWarranty();
|
|
|
|
// fuel
|
|
$this->testFuelGasWithServiceFee();
|
|
$this->testFuelDieselWithServiceFee();
|
|
$this->testFuelGasWithNoServiceFee();
|
|
$this->testFuelDieselWithNoServiceFee();
|
|
|
|
// jumpstart
|
|
$this->testJumpstart();
|
|
|
|
// jumpstart warranty
|
|
$this->testJumpstartWarranty();
|
|
|
|
// overheat
|
|
$this->testOverheatAssistanceWithCoolant();
|
|
$this->testOverheatAssistanceWithoutCoolant();
|
|
|
|
// post-recharged
|
|
$this->testPostRecharged();
|
|
|
|
// post replacement
|
|
$this->testPostReplacement();
|
|
|
|
// tire repair
|
|
$this->testTireRepairWithServiceFee();
|
|
$this->testTireRepairWithNoServiceFee();
|
|
|
|
// TEST SCENARIO: new battery with discount
|
|
// TEST SCENARIO: new battery with discount and trade-in
|
|
return 0;
|
|
}
|
|
|
|
protected function testBatterySalesNoTradeInNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, no trade-in, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesQuantityNoTradeInNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, more than 1, no trade-in, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
$criteria->addEntry($battery, null, 2);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInSameBatteryPremiumNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in same battery, premium, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($battery, 'premium', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInSameBatteryMotoliteNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in same battery, motolite, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($battery, 'motolite', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInSameBatteryOtherNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in same battery, other, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($battery, 'other', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInDifferentBatteryPremiumNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in different battery, premium, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
$trade_battery_id = 1037;
|
|
$trade_battery = $this->em->getRepository(Battery::class)->find($trade_battery_id);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($trade_battery, 'premium', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInDifferentBatteryMotoliteNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in different battery, premium, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
$trade_battery_id = 1037;
|
|
$trade_battery = $this->em->getRepository(Battery::class)->find($trade_battery_id);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($trade_battery, 'motolite', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInDifferentBatteryOtherNoDiscount()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: new battery, trade-in different battery, premium, no discount
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
// add battery
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
$trade_battery_id = 1037;
|
|
$trade_battery = $this->em->getRepository(Battery::class)->find($trade_battery_id);
|
|
|
|
// add battery for trade in
|
|
$criteria->addEntry($trade_battery, 'other', 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_NEW . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testBatterySalesTradeInQuantityNoDiscount()
|
|
{
|
|
}
|
|
|
|
protected function testBatteryReplacementWarranty()
|
|
{
|
|
// TEST SCENARIO: battery replacement warranty
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_WARRANTY);
|
|
|
|
$battery_id = 1038;
|
|
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
|
|
|
|
$criteria->addEntry($battery, null, 1);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::BATTERY_REPLACEMENT_WARRANTY . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testFuelGasWithServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: fuel, gas, service fee
|
|
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306614;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::EMERGENCY_REFUEL . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testFuelDieselWithServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: fuel, diesel, service fee
|
|
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306612;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::EMERGENCY_REFUEL . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testFuelGasWithNoServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: fuel, gas, no service fee
|
|
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306604;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::EMERGENCY_REFUEL . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testFuelDieselWithNoServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: fuel, diesel, no service fee
|
|
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306599;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::EMERGENCY_REFUEL . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testJumpstart()
|
|
{
|
|
// TEST SCENARIO: jumpstart
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
$criteria->setServiceType(ServiceType::JUMPSTART_TROUBLESHOOT);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::JUMPSTART_TROUBLESHOOT . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testJumpstartWarranty()
|
|
{
|
|
// TEST SCENARIO: jumpstart warranty
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
$criteria->setServiceType(ServiceType::JUMPSTART_WARRANTY);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::JUMPSTART_WARRANTY . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testOverheatAssistanceWithCoolant()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: overheat assistance with coolant
|
|
$criteria->setServiceType(ServiceType::OVERHEAT_ASSISTANCE);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306614;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
$criteria->setHasCoolant();
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::OVERHEAT_ASSISTANCE . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testOverheatAssistanceWithoutCoolant()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: overheat assistance with coolant
|
|
$criteria->setServiceType(ServiceType::OVERHEAT_ASSISTANCE);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306614;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::OVERHEAT_ASSISTANCE . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testPostRecharged()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: post recharged
|
|
$criteria->setServiceType(ServiceType::POST_RECHARGED);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::POST_RECHARGED . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testPostReplacement()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: post replacement
|
|
$criteria->setServiceType(ServiceType::POST_REPLACEMENT);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::POST_REPLACEMENT . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testTireRepairWithServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: tire repair with service fee
|
|
$criteria->setServiceType(ServiceType::TIRE_REPAIR);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306612;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::TIRE_REPAIR . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
protected function testTireRepairWithNoServiceFee()
|
|
{
|
|
$criteria = new InvoiceCriteria();
|
|
|
|
// TEST SCENARIO: tire repair no service fee
|
|
$criteria->setServiceType(ServiceType::TIRE_REPAIR);
|
|
|
|
// set customer vehicle
|
|
$cv_id = 1306604;
|
|
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
|
|
|
$criteria->setCustomerVehicle($cv);
|
|
|
|
$rules = $this->inv_manager->check($criteria);
|
|
|
|
// error_log(print_r($rules, true));
|
|
|
|
$invoice_items = $this->inv_manager->compute($criteria, $rules);
|
|
|
|
foreach ($invoice_items as $invoice_item)
|
|
{
|
|
error_log('TEST: ' . ServiceType::TIRE_REPAIR . ' ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
|
|
}
|
|
}
|
|
|
|
}
|