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\TradeInType;
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\InvoiceStatus;
|
||||
use App\Ramcar\ModeOfPayment;
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
use App\Ramcar\JOEventType;
|
||||
|
|
@ -328,8 +327,6 @@ class JobOrderController extends Controller
|
|||
{
|
||||
// generate the invoice
|
||||
$iobj = $ic->generateInvoice($criteria);
|
||||
$iobj->setStatus(InvoiceStatus::DRAFT)
|
||||
->setCreatedBy($this->getUser());
|
||||
|
||||
// validate
|
||||
$ierrors = $validator->validate($iobj);
|
||||
|
|
@ -523,8 +520,6 @@ class JobOrderController extends Controller
|
|||
{
|
||||
// generate the invoice
|
||||
$iobj = $ic->generateInvoice($criteria);
|
||||
$iobj->setStatus(InvoiceStatus::DRAFT)
|
||||
->setCreatedBy($this->getUser());
|
||||
|
||||
// validate
|
||||
$ierrors = $validator->validate($iobj);
|
||||
|
|
|
|||
|
|
@ -840,7 +840,6 @@ class RAPIController extends Controller
|
|||
}
|
||||
|
||||
$invoice = $ic->generateInvoice($crit);
|
||||
$invoice->setStatus(InvoiceStatus::DRAFT);
|
||||
|
||||
// remove previous invoice
|
||||
$old_invoice = $jo->getInvoice();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace App\Service\InvoiceGenerator;
|
||||
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\InvoiceStatus;
|
||||
use App\Ramcar\TradeInType;
|
||||
use App\Ramcar\DiscountApply;
|
||||
use App\Ramcar\ServiceType;
|
||||
|
|
@ -27,11 +30,14 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
const OTHER_SERVICES_FEE = 200;
|
||||
const COOLANT_FEE = 1600;
|
||||
const REFUEL_FEE_GAS = 260;
|
||||
const REFUEL_FEE_DIESEL = 220;
|
||||
const REFUEL_FEE_DIESEL = 220;
|
||||
|
||||
private $security;
|
||||
|
||||
// creates invoice based on the criteria sent
|
||||
public function __construct()
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function generateInvoice(InvoiceCriteria $criteria)
|
||||
|
|
@ -95,12 +101,19 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
// apply discounts
|
||||
$promos = $criteria->getPromos();
|
||||
|
||||
// get current user
|
||||
$user = $this->security->getUser();
|
||||
if ($user != null)
|
||||
{
|
||||
$invoice->setCreatedBy($user);
|
||||
}
|
||||
|
||||
$invoice->setTotalPrice($total['total_price'])
|
||||
->setVATExclusivePrice($total['vat_ex_price'])
|
||||
->setVAT($total['vat'])
|
||||
->setDiscount($total['discount'])
|
||||
->setTradeIn($total['ti_rate']);
|
||||
|
||||
->setTradeIn($total['ti_rate'])
|
||||
->setStatus(InvoiceStatus::DRAFT);
|
||||
|
||||
// dump
|
||||
//Debug::dump($invoice, 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue