From d8b9aef14f0a615555067258889bdb09cd6d117e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 21 Nov 2024 15:45:32 +0530 Subject: [PATCH] feat: available qty at company in sales transactions --- .../sales_invoice_item.json | 28 +++++++++++++++-- .../sales_invoice_item/sales_invoice_item.py | 1 + erpnext/controllers/selling_controller.py | 10 +++++-- .../quotation_item/quotation_item.json | 29 ++++++++++++++++-- .../doctype/quotation_item/quotation_item.py | 1 + .../sales_order_item/sales_order_item.json | 27 +++++++++++++++-- .../sales_order_item/sales_order_item.py | 1 + .../delivery_note_item.json | 30 +++++++++++++++---- .../delivery_note_item/delivery_note_item.py | 1 + 9 files changed, 112 insertions(+), 16 deletions(-) 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 f0d7c6ee232..27da8dc9ba2 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -90,11 +90,14 @@ "incoming_rate", "item_tax_rate", "actual_batch_qty", - "actual_qty", "section_break_eoec", "serial_no", "column_break_ytgd", "batch_no", + "available_quantity_section", + "actual_qty", + "column_break_ogff", + "company_total_stock", "edit_references", "sales_order", "so_detail", @@ -676,7 +679,8 @@ "allow_on_submit": 1, "fieldname": "actual_qty", "fieldtype": "Float", - "label": "Available Qty at Warehouse", + "label": "Qty (Warehouse)", + "no_copy": 1, "oldfieldname": "actual_qty", "oldfieldtype": "Currency", "print_hide": 1, @@ -930,12 +934,30 @@ "fieldtype": "Currency", "label": "Distributed Discount Amount", "options": "currency" + }, + { + "fieldname": "available_quantity_section", + "fieldtype": "Section Break", + "label": "Available Quantity" + }, + { + "fieldname": "column_break_ogff", + "fieldtype": "Column Break" + }, + { + "allow_on_submit": 1, + "fieldname": "company_total_stock", + "fieldtype": "Float", + "label": "Qty (Company)", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-10-28 15:06:40.980995", + "modified": "2024-11-25 16:27:33.287341", "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 c1d29ff4cac..b3421618629 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -34,6 +34,7 @@ class SalesInvoiceItem(Document): base_rate_with_margin: DF.Currency batch_no: DF.Link | None brand: DF.Data | None + company_total_stock: DF.Float conversion_factor: DF.Float cost_center: DF.Link customer_item_code: DF.Data | None diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 1a65b7a4e3f..85736767773 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -21,9 +21,15 @@ class SellingController(StockController): def onload(self): super().onload() - if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice"): + if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice", "Quotation"): for item in self.get("items") + (self.get("packed_items") or []): - item.update(get_bin_details(item.item_code, item.warehouse, include_child_warehouses=True)) + company = self.company + + item.update( + get_bin_details( + item.item_code, item.warehouse, company=company, include_child_warehouses=True + ) + ) def validate(self): super().validate() diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json index 3a12e9357a9..de230d710da 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.json +++ b/erpnext/selling/doctype/quotation_item/quotation_item.json @@ -24,6 +24,10 @@ "uom", "conversion_factor", "stock_qty", + "available_quantity_section", + "actual_qty", + "column_break_ylrv", + "company_total_stock", "section_break_16", "price_list_rate", "base_price_list_rate", @@ -71,7 +75,6 @@ "prevdoc_docname", "item_balance", "projected_qty", - "actual_qty", "col_break4", "stock_balance", "item_tax_rate", @@ -461,9 +464,10 @@ "report_hide": 1 }, { + "allow_on_submit": 1, "fieldname": "actual_qty", "fieldtype": "Float", - "label": "Actual Qty", + "label": "Qty (Warehouse)", "no_copy": 1, "print_hide": 1, "read_only": 1, @@ -669,12 +673,31 @@ "fieldtype": "Currency", "label": "Distributed Discount Amount", "options": "currency" + }, + { + "fieldname": "available_quantity_section", + "fieldtype": "Section Break", + "label": "Available Quantity" + }, + { + "fieldname": "column_break_ylrv", + "fieldtype": "Column Break" + }, + { + "allow_on_submit": 1, + "fieldname": "company_total_stock", + "fieldtype": "Float", + "label": "Qty (Company)", + "no_copy": 1, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-06-02 06:21:09.508680", + "modified": "2024-11-24 14:18:43.952844", "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 4aeb1ba0ec8..bbdd8643593 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.py +++ b/erpnext/selling/doctype/quotation_item/quotation_item.py @@ -27,6 +27,7 @@ class QuotationItem(Document): blanket_order: DF.Link | None blanket_order_rate: DF.Currency brand: DF.Link | None + company_total_stock: DF.Float conversion_factor: DF.Float customer_item_code: DF.Data | None description: DF.TextEditor | 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 c8cc9f90a52..dd016313a10 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -79,11 +79,14 @@ "against_blanket_order", "blanket_order", "blanket_order_rate", + "available_quantity_section", + "actual_qty", + "column_break_jpky", + "company_total_stock", "manufacturing_section_section", "bom_no", "planning_section", "projected_qty", - "actual_qty", "ordered_qty", "planned_qty", "production_plan_qty", @@ -637,7 +640,7 @@ "allow_on_submit": 1, "fieldname": "actual_qty", "fieldtype": "Float", - "label": "Actual Qty", + "label": "Qty (Warehouse)", "no_copy": 1, "print_hide": 1, "print_width": "70px", @@ -912,12 +915,30 @@ "fieldtype": "Currency", "label": "Distributed Discount Amount", "options": "currency" + }, + { + "allow_on_submit": 1, + "fieldname": "company_total_stock", + "fieldtype": "Float", + "label": "Qty (Company)", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_jpky", + "fieldtype": "Column Break" + }, + { + "fieldname": "available_quantity_section", + "fieldtype": "Section Break", + "label": "Available Quantity" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-06-02 06:13:40.597947", + "modified": "2024-11-21 13:21:29.743474", "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 58be64bce21..fa103e3348c 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.py +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.py @@ -30,6 +30,7 @@ class SalesOrderItem(Document): blanket_order_rate: DF.Currency bom_no: DF.Link | None brand: DF.Link | None + company_total_stock: DF.Float conversion_factor: DF.Float customer_item_code: DF.Data | None delivered_by_supplier: DF.Check 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 8bd857486d2..ba8b3b88555 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -88,16 +88,19 @@ "column_break_rxvc", "batch_no", "available_qty_section", - "actual_batch_qty", "actual_qty", - "installed_qty", - "item_tax_rate", + "actual_batch_qty", "column_break_atna", + "company_total_stock", + "section_break_kejd", + "installed_qty", "packed_qty", + "column_break_fguf", "received_qty", "accounting_details_section", "expense_account", "column_break_71", + "item_tax_rate", "internal_transfer_section", "material_request", "purchase_order", @@ -520,7 +523,7 @@ "allow_on_submit": 1, "fieldname": "actual_qty", "fieldtype": "Float", - "label": "Available Qty at From Warehouse", + "label": "Qty (Warehouse)", "no_copy": 1, "oldfieldname": "actual_qty", "oldfieldtype": "Currency", @@ -914,13 +917,30 @@ "fieldtype": "Currency", "label": "Distributed Discount Amount", "options": "currency" + }, + { + "allow_on_submit": 1, + "fieldname": "company_total_stock", + "fieldtype": "Float", + "label": "Qty (Company)", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "section_break_kejd", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_fguf", + "fieldtype": "Column Break" } ], "idx": 1, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-06-02 06:18:38.491763", + "modified": "2024-11-21 16:37:37.441498", "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 f9597f8b19e..7fb0e24be0b 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py @@ -30,6 +30,7 @@ class DeliveryNoteItem(Document): batch_no: DF.Link | None billed_amt: DF.Currency brand: DF.Link | None + company_total_stock: DF.Float conversion_factor: DF.Float cost_center: DF.Link | None customer_item_code: DF.Data | None