refs #1408 Fixed invoice total discount feature..
This commit is contained in:
@@ -179,6 +179,11 @@ class CreateInvoice extends Job
|
||||
}
|
||||
|
||||
foreach ((array) $this->request['items'] as $item) {
|
||||
$item['global_discount'] = 0;
|
||||
|
||||
if (!empty($this->request['discount'])) {
|
||||
$item['global_discount'] = $this->request['discount'];
|
||||
}
|
||||
|
||||
$invoice_item = $this->dispatch(new CreateInvoiceItem($item, $this->invoice));
|
||||
|
||||
|
||||
@@ -38,11 +38,16 @@ class CreateInvoiceItem extends Job
|
||||
|
||||
$item_discounted_amount = $item_amount;
|
||||
|
||||
// Apply discount to amount
|
||||
// Apply line discount to amount
|
||||
if (!empty($this->request['discount'])) {
|
||||
$item_discounted_amount = $item_amount -= ($item_amount * ($this->request['discount'] / 100));
|
||||
}
|
||||
|
||||
// Apply global discount to amount
|
||||
if (!empty($this->request['global_discount'])) {
|
||||
$item_discounted_amount = $item_amount - ($item_amount * ($this->request['global_discount'] / 100));
|
||||
}
|
||||
|
||||
$tax_amount = 0;
|
||||
$item_taxes = [];
|
||||
$item_tax_total = 0;
|
||||
|
||||
@@ -193,6 +193,11 @@ class UpdateInvoice extends Job
|
||||
$this->deleteRelationships($this->invoice, ['items', 'item_taxes']);
|
||||
|
||||
foreach ((array) $this->request['items'] as $item) {
|
||||
$item['global_discount'] = 0;
|
||||
|
||||
if (!empty($this->request['discount'])) {
|
||||
$item['global_discount'] = $this->request['discount'];
|
||||
}
|
||||
|
||||
$invoice_item = $this->dispatch(new CreateInvoiceItem($item, $this->invoice));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user