Fix setting of promo for invoice. #755
This commit is contained in:
parent
1704235bbd
commit
458a34c6a8
1 changed files with 6 additions and 4 deletions
|
|
@ -192,12 +192,11 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
|
|
||||||
$invoice_items = [];
|
$invoice_items = [];
|
||||||
$data = [];
|
$data = [];
|
||||||
|
$promo = null;
|
||||||
foreach ($this->available_rules as $rule)
|
foreach ($this->available_rules as $rule)
|
||||||
{
|
{
|
||||||
$items = $rule->compute($criteria, $total);
|
$items = $rule->compute($criteria, $total);
|
||||||
|
|
||||||
$promo = null;
|
|
||||||
|
|
||||||
if (count($items) > 0)
|
if (count($items) > 0)
|
||||||
{
|
{
|
||||||
foreach ($items as $item)
|
foreach ($items as $item)
|
||||||
|
|
@ -210,7 +209,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
if (isset($item['battery']))
|
if (isset($item['battery']))
|
||||||
$battery = $item['battery'];
|
$battery = $item['battery'];
|
||||||
|
|
||||||
$promo = null;
|
|
||||||
if (isset($item['promo']))
|
if (isset($item['promo']))
|
||||||
$promo = $item['promo'];
|
$promo = $item['promo'];
|
||||||
|
|
||||||
|
|
@ -219,13 +217,13 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
'quantity' => $quantity,
|
'quantity' => $quantity,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
'battery' => $battery,
|
'battery' => $battery,
|
||||||
'promo' => $promo,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// also need to return the total and the promo
|
// also need to return the total and the promo
|
||||||
|
// promo is set per invoice, not per item
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'promo' => $promo,
|
'promo' => $promo,
|
||||||
'invoice_items' => $invoice_items,
|
'invoice_items' => $invoice_items,
|
||||||
|
|
@ -254,8 +252,12 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
|
|
||||||
// check if promo is set
|
// check if promo is set
|
||||||
if (isset($data['promo']))
|
if (isset($data['promo']))
|
||||||
|
{
|
||||||
$promo = $data['promo'];
|
$promo = $data['promo'];
|
||||||
|
|
||||||
|
$invoice->setPromo($promo);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($invoice_items as $item)
|
foreach ($invoice_items as $item)
|
||||||
{
|
{
|
||||||
$invoice_item = new InvoiceItem();
|
$invoice_item = new InvoiceItem();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue