Typecast the invoice fields to float. Fix the namespace for APIResponse for TAPI controllers. #752

This commit is contained in:
Korina Cordero 2023-07-20 02:19:13 +00:00
parent 9b75993d3d
commit fc33668a46
6 changed files with 13 additions and 11 deletions

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManagerInterface;
use Catalyst\ApiBundle\Controller\ApiController;
use Catalyst\ApiBundle\Response\APIResponse;
use Catalyst\ApiBundle\Component\Response as APIResponse;
use App\Ramcar\APIResult;
use App\Entity\Vehicle;

View file

@ -12,7 +12,7 @@ use Doctrine\ORM\EntityManagerInterface;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use Catalyst\ApiBundle\Controller\ApiController;
use Catalyst\ApiBundle\Response\APIResponse;
use Catalyst\ApiBundle\Component\Response as APIResponse;
use App\Ramcar\WarrantyClass;
use App\Ramcar\JOStatus;

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManagerInterface;
use Catalyst\ApiBundle\Controller\ApiController;
use Catalyst\ApiBundle\Response\APIResponse;
use Catalyst\ApiBundle\Component\Response as APIResponse;
use App\Entity\Promo;

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManagerInterface;
use Catalyst\ApiBundle\Controller\ApiController;
use Catalyst\ApiBundle\Response\APIResponse;
use Catalyst\ApiBundle\Component\Response as APIResponse;
use App\Entity\Service;

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManagerInterface;
use Catalyst\ApiBundle\Controller\ApiController;
use Catalyst\ApiBundle\Response\APIResponse;
use Catalyst\ApiBundle\Component\Response as APIResponse;
use App\Entity\VehicleManufacturer;
use App\Entity\Vehicle;

View file

@ -263,7 +263,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
$invoice_item->setInvoice($invoice)
->setTitle($item['title'])
->setQuantity($item['quantity'])
->setPrice($item['price']);
->setPrice((float)$item['price']);
if ($item['battery'] != null)
$invoice_item->setBattery($item['battery']);
@ -271,11 +271,13 @@ class InvoiceManager implements InvoiceGeneratorInterface
$invoice->addItem($invoice_item);
}
$invoice->setTotalPrice($total['total_price'])
->setVATExclusivePrice($total['vat_ex_price'])
->setVAT($total['vat'])
->setDiscount($total['discount'])
->setTradeIn($total['ti_rate'])
// RULE: TYPECAST these values since bc operations return a string
// and these fields are going to be placed in a JSON response
$invoice->setTotalPrice((float)$total['total_price'])
->setVATExclusivePrice((float)$total['vat_ex_price'])
->setVAT((float)$total['vat'])
->setDiscount((float)$total['discount'])
->setTradeIn((float)$total['ti_rate'])
->setStatus(InvoiceStatus::DRAFT);
}