Typecast the invoice fields to float. Fix the namespace for APIResponse for TAPI controllers. #752
This commit is contained in:
parent
9b75993d3d
commit
fc33668a46
6 changed files with 13 additions and 11 deletions
|
|
@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use Catalyst\ApiBundle\Controller\ApiController;
|
use Catalyst\ApiBundle\Controller\ApiController;
|
||||||
use Catalyst\ApiBundle\Response\APIResponse;
|
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||||
use App\Ramcar\APIResult;
|
use App\Ramcar\APIResult;
|
||||||
|
|
||||||
use App\Entity\Vehicle;
|
use App\Entity\Vehicle;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
|
|
||||||
use Catalyst\ApiBundle\Controller\ApiController;
|
use Catalyst\ApiBundle\Controller\ApiController;
|
||||||
use Catalyst\ApiBundle\Response\APIResponse;
|
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||||
|
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use Catalyst\ApiBundle\Controller\ApiController;
|
use Catalyst\ApiBundle\Controller\ApiController;
|
||||||
use Catalyst\ApiBundle\Response\APIResponse;
|
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||||
|
|
||||||
use App\Entity\Promo;
|
use App\Entity\Promo;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use Catalyst\ApiBundle\Controller\ApiController;
|
use Catalyst\ApiBundle\Controller\ApiController;
|
||||||
use Catalyst\ApiBundle\Response\APIResponse;
|
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||||
|
|
||||||
use App\Entity\Service;
|
use App\Entity\Service;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use Catalyst\ApiBundle\Controller\ApiController;
|
use Catalyst\ApiBundle\Controller\ApiController;
|
||||||
use Catalyst\ApiBundle\Response\APIResponse;
|
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||||
|
|
||||||
use App\Entity\VehicleManufacturer;
|
use App\Entity\VehicleManufacturer;
|
||||||
use App\Entity\Vehicle;
|
use App\Entity\Vehicle;
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
$invoice_item->setInvoice($invoice)
|
$invoice_item->setInvoice($invoice)
|
||||||
->setTitle($item['title'])
|
->setTitle($item['title'])
|
||||||
->setQuantity($item['quantity'])
|
->setQuantity($item['quantity'])
|
||||||
->setPrice($item['price']);
|
->setPrice((float)$item['price']);
|
||||||
|
|
||||||
if ($item['battery'] != null)
|
if ($item['battery'] != null)
|
||||||
$invoice_item->setBattery($item['battery']);
|
$invoice_item->setBattery($item['battery']);
|
||||||
|
|
@ -271,11 +271,13 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
$invoice->addItem($invoice_item);
|
$invoice->addItem($invoice_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->setTotalPrice($total['total_price'])
|
// RULE: TYPECAST these values since bc operations return a string
|
||||||
->setVATExclusivePrice($total['vat_ex_price'])
|
// and these fields are going to be placed in a JSON response
|
||||||
->setVAT($total['vat'])
|
$invoice->setTotalPrice((float)$total['total_price'])
|
||||||
->setDiscount($total['discount'])
|
->setVATExclusivePrice((float)$total['vat_ex_price'])
|
||||||
->setTradeIn($total['ti_rate'])
|
->setVAT((float)$total['vat'])
|
||||||
|
->setDiscount((float)$total['discount'])
|
||||||
|
->setTradeIn((float)$total['ti_rate'])
|
||||||
->setStatus(InvoiceStatus::DRAFT);
|
->setStatus(InvoiceStatus::DRAFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue