From da419dd257b137f5e902674e6683ec94e08df230 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 21 Jul 2023 06:25:48 +0000 Subject: [PATCH 1/2] Fix setting of invoice criteria for vat computations and battery entries. #753 --- src/Controller/APIController.php | 18 ++++++++++++++++-- .../CustomerAppAPI/InvoiceController.php | 6 +++++- .../RiderAPIHandler/ResqRiderAPIHandler.php | 7 ++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index b2aabd5b..444aa90a 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -1026,7 +1026,14 @@ class APIController extends Controller implements LoggedController break; } - $icrit->addEntry($batt, $trade_in, 1); + // right now, the app does not include trade-ins but this might change in the future + if (empty($trade_in)) + $icrit->addEntry($batt, null, 1); + else + $icrit->addEntry($batt, $trade_in, 1); + + // set if taxable + $icrit->setIsTaxable(); // send to invoice generator $invoice = $ic->generateInvoice($icrit); @@ -1307,6 +1314,9 @@ class APIController extends Controller implements LoggedController $icrit->addBattery($batt); */ + // set taxable + $icrit->setIsTaxable(true); + // check trade-in // only allow motolite, other, none $trade_in = $req->request->get('trade_in'); @@ -1321,7 +1331,11 @@ class APIController extends Controller implements LoggedController break; } - $icrit->addEntry($batt, $trade_in, 1); + // right now, the app does not include trade-ins but this might change in the future + if (empty($trade_in)) + $icrit->addEntry($batt, null, 1); + else + $icrit->addEntry($batt, $trade_in, 1); // send to invoice generator $invoice = $ic->generateInvoice($icrit); diff --git a/src/Controller/CustomerAppAPI/InvoiceController.php b/src/Controller/CustomerAppAPI/InvoiceController.php index ef0cf6b2..a89f0950 100644 --- a/src/Controller/CustomerAppAPI/InvoiceController.php +++ b/src/Controller/CustomerAppAPI/InvoiceController.php @@ -92,7 +92,11 @@ class InvoiceController extends ApiController break; } - $icrit->addEntry($batt, $trade_in, 1); + // right now, the app does not include trade-ins but this might change in the future + if (empty($trade_in)) + $icrit->addEntry($batt, null, 1); + else + $icrit->addEntry($batt, $trade_in, 1); // set if taxable $icrit->setIsTaxable(); diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index f992f6e5..66d91060 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -874,7 +874,12 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface if ($battery != null) { - $crit->addEntry($battery, $trade_in, 1); + // right now, the app does not include trade-ins but this might change in the future + if ($trade_in == null) + $icrit->addEntry($batt, null, 1); + else + $icrit->addEntry($batt, $trade_in, 1); + // error_log('adding entry for battery - ' . $battery->getID()); } From 7b167387094d11104ea7bf2e9cd34f0d9e10bcfe Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 21 Jul 2023 06:28:40 +0000 Subject: [PATCH 2/2] Fix typo. #753 --- src/Service/RiderAPIHandler/ResqRiderAPIHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index 66d91060..311d43fd 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -876,9 +876,9 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface { // right now, the app does not include trade-ins but this might change in the future if ($trade_in == null) - $icrit->addEntry($batt, null, 1); + $crit->addEntry($battery, null, 1); else - $icrit->addEntry($batt, $trade_in, 1); + $crit->addEntry($battery, $trade_in, 1); // error_log('adding entry for battery - ' . $battery->getID()); }