resq/src/Command/TestInvoiceManagerCommand.php

2299 lines
77 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;
use App\Entity\Promo;
use App\Entity\JobOrder;
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 with tax
$this->testBatterySalesNoTradeInNoDiscountWithTax();
$this->testBatterySalesQuantityNoTradeInNoDiscountWithTax();
// battery sales without tax
$this->testBatterySalesNoTradeInNoDiscountWithoutTax();
$this->testBatterySalesQuantityNoTradeInNoDiscountWithoutTax();
// battery sales with trade in with tax
$this->testBatterySalesTradeInSameBatteryPremiumNoDiscountWithTax();
$this->testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithTax();
$this->testBatterySalesTradeInSameBatteryOtherNoDiscountWithTax();
$this->testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithTax();
$this->testBatterySalesTradeInDifferentBatteryMotoliteNoDiscountWithTax();
$this->testBatterySalesTradeInDifferentBatteryOtherNoDiscountWithTax();
$this->testBatterySalesTradeInQuantityNoDiscountWithTax();
// battery sales with trade in without tax
$this->testBatterySalesTradeInSameBatteryPremiumNoDiscountWithoutTax();
$this->testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithoutTax();
$this->testBatterySalesTradeInSameBatteryOtherNoDiscountWithoutTax();
$this->testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithoutTax();
$this->testBatterySalesTradeInDifferentBatteryMotoliteNoDiscountWithoutTax();
$this->testBatterySalesTradeInDifferentBatteryOtherNoDiscountWithoutTax();
$this->testBatterySalesTradeInQuantityNoDiscountWithoutTax();
// battery sales with discount with tax
$this->testBatterySalesNoTradeInWithDiscountWithTax();
// battery sales with discount without tax
$this->testBatterySalesNoTradeInWithDiscountWithoutTax();
// battery sales with discount and trade in with tax
$this->testBatterySalesTradeInSameBatteryWithDiscountWithTax();
$this->testBatterySalesTradeInDifferentBatteryWithDiscountWithTax();
// battery sales with discount and trade in without tax
$this->testBatterySalesTradeInSameBatteryWithDiscountWithoutTax();
$this->testBatterySalesTradeInDifferentBatteryWithDiscountWithoutTax();
// battery replacement warranty with tax
$this->testBatteryReplacementWarrantyWithTax();
// battery replacement warranty without tax
$this->testBatteryReplacementWarrantyWithoutTax();
// fuel with tax
$this->testFuelGasWithServiceFeeWithTax();
$this->testFuelDieselWithServiceFeeWithTax();
$this->testFuelGasWithNoServiceFeeWithTax();
$this->testFuelDieselWithNoServiceFeeWithTax();
// fuel without tax
$this->testFuelGasWithServiceFeeWithoutTax();
$this->testFuelDieselWithServiceFeeWithoutTax();
$this->testFuelGasWithNoServiceFeeWithoutTax();
$this->testFuelDieselWithNoServiceFeeWithoutTax();
// jumpstart with tax
$this->testJumpstartWithTax();
// jumpstart without tax
$this->testJumpstartWithoutTax();
// jumpstart warranty with tax
$this->testJumpstartWarrantyWithTax();
// jumpstart warranty without tax
$this->testJumpstartWarrantyWithoutTax();
// overheat with tax
$this->testOverheatAssistanceWithCoolantWithTax();
$this->testOverheatAssistanceWithoutCoolantWithTax();
// overheat without tax
$this->testOverheatAssistanceWithCoolantWithoutTax();
$this->testOverheatAssistanceWithoutCoolantWithoutTax();
// post-recharged with tax
$this->testPostRechargedWithTax();
// post-recharged without tax
$this->testPostRechargedWithoutTax();
// post replacement with tax
$this->testPostReplacementWithTax();
// post replacement without tax
$this->testPostReplacementWithoutTax();
// tire repair with tax
$this->testTireRepairWithServiceFeeWithTax();
$this->testTireRepairWithoutServiceFeeWithTax();
// tire repair without tax
$this->testTireRepairWithServiceFeeWithoutTax();
$this->testTireRepairWithoutServiceFeeWithoutTax();
// test creation of invoice criteria when JO is submitted
$this->testGenerateInvoiceCriteria();
$this->testGenerateInvoiceCriteriaInvalidPromo();
$this->testGenerateInvoiceCriteriaInvalidBattery();
// test generateDraftInvoice call from ajax call
$this->testGenerateDraftInvoiceNoErrorWithTradeIn();
$this->testGenerateDraftInvoiceNoErrorNoTradeIn();
$this->testGenerateDraftInvoiceInvalidBattery();
$this->testGenerateDraftInvoiceInvalidPromo();
$this->testGenerateDraftInvoiceNonBatterySales();
$this->testGenerateDraftInvoiceBatterySalesNoPromo();
// test generateInvoiceInvoice call from ajax call
$this->testGenerateInvoice();
return 0;
}
// 1battery sales with tax
protected function testBatterySalesNoTradeInNoDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, no discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$criteria->addEntry($battery, null, 1);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesQuantityNoTradeInNoDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, more than 1, no trade-in, no discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$criteria->addEntry($battery, null, 2);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY NO TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales without tax
protected function testBatterySalesNoTradeInNoDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, no discount, no tax
$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_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesQuantityNoTradeInNoDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, more than 1, no trade-in, no discount, without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY NO TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales with trade in with tax
protected function testBatterySalesTradeInSameBatteryPremiumNoDiscountWithTax()
{
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' PREMIUM TRADE IN SAME BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithTax()
{
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' MOTOLITE TRADE IN SAME BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInSameBatteryOtherNoDiscountWithTax()
{
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' OTHER TRADE IN SAME BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithTax()
{
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' PREMIUM TRADE IN DIFFERENT BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryMotoliteNoDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different 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);
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' MOTOLITE TRADE IN DIFFERENT BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryOtherNoDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different 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);
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' OTHER TRADE IN DIFFERENT BATTERY NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInQuantityNoDiscountWithTax()
{
$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', 3);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// start: battery sales with trade in without tax
protected function testBatterySalesTradeInSameBatteryPremiumNoDiscountWithoutTax()
{
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' PREMIUM TRADE IN SAME BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInSameBatteryMotoliteNoDiscountWithoutTax()
{
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' MOTOLITE TRADE IN SAME BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInSameBatteryOtherNoDiscountWithoutTax()
{
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' OTHER TRADE IN SAME BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryPremiumNoDiscountWithoutTax()
{
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' PREMIUM TRADE IN DIFFERENT BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryMotoliteNoDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different 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);
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' MOTOLITE TRADE IN DIFFERENT BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryOtherNoDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different 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);
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' OTHER TRADE IN DIFFERENT BATTERY NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInQuantityNoDiscountWithoutTax()
{
$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', 3);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales with discount with tax
protected function testBatterySalesNoTradeInWithDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, with discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_id);
$criteria->addEntry($battery, null, 1);
$criteria->addPromo($promo);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
$promo = $data['promo'];
foreach ($invoice_items as $invoice_item)
{
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('PROMO ' . $promo->getName());
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales with discount without tax
protected function testBatterySalesNoTradeInWithDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, with discount, without tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 10;
$promo = $this->em->getRepository(Promo::class)->find($promo_id);
$criteria->addEntry($battery, null, 1);
$criteria->addPromo($promo);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
$promo = $data['promo'];
foreach ($invoice_items as $invoice_item)
{
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('PROMO ' . $promo->getName());
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales with discount and trade in with tax
protected function testBatterySalesTradeInSameBatteryWithDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, with discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_id);
$criteria->addEntry($battery, null, 1);
// add battery for trade in
$criteria->addEntry($battery, 'premium', 1);
$criteria->addPromo($promo);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
$promo = $data['promo'];
foreach ($invoice_items as $invoice_item)
{
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('PROMO ' . $promo->getName());
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryWithDiscountWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different battery, premium, with discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_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);
$criteria->addPromo($promo);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN DIFFERENT BATTERY WITH DISCOUNT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery sales with discount and trade in without tax
protected function testBatterySalesTradeInSameBatteryWithDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, no trade-in, with discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_id);
$criteria->addEntry($battery, null, 1);
// add battery for trade in
$criteria->addEntry($battery, 'premium', 1);
$criteria->addPromo($promo);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
// error_log(print_r(json_encode($invoice_data), true));
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
$promo = $data['promo'];
foreach ($invoice_items as $invoice_item)
{
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('PROMO ' . $promo->getName());
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testBatterySalesTradeInDifferentBatteryWithDiscountWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different battery, premium, with discount, without tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_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);
$criteria->addPromo($promo);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN DIFFERENT BATTERY WITH DISCOUNT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery replacement warranty with tax
protected function testBatteryReplacementWarrantyWithTax()
{
// TEST SCENARIO: battery replacement warranty with tax
$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);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_WARRANTY) . ' WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// battery replacement warranty without tax
protected function testBatteryReplacementWarrantyWithoutTax()
{
// TEST SCENARIO: battery replacement warranty without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_WARRANTY) . ' WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// fuel with tax
protected function testFuelGasWithServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, gas, service fee, with tax
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
// set customer vehicle
$cv_id = 1306614;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelDieselWithServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, diesel, service fee, with tax
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
// set customer vehicle
$cv_id = 1306612;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelGasWithNoServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, gas, no service fee, with tax
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
// set customer vehicle
$cv_id = 1306604;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH NO SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelDieselWithNoServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, diesel, no service fee, with tax
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
// set customer vehicle
$cv_id = 1306581;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH NO SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// fuel without tax
protected function testFuelGasWithServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, gas, service fee, without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelDieselWithServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, diesel, service fee, without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelGasWithNoServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, gas, no service fee, without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH NO SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testFuelDieselWithNoServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: fuel, diesel, no service fee, without tax
$criteria->setServiceType(ServiceType::EMERGENCY_REFUEL);
// set customer vehicle
$cv_id = 1306581;
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH NO SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// jumpstart with tax
protected function testJumpstartWithTax()
{
// TEST SCENARIO: jumpstart with tax
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::JUMPSTART_TROUBLESHOOT);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_TROUBLESHOOT) . ' WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// jumpstart without tax
protected function testJumpstartWithoutTax()
{
// TEST SCENARIO: jumpstart without tax
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::JUMPSTART_TROUBLESHOOT);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_TROUBLESHOOT) . ' WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// jumpstart warranty with tax
protected function testJumpstartWarrantyWithTax()
{
// TEST SCENARIO: jumpstart warranty with tax
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::JUMPSTART_WARRANTY);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_WARRANTY) . ' WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// jumpstart warranty without tax
protected function testJumpstartWarrantyWithoutTax()
{
// TEST SCENARIO: jumpstart warranty without tax
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::JUMPSTART_WARRANTY);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_WARRANTY) . ' WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// overheat assistance with tax
protected function testOverheatAssistanceWithCoolantWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: overheat assistance with coolant with tax
$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();
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITH COOLANT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testOverheatAssistanceWithoutCoolantWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: overheat assistance without coolant with tax
$criteria->setServiceType(ServiceType::OVERHEAT_ASSISTANCE);
// set customer vehicle
$cv_id = 1306614;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITHOUT COOLANT WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// overheat assistance without tax
protected function testOverheatAssistanceWithCoolantWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: overheat assistance with coolant without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITH COOLANT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testOverheatAssistanceWithoutCoolantWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: overheat assistance without coolant without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITHOUT COOLANT WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// post recharged with tax
protected function testPostRechargedWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: post recharged with tax
$criteria->setServiceType(ServiceType::POST_RECHARGED);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::POST_RECHARGED) . ' WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// post recharged without tax
protected function testPostRechargedWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: post recharged with tax
$criteria->setServiceType(ServiceType::POST_RECHARGED);
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::POST_RECHARGED) . ' WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// post replacement with tax
protected function testPostReplacementWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: post replacement with tax
$criteria->setServiceType(ServiceType::POST_REPLACEMENT);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::POST_REPLACEMENT) . ' WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// post replacement without tax
protected function testPostReplacementWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: post replacement without tax
$criteria->setServiceType(ServiceType::POST_REPLACEMENT);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::POST_REPLACEMENT) . ' WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// tire repair with tax
protected function testTireRepairWithServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: tire repair with service fee with tax
$criteria->setServiceType(ServiceType::TIRE_REPAIR);
// set customer vehicle
$cv_id = 1306612;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITH SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testTireRepairWithoutServiceFeeWithTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: tire repair no service fee with tax
$criteria->setServiceType(ServiceType::TIRE_REPAIR);
// set customer vehicle
$cv_id = 1306604;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$criteria->setCustomerVehicle($cv);
$criteria->setIsTaxable();
$rules = $this->inv_manager->check($criteria);
// error_log(print_r($rules, true));
$invoice_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITHOUT SERVICE FEE WITH TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// tire repair without tax
protected function testTireRepairWithServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: tire repair with service fee without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITH SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
protected function testTireRepairWithoutServiceFeeWithoutTax()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: tire repair no service fee without tax
$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_data = $this->inv_manager->compute($criteria, $rules);
foreach ($invoice_data as $data)
{
$invoice_items = $data['invoice_items'];
$total = $data['total'];
foreach ($invoice_items as $invoice_item)
{
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITHOUT SERVICE FEE WITHOUT TAX ' . $invoice_item['title'] . ' ' . $invoice_item['quantity'] . ' ' . $invoice_item['price']);
}
error_log('TOTAL ' . print_r(json_encode($total), true));
}
}
// test creation of invoice criteria when JO is submitted
protected function testGenerateInvoiceCriteria()
{
// create JO, set service type and customer vehicle
$jo = new JobOrder();
$jo->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
// set customer vehicle
$cv_id = 1306604;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$jo->setCustomerVehicle($cv);
// create error_array
$error_array = [];
// create array of invoice items
$invoice_items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
], [
'battery' => 1038,
'quantity' => 1,
'trade_in' => 'premium'
]];
// error_log(print_r(json_encode($invoice_items), true));
// promo id
$promo_id = 10;
$this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (!empty($error_array))
{
error_log('TEST GENERATE INVOICE CRITERIA: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
}
}
protected function testGenerateInvoiceCriteriaInvalidPromo()
{
// create JO, set service type and customer vehicle
$jo = new JobOrder();
$jo->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
// set customer vehicle
$cv_id = 1306604;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$jo->setCustomerVehicle($cv);
// create error_array
$error_array = [];
// create array of invoice items
$invoice_items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
], [
'battery' => 1038,
'quantity' => 1,
'trade_in' => 'premium'
]];
// error_log(print_r(json_encode($invoice_items), true));
// promo id
$promo_id = 99;
$this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (!empty($error_array))
{
error_log('TEST GENERATE INVOICE CRITERIA INVALID PROMO: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
}
}
protected function testGenerateInvoiceCriteriaInvalidBattery()
{
// create JO, set service type and customer vehicle
$jo = new JobOrder();
$jo->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
// set customer vehicle
$cv_id = 1306604;
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
$jo->setCustomerVehicle($cv);
// create error_array
$error_array = [];
// create array of invoice items
$invoice_items = [[
'battery' => 1,
'quantity' => 1,
'trade_in' => '',
], [
'battery' => 1038,
'quantity' => 1,
'trade_in' => 'premium'
]];
// error_log(print_r(json_encode($invoice_items), true));
// promo id
$promo_id = 1;
$this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (!empty($error_array))
{
error_log('TEST GENERATE INVOICE CRITERIA INVALID BATTERY: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
}
}
// test generateDraftInvoice call from ajax call
protected function testGenerateDraftInvoiceNoErrorWithTradeIn()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$criteria->setIsTaxable();
$promo_id = 1;
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
], [
'battery' => 1038,
'quantity' => 1,
'trade_in' => 'premium'
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT INVOICE NO ERROR WITH TRADE IN: Errors found when generating draft invoice ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT INVOICE NO ERROR WITH TRADE IN: No errors here');
}
protected function testGenerateDraftInvoiceNoErrorNoTradeIn()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$criteria->setIsTaxable();
$promo_id = 1;
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT INVOICE NO ERROR NO TRADE IN: Errors found when generating draft invoice ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT INVOICE NO ERROR NO TRADE IN: No errors here');
}
protected function testGenerateDraftInvoiceInvalidBattery()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$criteria->setIsTaxable();
$promo_id = 1;
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
], [
'battery' => 2,
'quantity' => 1,
'trade_in' => 'premium'
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT INVOICE BATTERY ERROR: Errors found when generating draft invoice: ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT INVOICE BATTERY ERROR: No errors here');
}
protected function testGenerateDraftInvoiceInvalidPromo()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$criteria->setIsTaxable();
$promo_id = 99;
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT INVOICE PROMO ERROR: Errors found when generating draft invoice ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT INVOICE PROMO ERROR: No errors here');
}
protected function testGenerateDraftInvoiceNonBatterySales()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::JUMPSTART_TROUBLESHOOT);
$criteria->setIsTaxable();
$promo_id = 1;
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT NON BATTERY SALES: Errors found when generating draft invoice ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT NON BATTERY SALES: No errors here');
}
protected function testGenerateDraftInvoiceBatterySalesNoPromo()
{
$criteria = new InvoiceCriteria();
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$criteria->setIsTaxable();
$promo_id = '';
$service_charges = [];
// create array of invoice items
$items = [[
'battery' => 1038,
'quantity' => 1,
'trade_in' => '',
]];
$error = $this->inv_manager->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
if ($error)
error_log('TEST GENERATE DRAFT INVOICE BATTERY SALES NO PROMO: Errors found when generating draft invoice ' . print_r($error, true));
else
error_log('TEST GENERATE DRAFT INVOICE BATTERY SALES NO PROMO: No errors here');
}
// test generateInvoiceInvoice call from ajax call
protected function testGenerateInvoice()
{
$criteria = new InvoiceCriteria();
// TEST SCENARIO: new battery, trade-in different battery, premium, with discount, with tax
$criteria->setServiceType(ServiceType::BATTERY_REPLACEMENT_NEW);
$battery_id = 1038;
$battery = $this->em->getRepository(Battery::class)->find($battery_id);
$promo_id = 1;
$promo = $this->em->getRepository(Promo::class)->find($promo_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);
$criteria->addPromo($promo);
$criteria->setIsTaxable();
$invoice = $this->inv_manager->generateInvoice($criteria);
if ($invoice != null)
{
error_log('TEST GENERATEINVOICE:');
error_log('INVOICE');
error_log('TOTAL PRICE: ' . $invoice->getTotalPrice());
error_log('VAT EXCLUSIVE PRICE: ' . $invoice->getVATExclusivePrice());
error_log('VAT: ' . $invoice->getVAT());
error_log('DISCOUNT: ' . $invoice->getDiscount());
error_log('TRADE-IN: ' . $invoice->getTradeIn());
error_log('STATUS: ' . $invoice->getStatus());
$invoice_items = $invoice->getItems();
foreach ($invoice_items as $invoice_item)
{
error_log($invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice());
}
}
else
{
error_log('TEST GENERATE INVOICE: Error found. ');
}
}
}