Merge branch '755-resq-2-fix-display-of-discount-type' into '746-resq-2-0-final'

Resolve "RESQ 2: Fix display of discount type"

See merge request jankstudio/resq!869
This commit is contained in:
Ramon Gutierrez 2023-07-28 09:27:23 +00:00
commit e212e2d29a

View file

@ -192,12 +192,11 @@ class InvoiceManager implements InvoiceGeneratorInterface
$invoice_items = [];
$data = [];
$promo = null;
foreach ($this->available_rules as $rule)
{
$items = $rule->compute($criteria, $total);
$promo = null;
if (count($items) > 0)
{
foreach ($items as $item)
@ -210,7 +209,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
if (isset($item['battery']))
$battery = $item['battery'];
$promo = null;
if (isset($item['promo']))
$promo = $item['promo'];
@ -219,13 +217,13 @@ class InvoiceManager implements InvoiceGeneratorInterface
'quantity' => $quantity,
'price' => $price,
'battery' => $battery,
'promo' => $promo,
];
}
}
}
// also need to return the total and the promo
// promo is set per invoice, not per item
$data[] = [
'promo' => $promo,
'invoice_items' => $invoice_items,
@ -254,8 +252,12 @@ class InvoiceManager implements InvoiceGeneratorInterface
// check if promo is set
if (isset($data['promo']))
{
$promo = $data['promo'];
$invoice->setPromo($promo);
}
foreach ($invoice_items as $item)
{
$invoice_item = new InvoiceItem();