Move setting of invoice status and createdby inside the invoice generator. #265
This commit is contained in:
parent
89ec286a9f
commit
cf8c3bb8e1
3 changed files with 17 additions and 10 deletions
|
|
@ -8,7 +8,6 @@ use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\DiscountApply;
|
use App\Ramcar\DiscountApply;
|
||||||
use App\Ramcar\TradeInType;
|
use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
use App\Ramcar\InvoiceStatus;
|
|
||||||
use App\Ramcar\ModeOfPayment;
|
use App\Ramcar\ModeOfPayment;
|
||||||
use App\Ramcar\TransactionOrigin;
|
use App\Ramcar\TransactionOrigin;
|
||||||
use App\Ramcar\JOEventType;
|
use App\Ramcar\JOEventType;
|
||||||
|
|
@ -328,8 +327,6 @@ class JobOrderController extends Controller
|
||||||
{
|
{
|
||||||
// generate the invoice
|
// generate the invoice
|
||||||
$iobj = $ic->generateInvoice($criteria);
|
$iobj = $ic->generateInvoice($criteria);
|
||||||
$iobj->setStatus(InvoiceStatus::DRAFT)
|
|
||||||
->setCreatedBy($this->getUser());
|
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$ierrors = $validator->validate($iobj);
|
$ierrors = $validator->validate($iobj);
|
||||||
|
|
@ -523,8 +520,6 @@ class JobOrderController extends Controller
|
||||||
{
|
{
|
||||||
// generate the invoice
|
// generate the invoice
|
||||||
$iobj = $ic->generateInvoice($criteria);
|
$iobj = $ic->generateInvoice($criteria);
|
||||||
$iobj->setStatus(InvoiceStatus::DRAFT)
|
|
||||||
->setCreatedBy($this->getUser());
|
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$ierrors = $validator->validate($iobj);
|
$ierrors = $validator->validate($iobj);
|
||||||
|
|
|
||||||
|
|
@ -840,7 +840,6 @@ class RAPIController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $ic->generateInvoice($crit);
|
$invoice = $ic->generateInvoice($crit);
|
||||||
$invoice->setStatus(InvoiceStatus::DRAFT);
|
|
||||||
|
|
||||||
// remove previous invoice
|
// remove previous invoice
|
||||||
$old_invoice = $jo->getInvoice();
|
$old_invoice = $jo->getInvoice();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
namespace App\Service\InvoiceGenerator;
|
namespace App\Service\InvoiceGenerator;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
|
use App\Ramcar\InvoiceStatus;
|
||||||
use App\Ramcar\TradeInType;
|
use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\DiscountApply;
|
use App\Ramcar\DiscountApply;
|
||||||
use App\Ramcar\ServiceType;
|
use App\Ramcar\ServiceType;
|
||||||
|
|
@ -29,9 +32,12 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
const REFUEL_FEE_GAS = 260;
|
const REFUEL_FEE_GAS = 260;
|
||||||
const REFUEL_FEE_DIESEL = 220;
|
const REFUEL_FEE_DIESEL = 220;
|
||||||
|
|
||||||
|
private $security;
|
||||||
|
|
||||||
// creates invoice based on the criteria sent
|
// creates invoice based on the criteria sent
|
||||||
public function __construct()
|
public function __construct(Security $security)
|
||||||
{
|
{
|
||||||
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateInvoice(InvoiceCriteria $criteria)
|
public function generateInvoice(InvoiceCriteria $criteria)
|
||||||
|
|
@ -95,12 +101,19 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
// apply discounts
|
// apply discounts
|
||||||
$promos = $criteria->getPromos();
|
$promos = $criteria->getPromos();
|
||||||
|
|
||||||
|
// get current user
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
if ($user != null)
|
||||||
|
{
|
||||||
|
$invoice->setCreatedBy($user);
|
||||||
|
}
|
||||||
|
|
||||||
$invoice->setTotalPrice($total['total_price'])
|
$invoice->setTotalPrice($total['total_price'])
|
||||||
->setVATExclusivePrice($total['vat_ex_price'])
|
->setVATExclusivePrice($total['vat_ex_price'])
|
||||||
->setVAT($total['vat'])
|
->setVAT($total['vat'])
|
||||||
->setDiscount($total['discount'])
|
->setDiscount($total['discount'])
|
||||||
->setTradeIn($total['ti_rate']);
|
->setTradeIn($total['ti_rate'])
|
||||||
|
->setStatus(InvoiceStatus::DRAFT);
|
||||||
|
|
||||||
// dump
|
// dump
|
||||||
//Debug::dump($invoice, 1);
|
//Debug::dump($invoice, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue