Moved invoice code out of JO controller. #354
This commit is contained in:
parent
39b9e50654
commit
9125a0d2fa
4 changed files with 39 additions and 10 deletions
|
|
@ -696,7 +696,7 @@ class JobOrderController extends Controller
|
||||||
$items = $req->request->get('items');
|
$items = $req->request->get('items');
|
||||||
$promo_id = $req->request->get('promo');
|
$promo_id = $req->request->get('promo');
|
||||||
$cvid = $req->request->get('cvid');
|
$cvid = $req->request->get('cvid');
|
||||||
$service_charges = $req->request->get('service_charges');
|
$service_charges = $req->request->get('service_charges', []);
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
|
@ -740,14 +740,7 @@ class JobOrderController extends Controller
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: this snippet should be in the invoice generator
|
$error = $ic->generateDraftInvoice($criteria, $promo_id, $service_charges, $items);
|
||||||
$error = $ic->validateDiscount($criteria, $promo_id);
|
|
||||||
|
|
||||||
// process service charges
|
|
||||||
$error = $ic->invoiceServiceCharges($criteria, $service_charges);
|
|
||||||
|
|
||||||
if (!$error)
|
|
||||||
$error = $ic->invoiceBatteries($criteria, $items);
|
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,25 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepare draft for invoice
|
||||||
|
public function generateDraftInvoice($criteria, $discount, $service_charges, $items)
|
||||||
|
{
|
||||||
|
$ierror = $this->validateDiscount($criteria, $discount);
|
||||||
|
|
||||||
|
if (!$ierror)
|
||||||
|
{
|
||||||
|
// process service charges
|
||||||
|
$ierror = $this->invoiceServiceCharges($criteria, $service_charges);
|
||||||
|
|
||||||
|
if (!$ierror)
|
||||||
|
{
|
||||||
|
$ierror = $this->invoiceBatteries($criteria, $items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ierror;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getTaxAmount($price)
|
protected function getTaxAmount($price)
|
||||||
{
|
{
|
||||||
$vat_ex_price = $this->getTaxExclusivePrice($price);
|
$vat_ex_price = $this->getTaxExclusivePrice($price);
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,20 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepare draft for invoice
|
||||||
|
public function generateDraftInvoice($criteria, $promo_id, $service_charges, $items)
|
||||||
|
{
|
||||||
|
$ierror = $this->invoicePromo($criteria, $promo_id);
|
||||||
|
|
||||||
|
if (!$ierror)
|
||||||
|
{
|
||||||
|
$ierror = $this->invoiceBatteries($criteria, $items);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ierror;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getTaxAmount($price)
|
protected function getTaxAmount($price)
|
||||||
{
|
{
|
||||||
$vat_ex_price = $this->getTaxExclusivePrice($price);
|
$vat_ex_price = $this->getTaxExclusivePrice($price);
|
||||||
|
|
@ -227,7 +241,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoicePromo(InvoiceCriteria $criteria, $promo_id)
|
protected function invoicePromo(InvoiceCriteria $criteria, $promo_id)
|
||||||
{
|
{
|
||||||
// return error if there's a problem, false otherwise
|
// return error if there's a problem, false otherwise
|
||||||
// check service type
|
// check service type
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,7 @@ interface InvoiceGeneratorInterface
|
||||||
// generate invoice criteria
|
// generate invoice criteria
|
||||||
public function generateInvoiceCriteria(JobOrder $jo, int $promo_id, array $invoice_items, array &$error_array);
|
public function generateInvoiceCriteria(JobOrder $jo, int $promo_id, array $invoice_items, array &$error_array);
|
||||||
|
|
||||||
|
// prepare draft for invoice
|
||||||
|
public function generateDraftInvoice(InvoiceCriteria $criteria, int $promo_id, array $service_charges, array $items);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue