diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json index a6f73dae92a..7a7c5350c57 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json @@ -37,6 +37,7 @@ "column_break_19", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "section_break1", "rate", @@ -847,6 +848,12 @@ { "fieldname": "column_break_ciit", "fieldtype": "Column Break" + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "istable": 1, diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py index e058f8225ab..7b28f11187d 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py @@ -39,6 +39,7 @@ class POSInvoiceItem(SalesInvoiceItem): description: DF.TextEditor discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency dn_detail: DF.Data | None enable_deferred_revenue: DF.Check expense_account: DF.Link | None diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 6e0dc694b3b..6ab587d3bce 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -38,6 +38,7 @@ "column_break_30", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "sec_break2", "rate", @@ -838,7 +839,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "section_break_26", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -969,6 +970,12 @@ "no_copy": 1, "options": "Company:company:default_currency", "print_hide": 1 + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py index a8f844c6c1c..96db9d66f05 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py @@ -34,6 +34,7 @@ class PurchaseInvoiceItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency enable_deferred_expense: DF.Check expense_account: DF.Link | None from_warehouse: DF.Link | None diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index 240b16bf6a9..aba45c292e2 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -37,6 +37,7 @@ "column_break_19", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "section_break1", "rate", @@ -253,7 +254,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -922,12 +923,18 @@ { "fieldname": "column_break_ytgd", "fieldtype": "Column Break" + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-05-23 16:36:18.970862", + "modified": "2024-06-02 06:14:40.009020", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index f92a7a8222b..c1d29ff4cac 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -45,6 +45,7 @@ class SalesInvoiceItem(Document): discount_account: DF.Link | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency dn_detail: DF.Data | None enable_deferred_revenue: DF.Check expense_account: DF.Link | None diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json index 5f4c9f0fd43..c2f9f9efbb2 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -42,6 +42,7 @@ "column_break_28", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "sec_break2", "rate", @@ -782,7 +783,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin_section", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -922,13 +923,19 @@ "label": "Job Card", "options": "Job Card", "search_index": 1 + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:12:24.979325", + "modified": "2024-06-02 06:20:10.508290", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order Item", diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py index e9cc2b4eecf..79c66c3a30e 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py @@ -37,6 +37,7 @@ class PurchaseOrderItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency expected_delivery_date: DF.Date | None expense_account: DF.Link | None fg_item: DF.Link | None diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json index f043b821287..34a6c0b9003 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json @@ -32,6 +32,7 @@ "price_list_rate", "discount_percentage", "discount_amount", + "distributed_discount_amount", "col_break_price_list", "base_price_list_rate", "sec_break1", @@ -565,13 +566,19 @@ { "fieldname": "dimension_col_break", "fieldtype": "Column Break" + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:49.490628", + "modified": "2024-06-02 06:22:17.864822", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation Item", diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py index d2f4a59930b..a51b9500fd8 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py @@ -26,6 +26,7 @@ class SupplierQuotationItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency expected_delivery_date: DF.Date | None image: DF.Attach | None is_free_item: DF.Check diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 65f73061008..01a95c17a2e 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1654,8 +1654,11 @@ class AccountsController(TransactionBase): and self.get("discount_amount") and self.get("additional_discount_account") ): - amount = item.amount - base_amount = item.base_amount + amount += item.distributed_discount_amount + base_amount += flt( + item.distributed_discount_amount * self.get("conversion_rate"), + item.precision("distributed_discount_amount"), + ) return amount, base_amount diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 127ed31e837..b40af6a2ac0 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -684,6 +684,9 @@ class calculate_taxes_and_totals: ) item.net_amount = flt(item.net_amount - distributed_amount, item.precision("net_amount")) + item.distributed_discount_amount = flt( + distributed_amount, item.precision("distributed_discount_amount") + ) net_total += item.net_amount # discount amount rounding loss adjustment if no taxes @@ -700,6 +703,10 @@ class calculate_taxes_and_totals: item.net_amount = flt( item.net_amount + discount_amount_loss, item.precision("net_amount") ) + item.distributed_discount_amount = flt( + distributed_amount + discount_amount_loss, + item.precision("distributed_discount_amount"), + ) item.net_rate = ( flt(item.net_amount / item.qty, item.precision("net_rate")) if item.qty else 0 diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json index 6edc734d9cc..3a12e9357a9 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.json +++ b/erpnext/selling/doctype/quotation_item/quotation_item.json @@ -34,6 +34,7 @@ "column_break_18", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "section_break1", "rate", @@ -235,7 +236,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -662,12 +663,18 @@ "label": "Has Alternative Item", "print_hide": 1, "read_only": 1 + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:31.183320", + "modified": "2024-06-02 06:21:09.508680", "modified_by": "Administrator", "module": "Selling", "name": "Quotation Item", diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.py b/erpnext/selling/doctype/quotation_item/quotation_item.py index f209762c3ba..4aeb1ba0ec8 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.py +++ b/erpnext/selling/doctype/quotation_item/quotation_item.py @@ -32,6 +32,7 @@ class QuotationItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency gross_profit: DF.Currency has_alternative_item: DF.Check image: DF.Attach | None diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json index 5c3e01a4850..c8cc9f90a52 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -40,6 +40,7 @@ "column_break_19", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "section_break_simple1", "rate", @@ -280,7 +281,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -905,12 +906,18 @@ "label": "Is Stock Item", "print_hide": 1, "report_hide": 1 + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:37.177978", + "modified": "2024-06-02 06:13:40.597947", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order Item", diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.py b/erpnext/selling/doctype/sales_order_item/sales_order_item.py index fa7b9b968f3..58be64bce21 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.py +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.py @@ -38,6 +38,7 @@ class SalesOrderItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency ensure_delivery_based_on_produced_serial_no: DF.Check grant_commission: DF.Check gross_profit: DF.Currency diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index c93031e9e7e..8bd857486d2 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -40,6 +40,7 @@ "column_break_19", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "section_break_1", "rate", @@ -274,7 +275,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -907,13 +908,19 @@ { "fieldname": "column_break_rxvc", "fieldtype": "Column Break" + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:06:50.061877", + "modified": "2024-06-02 06:18:38.491763", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py index b76f7429728..f9597f8b19e 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py @@ -36,6 +36,7 @@ class DeliveryNoteItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Float + distributed_discount_amount: DF.Currency dn_detail: DF.Data | None expense_account: DF.Link | None grant_commission: DF.Check diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 0a5e8c60403..f610826ba64 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -48,6 +48,7 @@ "column_break_37", "discount_percentage", "discount_amount", + "distributed_discount_amount", "base_rate_with_margin", "sec_break1", "rate", @@ -911,7 +912,7 @@ }, { "collapsible": 1, - "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount", + "collapsible_depends_on": "eval: doc.margin_type || doc.discount_amount || doc.distributed_discount_amount", "fieldname": "discount_and_margin_section", "fieldtype": "Section Break", "label": "Discount and Margin" @@ -1135,6 +1136,12 @@ "no_copy": 1, "options": "Company:company:default_currency", "print_hide": 1 + }, + { + "fieldname": "distributed_discount_amount", + "fieldtype": "Currency", + "label": "Distributed Discount Amount", + "options": "currency" } ], "idx": 1, diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py index 2154007771d..6581fc00d37 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py @@ -36,6 +36,7 @@ class PurchaseReceiptItem(Document): description: DF.TextEditor | None discount_amount: DF.Currency discount_percentage: DF.Percent + distributed_discount_amount: DF.Currency expense_account: DF.Link | None from_warehouse: DF.Link | None has_item_scanned: DF.Check