Add saving of service charges to JO and Invoice Item. #341
This commit is contained in:
parent
f3f941e0a0
commit
0cff722c6a
3 changed files with 21 additions and 2 deletions
|
|
@ -161,11 +161,20 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
$ierror = $this->invoiceBatteries($criteria, $invoice_items);
|
$ierror = $this->invoiceBatteries($criteria, $invoice_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the meta for service charges
|
||||||
|
$service_charges = $jo->getMeta('service_charges');
|
||||||
|
if ($service_charges != null)
|
||||||
|
{
|
||||||
|
$service_charges = $jo->getMeta('service_charges');
|
||||||
|
|
||||||
|
$this->invoiceServiceCharges($criteria, $service_charges);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($ierror)
|
if ($ierror)
|
||||||
{
|
{
|
||||||
$error_array['invoice'] = $ierror;
|
$error_array['invoice'] = $ierror;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// generate the invoice
|
// generate the invoice
|
||||||
|
|
@ -641,12 +650,13 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
foreach ($service_charges as $service_charge)
|
foreach ($service_charges as $service_charge)
|
||||||
{
|
{
|
||||||
$amount = $service_charge->getAmount();
|
$amount = $service_charge->getAmount();
|
||||||
|
$title = 'Service Charge - ' . $service_charge->getName();
|
||||||
|
|
||||||
$total['total_price'] += $amount;
|
$total['total_price'] += $amount;
|
||||||
// add item
|
// add item
|
||||||
$item = new InvoiceItem();
|
$item = new InvoiceItem();
|
||||||
$item->setInvoice($invoice)
|
$item->setInvoice($invoice)
|
||||||
->setTitle('Service Charge - ' . $service_charge->getName())
|
->setTitle($title)
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice($amount);
|
->setPrice($amount);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -531,6 +531,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['invoice_discount'] = 'Invalid discount specified';
|
$error_array['invoice_discount'] = 'Invalid discount specified';
|
||||||
|
|
||||||
// get list of service charges
|
// get list of service charges
|
||||||
|
$service_charges = $req->request->get('service_charges');
|
||||||
|
|
||||||
if (empty($error_array))
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
|
|
@ -563,6 +564,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
|
|
||||||
$jo->addMeta('discount', $discount);
|
$jo->addMeta('discount', $discount);
|
||||||
|
|
||||||
|
if (!empty($service_charges))
|
||||||
|
{
|
||||||
|
$jo->addMeta('service_charges', $service_charges);
|
||||||
|
}
|
||||||
|
|
||||||
// check if user is null, meaning call to create came from API
|
// check if user is null, meaning call to create came from API
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -994,6 +994,9 @@ $(function() {
|
||||||
// add invoice items to data
|
// add invoice items to data
|
||||||
fields['invoice_items'] = invoiceItems;
|
fields['invoice_items'] = invoiceItems;
|
||||||
|
|
||||||
|
// add service charges to data
|
||||||
|
fields['service_charges'] = sc_array;
|
||||||
|
|
||||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||||
// add selected hub to data
|
// add selected hub to data
|
||||||
fields['hub'] = selectedHub;
|
fields['hub'] = selectedHub;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue