From f92b5011dace89d76c5038cd91dea567ee286408 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 28 Nov 2022 22:51:35 +0530 Subject: [PATCH 01/10] fix: incorrect balance qty (cherry picked from commit b2105a8be7ba3891df1253a94c8322632db22956) --- .../stock/doctype/stock_reconciliation/stock_reconciliation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index d92d0f1686e..260c1344b1e 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -348,6 +348,9 @@ class StockReconciliation(StockController): if row.qty: args = self.get_sle_for_items(row) + if row.serial_no and row.batch_no: + args["qty_after_transaction"] = row.qty + args.update( { "actual_qty": row.qty, From 93ec57dd4440e24a2764e73bbb541a4961bfb7f8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 29 Nov 2022 00:08:07 +0530 Subject: [PATCH 02/10] test: test case for serialized batched item (cherry picked from commit b606a9684beb7a7f3256fad25c9389dc7e763d4f) --- .../stock_reconciliation.py | 6 ++-- .../test_stock_reconciliation.py | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 260c1344b1e..3a0b38a0fcd 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -230,7 +230,7 @@ class StockReconciliation(StockController): if item.has_serial_no or item.has_batch_no: has_serial_no = True - self.get_sle_for_serialized_items(row, sl_entries) + self.get_sle_for_serialized_items(row, sl_entries, item) else: if row.serial_no or row.batch_no: frappe.throw( @@ -282,7 +282,7 @@ class StockReconciliation(StockController): if has_serial_no and sl_entries: self.update_valuation_rate_for_serial_no() - def get_sle_for_serialized_items(self, row, sl_entries): + def get_sle_for_serialized_items(self, row, sl_entries, item): from erpnext.stock.stock_ledger import get_previous_sle serial_nos = get_serial_nos(row.serial_no) @@ -348,7 +348,7 @@ class StockReconciliation(StockController): if row.qty: args = self.get_sle_for_items(row) - if row.serial_no and row.batch_no: + if item.has_serial_no and item.has_batch_no: args["qty_after_transaction"] = row.qty args.update( diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 7b984d38475..eaea301432e 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -644,6 +644,38 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): ) self.assertEqual(len(active_sr_no), 0) + def test_serial_no_batch_no_item(self): + item = self.make_item( + "Test Serial No Batch No Item", + { + "is_stock_item": 1, + "has_serial_no": 1, + "has_batch_no": 1, + "serial_no_series": "SRS9.####", + "batch_number_series": "BNS9.####", + "create_new_batch": 1, + }, + ) + + warehouse = "_Test Warehouse - _TC" + + sr = create_stock_reconciliation( + item_code=item.name, + warehouse=warehouse, + qty=1, + rate=100, + ) + + sl_entry = frappe.db.get_value( + "Stock Ledger Entry", + {"voucher_type": "Stock Reconciliation", "voucher_no": sr.name}, + ["actual_qty", "qty_after_transaction"], + as_dict=1, + ) + + self.assertEqual(flt(sl_entry.actual_qty), 1.0) + self.assertEqual(flt(sl_entry.qty_after_transaction), 1.0) + def create_batch_item_with_batch(item_name, batch_id): batch_item_doc = create_item(item_name, is_stock_item=1) From 93b8cc3042fe22a6412bd5f084b6cd3ef36db714 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Nov 2022 17:37:41 +0530 Subject: [PATCH 03/10] fix(ux): Action buttons in Bank Reconciliation (cherry picked from commit 6ebe8ad60d62645b1604481ff6d9b2b97a0fc104) --- .../doctype/bank_clearance/bank_clearance.js | 28 ++++++++++++++---- .../bank_clearance/bank_clearance.json | 29 ++++--------------- .../doctype/bank_clearance/bank_clearance.py | 2 -- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js index 7e57c2fc471..ceba99a56a8 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js @@ -37,6 +37,14 @@ frappe.ui.form.on("Bank Clearance", { refresh: function(frm) { frm.disable_save(); + + if (frm.doc.account && frm.doc.from_date && frm.doc.to_date) { + frm.add_custom_button(__('Get Payment Entries'), () => + frm.trigger("get_payment_entries") + ); + + frm.change_custom_button_type('Get Payment Entries', null, 'primary'); + } }, update_clearance_date: function(frm) { @@ -46,22 +54,30 @@ frappe.ui.form.on("Bank Clearance", { callback: function(r, rt) { frm.refresh_field("payment_entries"); frm.refresh_fields(); + + if (!frm.doc.payment_entries.length) { + frm.change_custom_button_type('Get Payment Entries', null, 'primary'); + frm.change_custom_button_type('Update Clearance Date', null, 'default'); + } } }); }, + get_payment_entries: function(frm) { return frappe.call({ method: "get_payment_entries", doc: frm.doc, callback: function(r, rt) { frm.refresh_field("payment_entries"); - frm.refresh_fields(); - $(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){ - if (i !=0){ - $(v).addClass("text-right") - } - }) + if (frm.doc.payment_entries.length) { + frm.add_custom_button(__('Update Clearance Date'), () => + frm.trigger("update_clearance_date") + ); + + frm.change_custom_button_type('Get Payment Entries', null, 'default'); + frm.change_custom_button_type('Update Clearance Date', null, 'primary'); + } } }); } diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.json b/erpnext/accounts/doctype/bank_clearance/bank_clearance.json index a436d1effb8..591d01949b8 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.json +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_copy": 1, "creation": "2013-01-10 16:34:05", "doctype": "DocType", @@ -13,11 +14,8 @@ "bank_account", "include_reconciled_entries", "include_pos_transactions", - "get_payment_entries", "section_break_10", - "payment_entries", - "update_clearance_date", - "total_amount" + "payment_entries" ], "fields": [ { @@ -76,11 +74,6 @@ "fieldtype": "Check", "label": "Include POS Transactions" }, - { - "fieldname": "get_payment_entries", - "fieldtype": "Button", - "label": "Get Payment Entries" - }, { "fieldname": "section_break_10", "fieldtype": "Section Break" @@ -91,25 +84,14 @@ "fieldtype": "Table", "label": "Payment Entries", "options": "Bank Clearance Detail" - }, - { - "fieldname": "update_clearance_date", - "fieldtype": "Button", - "label": "Update Clearance Date" - }, - { - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "account_currency", - "read_only": 1 } ], "hide_toolbar": 1, "icon": "fa fa-check", "idx": 1, "issingle": 1, - "modified": "2020-04-06 16:12:06.628008", + "links": [], + "modified": "2022-11-28 17:24:13.008692", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Clearance", @@ -126,5 +108,6 @@ "quick_entry": 1, "read_only": 1, "sort_field": "modified", - "sort_order": "ASC" + "sort_order": "ASC", + "states": [] } \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 78c35266542..80878ac5068 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -179,7 +179,6 @@ class BankClearance(Document): ) self.set("payment_entries", []) - self.total_amount = 0.0 default_currency = erpnext.get_default_currency() for d in entries: @@ -198,7 +197,6 @@ class BankClearance(Document): d.pop("debit") d.pop("account_currency") row.update(d) - self.total_amount += flt(amount) @frappe.whitelist() def update_clearance_date(self): From 2aada1a0d95d9fde65314d1078eb850dedce7801 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Nov 2022 19:22:35 +0530 Subject: [PATCH 04/10] fix: Auto repeat date validations (cherry picked from commit fa152214552e37236ff927e35ed09d016933a26c) --- erpnext/controllers/accounts_controller.py | 4 ++++ erpnext/controllers/buying_controller.py | 1 + erpnext/controllers/selling_controller.py | 1 + 3 files changed, 6 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1849e8b3b55..dc42a89df7f 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -239,6 +239,10 @@ class AccountsController(TransactionBase): else: item.set(field_map.get(self.doctype), default_deferred_account) + def validate_auto_repeat_subscription_dates(self): + if getdate(self.from_date) > getdate(self.to_date): + frappe.throw(_("To Date cannot be before From Date"), title=_("Invalid Auto Repeat Date")) + def validate_deferred_start_and_end_date(self): for d in self.items: if d.get("enable_deferred_revenue") or d.get("enable_deferred_expense"): diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 48fe7cb083d..051460474ac 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -41,6 +41,7 @@ class BuyingController(SubcontractingController): self.validate_from_warehouse() self.set_supplier_address() self.validate_asset_return() + self.validate_auto_repeat_subscription_dates() if self.doctype == "Purchase Invoice": self.validate_purchase_receipt_if_update_stock() diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 88d2f0687dc..965335b1a3f 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -40,6 +40,7 @@ class SellingController(StockController): self.set_customer_address() self.validate_for_duplicate_items() self.validate_target_warehouse() + self.validate_auto_repeat_subscription_dates() def set_missing_values(self, for_validate=False): From 5abcb478d0c90a23b5ed0cc3ffde9e3c28caf324 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Nov 2022 22:47:44 +0530 Subject: [PATCH 05/10] chore: Update condition (cherry picked from commit 6a47fb6c9e9e93553b622a795217f3a15ded1eb9) --- erpnext/controllers/accounts_controller.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index dc42a89df7f..b7a80c10192 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -240,7 +240,11 @@ class AccountsController(TransactionBase): item.set(field_map.get(self.doctype), default_deferred_account) def validate_auto_repeat_subscription_dates(self): - if getdate(self.from_date) > getdate(self.to_date): + if ( + self.get("from_date") + and self.get("to_date") + and getdate(self.from_date) > getdate(self.to_date) + ): frappe.throw(_("To Date cannot be before From Date"), title=_("Invalid Auto Repeat Date")) def validate_deferred_start_and_end_date(self): From cdd13cd95fe3344ab342de98436c1f125d6b8182 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 25 Nov 2022 16:23:20 +0530 Subject: [PATCH 06/10] fix: remove duplicate schema (cherry picked from commit 2c18a95115baf3cbc79a2c2d7ba48b862425f159) --- erpnext/templates/generators/item/item.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/templates/generators/item/item.html b/erpnext/templates/generators/item/item.html index 4070d40d47e..358c1c52e5f 100644 --- a/erpnext/templates/generators/item/item.html +++ b/erpnext/templates/generators/item/item.html @@ -32,7 +32,7 @@
-
+
{% if show_tabs and tabs %}
From c1ae5b0af5aa49f53ed64cf45ae99c1845b25234 Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Fri, 25 Nov 2022 15:06:06 +0530 Subject: [PATCH 07/10] fix(pos): filter on customer groups Signed-off-by: Sabu Siyad (cherry picked from commit cc63415887071b7675b95b6698884fd61847ab73) --- .../doctype/pos_invoice/pos_invoice.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js index 15c292211c0..fa11b7d9d8f 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js @@ -5,6 +5,8 @@ frappe.provide("erpnext.accounts"); erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnext.selling.SellingController { + settings = {}; + setup(doc) { this.setup_posting_date_time_check(); super.setup(doc); @@ -25,8 +27,13 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); } + onload_post_render(frm) { + this.pos_profile(frm); + } + refresh(doc) { super.refresh(); + if (doc.docstatus == 1 && !doc.is_return) { this.frm.add_custom_button(__('Return'), this.make_sales_return, __('Create')); this.frm.page.set_inner_btn_group_as_primary(__('Create')); @@ -36,6 +43,18 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex this.frm.return_print_format = "Sales Invoice Return"; this.frm.set_value('consolidated_invoice', ''); } + + this.frm.set_query("customer", (function () { + const customer_groups = this.settings?.customer_groups; + + if (!customer_groups?.length) return {}; + + return { + filters: { + customer_group: ["in", customer_groups], + } + } + }).bind(this)); } is_pos() { @@ -88,6 +107,25 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex }); } + pos_profile(frm) { + if (!frm.pos_profile || frm.pos_profile == '') { + this.update_customer_groups_settings([]); + return; + } + + frappe.call({ + method: "erpnext.selling.page.point_of_sale.point_of_sale.get_pos_profile_data", + args: { "pos_profile": frm.pos_profile }, + callback: ({ message: profile }) => { + this.update_customer_groups_settings(profile?.customer_groups); + }, + }); + } + + update_customer_groups_settings(customer_groups) { + this.settings.customer_groups = customer_groups?.map((group) => group.name) + } + amount(){ this.write_off_outstanding_amount_automatically() } From c03ec80d1add7d2b854cf2252cc43c1a51e67c81 Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Thu, 24 Nov 2022 15:40:05 +0530 Subject: [PATCH 08/10] fix(pos): warehouse should be in company Signed-off-by: Sabu Siyad (cherry picked from commit 95a620a30d67e6b2ac5137d87efa97f3f149b95f) --- erpnext/accounts/doctype/pos_invoice/pos_invoice.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js index 15c292211c0..c868d9ec7e9 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js @@ -12,6 +12,8 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex company() { erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype); + this.frm.set_value("set_warehouse", ""); + this.frm.set_value("taxes_and_charges", ""); } onload(doc) { From c379baf7a2d7f038e7eff5b204a9704434f2e5ed Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Thu, 24 Nov 2022 16:11:26 +0530 Subject: [PATCH 09/10] feat(pos): invoice: fitler warehouse by company Signed-off-by: Sabu Siyad (cherry picked from commit 4ad0e2ed7eb925c893a84ef00964fbc1cab09cc6) --- erpnext/accounts/doctype/pos_invoice/pos_invoice.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js index c868d9ec7e9..40df6187d29 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js @@ -19,11 +19,20 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex onload(doc) { super.onload(); this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice Merge Log', 'POS Closing Entry']; + if(doc.__islocal && doc.is_pos && frappe.get_route_str() !== 'point-of-sale') { this.frm.script_manager.trigger("is_pos"); this.frm.refresh_fields(); } + this.frm.set_query("set_warehouse", function(doc) { + return { + filters: { + company: doc.company ? doc.company : '', + } + } + }); + erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); } From 8d0f715087baf8940cc72986094d33c910e3c58b Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 25 Nov 2022 17:03:00 +0530 Subject: [PATCH 10/10] fix: only show serial no batch selector only once (cherry picked from commit 0f87d329d616c65249e180c57011cda4955e1e23) --- erpnext/stock/doctype/stock_entry/stock_entry.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 266ea5f674f..b9102445e01 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1079,7 +1079,8 @@ erpnext.stock.select_batch_and_serial_no = (frm, item) => { if (frm.doc.purpose === 'Material Receipt') return; frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() { - new erpnext.SerialNoBatchSelector({ + if (frm.batch_selector?.dialog?.display) return; + frm.batch_selector = new erpnext.SerialNoBatchSelector({ frm: frm, item: item, warehouse_details: get_warehouse_type_and_name(item),