From daf22287253aa13a374879fd2510ad223d15b302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Thu, 15 Sep 2022 14:11:37 +0300 Subject: [PATCH] reverd document discount changes.. --- app/Jobs/Document/CreateDocumentItem.php | 15 ++++++--------- .../Document/CreateDocumentItemsAndTotals.php | 11 ----------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/app/Jobs/Document/CreateDocumentItem.php b/app/Jobs/Document/CreateDocumentItem.php index c4fc9132b..92710d1f9 100644 --- a/app/Jobs/Document/CreateDocumentItem.php +++ b/app/Jobs/Document/CreateDocumentItem.php @@ -45,16 +45,13 @@ class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreat } // Apply total discount to amount - /* - // Disabled this block because broken line item amount.. - if (!empty($this->request['global_discount'])) { + if (! empty($this->request['global_discount'])) { if ($this->request['global_discount_type'] === 'percentage') { - //$item_discounted_amount -= $item_discounted_amount * ($this->request['global_discount'] / 100); + $item_discounted_amount -= $item_discounted_amount * ($this->request['global_discount'] / 100); } else { - //$item_discounted_amount -= $this->request['global_discount']; + $item_discounted_amount -= $this->request['global_discount']; } } - */ $tax_amount = 0; $item_tax_total = 0; @@ -155,12 +152,12 @@ class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreat $this->request['document_id'] = $this->document->id; $this->request['item_id'] = $item_id; $this->request['name'] = Str::limit($this->request['name'], 180, ''); - $this->request['description'] = !empty($this->request['description']) ? $this->request['description'] : ''; + $this->request['description'] = ! empty($this->request['description']) ? $this->request['description'] : ''; $this->request['quantity'] = (double) $this->request['quantity']; $this->request['price'] = round($this->request['price'], $precision); $this->request['tax'] = round($item_tax_total, $precision); - $this->request['discount_type'] = ! empty($this->request['discount_type']) ? $this->request['discount_type'] : null; - $this->request['discount_rate'] = !empty($this->request['discount']) ? $this->request['discount'] : 0; + $this->request['discount_type'] = ! empty($this->request['discount_type']) ? $this->request['discount_type'] : 'percent'; + $this->request['discount_rate'] = ! empty($this->request['discount']) ? $this->request['discount'] : 0; $this->request['total'] = round($actual_price_item, $precision); $this->request['created_from'] = $this->request['created_from']; $this->request['created_by'] = $this->request['created_by']; diff --git a/app/Jobs/Document/CreateDocumentItemsAndTotals.php b/app/Jobs/Document/CreateDocumentItemsAndTotals.php index 52b17a50b..b2afe11b1 100644 --- a/app/Jobs/Document/CreateDocumentItemsAndTotals.php +++ b/app/Jobs/Document/CreateDocumentItemsAndTotals.php @@ -227,17 +227,6 @@ class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, S $discount_amount_total += $discount_amount; - // Calculate global discount total - if (! empty($item['global_discount'])) { - if ($item['global_discount_type'] === 'percentage') { - $global_discount_amount = $document_item->total * ($item['global_discount'] / 100); - } else { - $global_discount_amount = $item['global_discount']; - } - - $actual_total -= $global_discount_amount; - } - if (! $document_item->item_taxes) { continue; }