Modify the admin panel to use the new invoice engine when creating a new JO. #744

This commit is contained in:
Korina Cordero 2023-06-05 21:34:15 -04:00
parent 4ebbd8cfd3
commit e9f18ed184
4 changed files with 118 additions and 128 deletions

View file

@ -170,6 +170,9 @@ services:
# invoice generator interface # invoice generator interface
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator" App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
# invoice manager
App\Service\InvoiceManager: ~
# job order generator # job order generator
App\Service\JobOrderHandler\ResqJobOrderHandler: App\Service\JobOrderHandler\ResqJobOrderHandler:
arguments: arguments:

View file

@ -187,7 +187,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -222,7 +222,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY NO TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -257,7 +257,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -291,7 +291,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY NO TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -329,7 +329,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -367,7 +367,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -405,7 +405,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -446,7 +446,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -487,7 +487,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -528,7 +528,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -569,7 +569,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY TRADE IN NO DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -606,7 +606,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -642,7 +642,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -678,7 +678,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -717,7 +717,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -756,7 +756,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -795,7 +795,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) 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->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -834,7 +834,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' QUANTITY TRADE IN NO DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -877,7 +877,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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('PROMO ' . $promo->getName());
@ -920,7 +920,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' NO TRADE IN WITH DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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('PROMO ' . $promo->getName());
@ -968,7 +968,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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('PROMO ' . $promo->getName());
@ -1016,7 +1016,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN DIFFERENT BATTERY WITH DISCOUNT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1060,7 +1060,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN SAME BATTERY WITH DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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('PROMO ' . $promo->getName());
@ -1106,7 +1106,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_NEW) . ' TRADE IN DIFFERENT BATTERY WITH DISCOUNT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1141,7 +1141,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_WARRANTY) . ' WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1174,7 +1174,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::BATTERY_REPLACEMENT_WARRANTY) . ' WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1210,7 +1210,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1245,7 +1245,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1280,7 +1280,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH NO SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1315,7 +1315,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH NO SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1349,7 +1349,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1382,7 +1382,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1415,7 +1415,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' GAS WITH NO SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1448,7 +1448,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::EMERGENCY_REFUEL) . ' DIESEL WITH NO SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1478,7 +1478,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_TROUBLESHOOT) . ' WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1506,7 +1506,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_TROUBLESHOOT) . ' WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1536,7 +1536,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_WARRANTY) . ' WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1564,7 +1564,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::JUMPSTART_WARRANTY) . ' WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1600,7 +1600,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITH COOLANT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1634,7 +1634,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITHOUT COOLANT WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1669,7 +1669,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITH COOLANT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1702,7 +1702,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::OVERHEAT_ASSISTANCE) . ' WITHOUT COOLANT WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1732,7 +1732,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::POST_RECHARGED) . ' WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1760,7 +1760,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::POST_RECHARGED) . ' WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1790,7 +1790,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::POST_REPLACEMENT) . ' WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1820,7 +1820,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::POST_REPLACEMENT) . ' WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1856,7 +1856,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITH SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1891,7 +1891,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITHOUT SERVICE FEE WITH TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1925,7 +1925,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITH SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1958,7 +1958,7 @@ class TestInvoiceManagerCommand extends Command
foreach ($invoice_items as $invoice_item) foreach ($invoice_items as $invoice_item)
{ {
error_log('TEST: ' . strtoupper(ServiceType::TIRE_REPAIR) . ' WITHOUT SERVICE FEE WITHOUT TAX ' . $invoice_item->getTitle() . ' ' . $invoice_item->getQuantity() . ' ' . $invoice_item->getPrice()); 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)); error_log('TOTAL ' . print_r(json_encode($total), true));
@ -1997,27 +1997,9 @@ class TestInvoiceManagerCommand extends Command
// promo id // promo id
$promo_id = 10; $promo_id = 10;
$invoice = $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (empty($error_array)) if (!empty($error_array))
{
error_log('TEST GENERATEINVOICECRITERIA:');
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 CRITERIA: Errors found when generating invoice ' . print_r(json_encode($error_array), true)); error_log('TEST GENERATE INVOICE CRITERIA: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
} }
@ -2054,27 +2036,9 @@ class TestInvoiceManagerCommand extends Command
// promo id // promo id
$promo_id = 99; $promo_id = 99;
$invoice = $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (empty($error_array)) if (!empty($error_array))
{
error_log('TEST GENERATEINVOICECRITERIA:');
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 CRITERIA INVALID PROMO: Errors found when generating invoice ' . print_r(json_encode($error_array), true)); error_log('TEST GENERATE INVOICE CRITERIA INVALID PROMO: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
} }
@ -2111,27 +2075,9 @@ class TestInvoiceManagerCommand extends Command
// promo id // promo id
$promo_id = 1; $promo_id = 1;
$invoice = $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->inv_manager->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
if (empty($error_array)) if (!empty($error_array))
{
error_log('TEST GENERATEINVOICECRITERIA:');
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 CRITERIA INVALID BATTERY: Errors found when generating invoice ' . print_r(json_encode($error_array), true)); error_log('TEST GENERATE INVOICE CRITERIA INVALID BATTERY: Errors found when generating invoice ' . print_r(json_encode($error_array), true));
} }

View file

@ -96,6 +96,8 @@ class InvoiceManager
$ierror = $this->validatePromo($criteria, $promo_id); $ierror = $this->validatePromo($criteria, $promo_id);
error_log('generateInvoiceCriteria ' . count($invoice_items));
if (!$ierror && !empty($invoice_items)) if (!$ierror && !empty($invoice_items))
{ {
// validate the invoice items (batteries and trade ins) // validate the invoice items (batteries and trade ins)
@ -109,17 +111,30 @@ class InvoiceManager
else else
{ {
// generate the invoice // generate the invoice
// check which rules to apply $invoice = $this->generateInvoice($criteria);
$rules = $this->check($criteria);
$invoice_data = $this->compute($criteria, $rules); // validate
$ierrors = $this->validator->validate($invoice);
$invoice = $this->createInvoice($invoice_data); // add errors to list
foreach ($ierrors as $error) {
return $invoice; $error_array[$error->getPropertyPath()] = $error->getMessage();
} }
return null; // check if invoice already exists for JO
$old_invoice = $jo->getInvoice();
if ($old_invoice != null)
{
// remove old invoice
$this->em->remove($old_invoice);
$this->em->flush();
}
// add invoice to JO
$jo->setInvoice($invoice);
$this->em->persist($invoice);
}
} }
// this is called by JobOrderController when JS script generateInvoice is called // this is called by JobOrderController when JS script generateInvoice is called
@ -137,6 +152,7 @@ class InvoiceManager
} }
// this is called by JobOrderController when JS script generateInvoice is called // this is called by JobOrderController when JS script generateInvoice is called
// this is also called by generateInvoiceCriteria
public function generateInvoice($criteria) public function generateInvoice($criteria)
{ {
// no need to validate since generateDraftInvoice was called before this was called // no need to validate since generateDraftInvoice was called before this was called
@ -252,23 +268,33 @@ class InvoiceManager
} }
$promo = null; $promo = null;
error_log('mogol compute items ' . count($items));
foreach ($items as $item) foreach ($items as $item)
{ {
$invoice_item = new InvoiceItem(); $title = $item['title'];
$quantity = $item['qty'];
$invoice_item->setTitle($item['title']) $price = $item['price'];
->setQuantity($item['qty'])
->setPrice($item['price']);
$battery = null;
if (isset($item['battery'])) if (isset($item['battery']))
$invoice_item->setBattery($item['battery']); $battery = $item['battery'];
$promo = null;
if (isset($item['promo'])) if (isset($item['promo']))
$promo = $item['promo']; $promo = $item['promo'];
$invoice_items[] = $invoice_item; $invoice_items[] = [
'title' => $title,
'quantity' => $quantity,
'price' => $price,
'battery' => $battery,
'promo' => $promo,
];
} }
error_log('mogol compute invoice items ' . count($invoice_items));
// also need to return the total and the promo // also need to return the total and the promo
$data[] = [ $data[] = [
'promo' => $promo, 'promo' => $promo,
@ -367,8 +393,20 @@ class InvoiceManager
if (isset($data['promo'])) if (isset($data['promo']))
$promo = $data['promo']; $promo = $data['promo'];
foreach ($invoice_items as $invoice_item) error_log('mogol ' . count($invoice_items));
foreach ($invoice_items as $item)
{ {
$invoice_item = new InvoiceItem();
$invoice_item->setInvoice($invoice)
->setTitle($item['title'])
->setQuantity($item['quantity'])
->setPrice($item['price']);
if ($item['battery'] != null)
$invoice_item->setBattery($item['battery']);
$invoice->addItem($invoice_item); $invoice->addItem($invoice_item);
} }
@ -378,6 +416,8 @@ class InvoiceManager
->setDiscount($total['discount']) ->setDiscount($total['discount'])
->setTradeIn($total['ti_rate']) ->setTradeIn($total['ti_rate'])
->setStatus(InvoiceStatus::DRAFT); ->setStatus(InvoiceStatus::DRAFT);
error_log('mogol total ' . $invoice->getTotalPrice());
} }
return $invoice; return $invoice;

View file

@ -30,7 +30,6 @@ use App\Entity\EmergencyType;
use App\Entity\OwnershipType; use App\Entity\OwnershipType;
use App\Entity\CustomerLocation; use App\Entity\CustomerLocation;
use App\Ramcar\InvoiceCriteria;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Ramcar\TradeInType; use App\Ramcar\TradeInType;
use App\Ramcar\JOEventType; use App\Ramcar\JOEventType;
@ -53,7 +52,6 @@ use App\Ramcar\CustomerClassification;
use App\Ramcar\Gender; use App\Ramcar\Gender;
use App\Ramcar\CallerClassification; use App\Ramcar\CallerClassification;
use App\Service\InvoiceGeneratorInterface;
use App\Service\JobOrderHandlerInterface; use App\Service\JobOrderHandlerInterface;
use App\Service\RiderAssignmentHandlerInterface; use App\Service\RiderAssignmentHandlerInterface;
use App\Service\WarrantyHandler; use App\Service\WarrantyHandler;
@ -66,6 +64,9 @@ use App\Service\HubSelector;
use App\Service\HubDistributor; use App\Service\HubDistributor;
use App\Service\HubFilteringGeoChecker; use App\Service\HubFilteringGeoChecker;
use App\Service\InvoiceManager;
use App\InvoiceCriteria;
use CrEOF\Spatial\PHP\Types\Geometry\Point; use CrEOF\Spatial\PHP\Types\Geometry\Point;
use Mosquitto\Client as MosquittoClient; use Mosquitto\Client as MosquittoClient;
@ -95,7 +96,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
protected $template_hash; protected $template_hash;
public function __construct(Security $security, EntityManagerInterface $em, public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator, InvoiceManager $ic, ValidatorInterface $validator,
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah, TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt, string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence, PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence,