From 91762097a54bfcbb5d693a3feb4238b0ae28cf78 Mon Sep 17 00:00:00 2001 From: hrzzz Date: Wed, 3 Aug 2022 13:09:23 -0300 Subject: [PATCH 01/72] fix: for Tree Type item and item group show net amout --- erpnext/selling/report/sales_analytics/sales_analytics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py index 9d7d806c71..186352848d 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.py +++ b/erpnext/selling/report/sales_analytics/sales_analytics.py @@ -168,7 +168,7 @@ class Analytics(object): def get_sales_transactions_based_on_items(self): if self.filters["value_quantity"] == "Value": - value_field = "base_amount" + value_field = "base_net_amount" else: value_field = "stock_qty" @@ -216,7 +216,7 @@ class Analytics(object): def get_sales_transactions_based_on_item_group(self): if self.filters["value_quantity"] == "Value": - value_field = "base_amount" + value_field = "base_net_amount" else: value_field = "qty" From 33762dbbac55181371f7bcf052474d213312434b Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 10 Aug 2022 14:17:28 +0530 Subject: [PATCH 02/72] fix(pos): error while consolidating pos invoices --- .../accounts/doctype/pos_profile/pos_profile.json | 11 ++++++++++- erpnext/controllers/taxes_and_totals.py | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index d5f7ee4f21..994b6776e3 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -43,6 +43,7 @@ "currency", "write_off_account", "write_off_cost_center", + "write_off_limit", "account_for_change_amount", "disable_rounded_total", "column_break_23", @@ -360,6 +361,14 @@ "fieldtype": "Check", "label": "Validate Stock on Save" }, + { + "default": "1", + "description": "Auto write off precision loss while consolidation", + "fieldname": "write_off_limit", + "fieldtype": "Currency", + "label": "Write Off Limit", + "reqd": 1 + }, { "default": "0", "description": "If enabled, the consolidated invoices will have rounded total disabled", @@ -393,7 +402,7 @@ "link_fieldname": "pos_profile" } ], - "modified": "2022-07-21 11:16:46.911173", + "modified": "2022-08-10 12:57:06.241439", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 0d8cffe03f..26b8db4a81 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -767,6 +767,18 @@ class calculate_taxes_and_totals(object): self.doc.precision("outstanding_amount"), ) + if ( + self.doc.doctype == "Sales Invoice" + and self.doc.get("is_pos") + and self.doc.get("pos_profile") + and self.doc.get("is_consolidated") + ): + write_off_limit = flt( + frappe.db.get_value("POS Profile", self.doc.pos_profile, "write_off_limit") + ) + if write_off_limit and abs(self.doc.outstanding_amount) <= write_off_limit: + self.doc.write_off_outstanding_amount_automatically = 1 + if ( self.doc.doctype == "Sales Invoice" and self.doc.get("is_pos") From 27891ecb77a74dea90c30133d81d92edebf59cf3 Mon Sep 17 00:00:00 2001 From: hrzzz Date: Mon, 15 Aug 2022 09:14:23 -0300 Subject: [PATCH 03/72] feat: two new filters for gross profit --- .../accounts/report/gross_profit/gross_profit.js | 12 ++++++++++++ .../accounts/report/gross_profit/gross_profit.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.js b/erpnext/accounts/report/gross_profit/gross_profit.js index 21205c3163..ffbe9ada6c 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.js +++ b/erpnext/accounts/report/gross_profit/gross_profit.js @@ -38,6 +38,18 @@ frappe.query_reports["Gross Profit"] = { "options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term", "default": "Invoice" }, + { + "fieldname":"item_group", + "label": __("Item Group"), + "fieldtype": "Link", + "options": "Item Group" + }, + { + "fieldname":"sales_person", + "label": __("Sales Person"), + "fieldtype": "Link", + "options": "Sales Person" + }, ], "tree": true, "name_field": "parent", diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 526ea9d6e2..264fcd3fcb 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -8,6 +8,7 @@ from frappe.utils import cint, flt, formatdate from erpnext.controllers.queries import get_match_cond from erpnext.stock.utils import get_incoming_rate +from erpnext.stock.report.stock_ledger.stock_ledger import get_item_group_condition def execute(filters=None): @@ -676,6 +677,17 @@ class GrossProfitGenerator(object): if self.filters.to_date: conditions += " and posting_date <= %(to_date)s" + if self.filters.item_group: + conditions += " and {0}".format(get_item_group_condition(self.filters.item_group)) + + if self.filters.sales_person: + conditions += """ + and exists(select 1 + from `tabSales Team` st + where st.parent = `tabSales Invoice`.name + and st.sales_person = %(sales_person)s) + """ + if self.filters.group_by == "Sales Person": sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives" sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name" @@ -723,6 +735,7 @@ class GrossProfitGenerator(object): from `tabSales Invoice` inner join `tabSales Invoice Item` on `tabSales Invoice Item`.parent = `tabSales Invoice`.name + join `tabItem` item on item.name = `tabSales Invoice Item`.item_code {sales_team_table} {payment_term_table} where From 3ef551872a38c059e8ca09927c7bea44635c9474 Mon Sep 17 00:00:00 2001 From: hrzzz Date: Mon, 15 Aug 2022 09:23:56 -0300 Subject: [PATCH 04/72] fix: remove spaces and order import --- erpnext/accounts/report/gross_profit/gross_profit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 264fcd3fcb..74cface4ef 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -7,8 +7,8 @@ from frappe import _, scrub from frappe.utils import cint, flt, formatdate from erpnext.controllers.queries import get_match_cond -from erpnext.stock.utils import get_incoming_rate from erpnext.stock.report.stock_ledger.stock_ledger import get_item_group_condition +from erpnext.stock.utils import get_incoming_rate def execute(filters=None): @@ -681,9 +681,9 @@ class GrossProfitGenerator(object): conditions += " and {0}".format(get_item_group_condition(self.filters.item_group)) if self.filters.sales_person: - conditions += """ - and exists(select 1 - from `tabSales Team` st + conditions += """ + and exists(select 1 + from `tabSales Team` st where st.parent = `tabSales Invoice`.name and st.sales_person = %(sales_person)s) """ From 520306dc8751ab39cee7675a481b00e6dfeaa1b0 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Sun, 21 Aug 2022 12:09:08 +0530 Subject: [PATCH 05/72] fix: Add docstatus filter for voucher_no in Repost Item Valuation --- .../doctype/repost_item_valuation/repost_item_valuation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js index d6e00eada7..eae73050b2 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js @@ -24,7 +24,8 @@ frappe.ui.form.on('Repost Item Valuation', { frm.set_query("voucher_no", () => { return { filters: { - company: frm.doc.company + company: frm.doc.company, + docstatus: 1 } }; }); From 3b15966cc9fb2cf91eca9105f767d8775845f7fa Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 21 Aug 2022 17:51:05 +0530 Subject: [PATCH 06/72] fix: Cash and non trade discount calculation --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 2 +- .../doctype/sales_invoice/sales_invoice.js | 4 ++ .../doctype/sales_invoice/sales_invoice.py | 16 ------- erpnext/controllers/accounts_controller.py | 46 ++++++++++--------- erpnext/controllers/taxes_and_totals.py | 16 ++++--- .../public/js/controllers/taxes_and_totals.js | 10 ++++ 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 1987c8340d..7227b95818 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -366,7 +366,7 @@ def update_outstanding_amt( if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]: ref_doc = frappe.get_doc(against_voucher_type, against_voucher) - # Didn't use db_set for optimisation purpose + # Didn't use db_set for optimization purpose ref_doc.outstanding_amount = bal frappe.db.set_value(against_voucher_type, against_voucher, "outstanding_amount", bal) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index adcbb83e8d..73ec051c6d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -479,9 +479,13 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e is_cash_or_non_trade_discount() { this.frm.set_df_property("additional_discount_account", "hidden", 1 - this.frm.doc.is_cash_or_non_trade_discount); + this.frm.set_df_property("additional_discount_account", "reqd", this.frm.doc.is_cash_or_non_trade_discount); + if (!this.frm.doc.is_cash_or_non_trade_discount) { this.frm.set_value("additional_discount_account", ""); } + + this.calculate_taxes_and_totals(); } }; diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 19a234d9df..4008863e9b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1033,22 +1033,6 @@ class SalesInvoice(SellingController): ) ) - if self.apply_discount_on == "Grand Total" and self.get("is_cash_or_discount_account"): - gl_entries.append( - self.get_gl_dict( - { - "account": self.additional_discount_account, - "against": self.debit_to, - "debit": self.base_discount_amount, - "debit_in_account_currency": self.discount_amount, - "cost_center": self.cost_center, - "project": self.project, - }, - self.currency, - item=self, - ) - ) - def make_tax_gl_entries(self, gl_entries): enable_discount_accounting = cint( frappe.db.get_single_value("Selling Settings", "enable_discount_accounting") diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 70d2bc68a1..28070d2377 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1109,17 +1109,17 @@ class AccountsController(TransactionBase): frappe.db.get_single_value("Selling Settings", "enable_discount_accounting") ) + if self.doctype == "Purchase Invoice": + dr_or_cr = "credit" + rev_dr_cr = "debit" + supplier_or_customer = self.supplier + + else: + dr_or_cr = "debit" + rev_dr_cr = "credit" + supplier_or_customer = self.customer + if enable_discount_accounting: - if self.doctype == "Purchase Invoice": - dr_or_cr = "credit" - rev_dr_cr = "debit" - supplier_or_customer = self.supplier - - else: - dr_or_cr = "debit" - rev_dr_cr = "credit" - supplier_or_customer = self.customer - for item in self.get("items"): if item.get("discount_amount") and item.get("discount_account"): discount_amount = item.discount_amount * item.qty @@ -1173,18 +1173,22 @@ class AccountsController(TransactionBase): ) ) - if self.get("discount_amount") and self.get("additional_discount_account"): - gl_entries.append( - self.get_gl_dict( - { - "account": self.additional_discount_account, - "against": supplier_or_customer, - dr_or_cr: self.discount_amount, - "cost_center": self.cost_center, - }, - item=self, - ) + if ( + (enable_discount_accounting or self.is_cash_or_non_trade_discount) + and self.get("additional_discount_account") + and self.get("discount_amount") + ): + gl_entries.append( + self.get_gl_dict( + { + "account": self.additional_discount_account, + "against": supplier_or_customer, + dr_or_cr: self.discount_amount, + "cost_center": self.cost_center, + }, + item=self, ) + ) def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield): from erpnext.controllers.status_updater import get_allowance_for diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 0d8cffe03f..bc38d08b80 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -37,6 +37,11 @@ class calculate_taxes_and_totals(object): self.set_discount_amount() self.apply_discount_amount() + # Update grand total as per cash and non trade discount + if self.doc.apply_discount_on == "Grand Total" and self.doc.get("is_cash_or_non_trade_discount"): + self.doc.grand_total -= self.doc.discount_amount + self.doc.base_grand_total -= self.doc.base_discount_amount + self.calculate_shipping_charges() if self.doc.doctype in ["Sales Invoice", "Purchase Invoice"]: @@ -500,9 +505,6 @@ class calculate_taxes_and_totals(object): else: self.doc.grand_total = flt(self.doc.net_total) - if self.doc.apply_discount_on == "Grand Total" and self.doc.get("is_cash_or_non_trade_discount"): - self.doc.grand_total -= self.doc.discount_amount - if self.doc.get("taxes"): self.doc.total_taxes_and_charges = flt( self.doc.grand_total - self.doc.net_total - flt(self.doc.rounding_adjustment), @@ -597,16 +599,16 @@ class calculate_taxes_and_totals(object): if not self.doc.apply_discount_on: frappe.throw(_("Please select Apply Discount On")) + self.doc.base_discount_amount = flt( + self.doc.discount_amount * self.doc.conversion_rate, self.doc.precision("base_discount_amount") + ) + if self.doc.apply_discount_on == "Grand Total" and self.doc.get( "is_cash_or_non_trade_discount" ): self.discount_amount_applied = True return - self.doc.base_discount_amount = flt( - self.doc.discount_amount * self.doc.conversion_rate, self.doc.precision("base_discount_amount") - ) - total_for_discount_amount = self.get_total_for_discount_amount() taxes = self.doc.get("taxes") net_total = 0 diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 16b0b4a866..3b9e23a3f5 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -39,6 +39,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { this._calculate_taxes_and_totals(); this.calculate_discount_amount(); + // # Update grand total as per cash and non trade discount + if (this.frm.doc.apply_discount_on == "Grand Total" && this.frm.doc.is_cash_or_non_trade_discount) { + this.frm.doc.grand_total -= this.frm.doc.discount_amount; + this.frm.doc.base_grand_total -= this.frm.doc.base_discount_amount; + } + await this.calculate_shipping_charges(); // Advance calculation applicable to Sales /Purchase Invoice @@ -633,6 +639,10 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { this.frm.doc.base_discount_amount = flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount")); + if (this.frm.doc.apply_discount_on == "Grand Total" && this.frm.doc.is_cash_or_non_trade_discount) { + return + } + var total_for_discount_amount = this.get_total_for_discount_amount(); var net_total = 0; // calculate item amount after Discount Amount From ae3dce0cbdca40294739b547d85bfca9b1e28c0f Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 22 Aug 2022 08:57:58 +0530 Subject: [PATCH 07/72] fix: Test cases --- erpnext/controllers/accounts_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 28070d2377..e689d567a1 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1174,7 +1174,7 @@ class AccountsController(TransactionBase): ) if ( - (enable_discount_accounting or self.is_cash_or_non_trade_discount) + (enable_discount_accounting or self.get("is_cash_or_non_trade_discount")) and self.get("additional_discount_account") and self.get("discount_amount") ): From 42de9ca49e6d615b58494930d7373327ce81a2d2 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Fri, 19 Aug 2022 12:30:47 +0530 Subject: [PATCH 08/72] fix: TDS calculation for advance payment "against_voucher": ["is", "not set"] was used in query due to which if TDS was added on "advance" payment vouchers and then reconciled against purchase invoice. it will not find those vouchers and consider this as first-time threshold due to which it will calculate Tax for all transactions. (cherry picked from commit a4521437825a960e14556fa3963bd1bd1a55a2dc) --- .../doctype/tax_withholding_category/tax_withholding_category.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index a519d8be73..6004e2b19b 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -318,7 +318,6 @@ def get_advance_vouchers( "is_cancelled": 0, "party_type": party_type, "party": ["in", parties], - "against_voucher": ["is", "not set"], } if company: From bf5c43322a2fdf299a031ee2b864f5da0d9e15a9 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Mon, 22 Aug 2022 18:36:42 +0530 Subject: [PATCH 09/72] fix: don't allow to create SCR directly (#31924) --- .../doctype/subcontracting_receipt/subcontracting_receipt.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json index 872d18e15e..84e95548e1 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json @@ -625,9 +625,10 @@ "print_hide": 1 } ], + "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2022-08-19 19:50:16.935124", + "modified": "2022-08-22 17:30:40.827517", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt", From 1cb7ae16ab156da2fd43ec915316947b0b8db964 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 23 Aug 2022 09:12:20 +0530 Subject: [PATCH 10/72] chore: Linting issues --- erpnext/public/js/controllers/taxes_and_totals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 3b9e23a3f5..4c3e9dcf0a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -640,7 +640,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { precision("base_discount_amount")); if (this.frm.doc.apply_discount_on == "Grand Total" && this.frm.doc.is_cash_or_non_trade_discount) { - return + return; } var total_for_discount_amount = this.get_total_for_discount_amount(); From a956e20f294a5d66d6589c479398eefc632eff43 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 23 Aug 2022 11:36:00 +0530 Subject: [PATCH 11/72] refactor: disable discount accounting on Buying module(PI) --- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index de3927e45b..1d2a5d6c27 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -575,7 +575,6 @@ class PurchaseInvoice(BuyingController): self.make_supplier_gl_entry(gl_entries) self.make_item_gl_entries(gl_entries) - self.make_discount_gl_entries(gl_entries) if self.check_asset_cwip_enabled(): self.get_asset_gl_entry(gl_entries) @@ -807,7 +806,7 @@ class PurchaseInvoice(BuyingController): ) if not item.is_fixed_asset: - dummy, amount = self.get_amount_and_base_amount(item, enable_discount_accounting) + dummy, amount = self.get_amount_and_base_amount(item, None) else: amount = flt(item.base_net_amount + item.item_tax_amount, item.precision("base_net_amount")) @@ -1165,7 +1164,7 @@ class PurchaseInvoice(BuyingController): ) for tax in self.get("taxes"): - amount, base_amount = self.get_tax_amounts(tax, enable_discount_accounting) + amount, base_amount = self.get_tax_amounts(tax, None) if tax.category in ("Total", "Valuation and Total") and flt(base_amount): account_currency = get_account_currency(tax.account_head) From 277ef04b600412fa8cc60abc90ba254c35b2ecf6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 23 Aug 2022 15:17:27 +0530 Subject: [PATCH 12/72] test: remove discount accounting tests --- .../purchase_invoice/test_purchase_invoice.py | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index e55d3a70af..0a4f25b876 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -338,59 +338,6 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin): self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount) - @change_settings("Buying Settings", {"enable_discount_accounting": 1}) - def test_purchase_invoice_with_discount_accounting_enabled(self): - - discount_account = create_account( - account_name="Discount Account", - parent_account="Indirect Expenses - _TC", - company="_Test Company", - ) - pi = make_purchase_invoice(discount_account=discount_account, rate=45) - - expected_gle = [ - ["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()], - ["Creditors - _TC", 0.0, 225.0, nowdate()], - ["Discount Account - _TC", 0.0, 25.0, nowdate()], - ] - - check_gl_entries(self, pi.name, expected_gle, nowdate()) - - @change_settings("Buying Settings", {"enable_discount_accounting": 1}) - def test_additional_discount_for_purchase_invoice_with_discount_accounting_enabled(self): - - additional_discount_account = create_account( - account_name="Discount Account", - parent_account="Indirect Expenses - _TC", - company="_Test Company", - ) - - pi = make_purchase_invoice(do_not_save=1, parent_cost_center="Main - _TC") - pi.apply_discount_on = "Grand Total" - pi.additional_discount_account = additional_discount_account - pi.additional_discount_percentage = 10 - pi.disable_rounded_total = 1 - pi.append( - "taxes", - { - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "Main - _TC", - "description": "Test", - "rate": 10, - }, - ) - pi.submit() - - expected_gle = [ - ["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()], - ["_Test Account VAT - _TC", 25.0, 0.0, nowdate()], - ["Creditors - _TC", 0.0, 247.5, nowdate()], - ["Discount Account - _TC", 0.0, 27.5, nowdate()], - ] - - check_gl_entries(self, pi.name, expected_gle, nowdate()) - def test_purchase_invoice_change_naming_series(self): pi = frappe.copy_doc(test_records[1]) pi.insert() From fe73d55f702163386e413b61dd504f93a8e8479c Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Tue, 23 Aug 2022 12:37:10 +0200 Subject: [PATCH 13/72] chore: add Work Order test dependencies (#31936) --- erpnext/manufacturing/doctype/work_order/test_work_order.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py index b556d9974a..a53c42c5ec 100644 --- a/erpnext/manufacturing/doctype/work_order/test_work_order.py +++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py @@ -26,6 +26,8 @@ from erpnext.stock.doctype.stock_entry import test_stock_entry from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse from erpnext.stock.utils import get_bin +test_dependencies = ["BOM"] + class TestWorkOrder(FrappeTestCase): def setUp(self): From fdd167cac123a6f2fea11ccdd73f3b12a65f2f8d Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Aug 2022 12:24:55 +0530 Subject: [PATCH 14/72] fix: include payment against PO in AR/AP report --- .../report/accounts_receivable/accounts_receivable.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index e937edbeb2..eb2959e197 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -178,6 +178,11 @@ class ReceivablePayableReport(object): key = (ple.against_voucher_type, ple.against_voucher_no, ple.party) row = self.voucher_balance.get(key) + + if not row: + # no invoice, this is an invoice / stand-alone payment / credit note + row = self.voucher_balance.get((ple.voucher_type, ple.voucher_no, ple.party)) + return row def update_voucher_balance(self, ple): From b4a2eb2e65b0706ba7483215040855297b9b9ff8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 Aug 2022 12:29:15 +0530 Subject: [PATCH 15/72] fix: gl entries for asset repair --- erpnext/assets/doctype/asset/test_asset.py | 14 +- .../doctype/asset_repair/asset_repair.js | 2 +- .../doctype/asset_repair/asset_repair.json | 6 +- .../doctype/asset_repair/asset_repair.py | 146 +++++++++++------- .../doctype/asset_repair/test_asset_repair.py | 122 ++++++++++++++- erpnext/setup/doctype/company/company.json | 10 +- 6 files changed, 222 insertions(+), 78 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 986b7001ff..132840e38c 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -1454,12 +1454,14 @@ def create_fixed_asset_item(item_code=None, auto_create_assets=1, is_grouped_ass return item -def set_depreciation_settings_in_company(): - company = frappe.get_doc("Company", "_Test Company") - company.accumulated_depreciation_account = "_Test Accumulated Depreciations - _TC" - company.depreciation_expense_account = "_Test Depreciations - _TC" - company.disposal_account = "_Test Gain/Loss on Asset Disposal - _TC" - company.depreciation_cost_center = "_Test Cost Center - _TC" +def set_depreciation_settings_in_company(company=None): + if not company: + company = "_Test Company" + company = frappe.get_doc("Company", company) + company.accumulated_depreciation_account = "_Test Accumulated Depreciations - " + company.abbr + company.depreciation_expense_account = "_Test Depreciations - " + company.abbr + company.disposal_account = "_Test Gain/Loss on Asset Disposal - " + company.abbr + company.depreciation_cost_center = "Main - " + company.abbr company.save() # Enable booking asset depreciation entry automatically diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js index f5e4e723b4..f9ed2cc344 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.js +++ b/erpnext/assets/doctype/asset_repair/asset_repair.js @@ -76,7 +76,7 @@ frappe.ui.form.on('Asset Repair Consumed Item', { 'warehouse': frm.doc.warehouse, 'qty': item.consumed_quantity, 'serial_no': item.serial_no, - 'company': frm.doc.company + 'company': frm.doc.company, }; frappe.call({ diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.json b/erpnext/assets/doctype/asset_repair/asset_repair.json index ba3189887c..accb5bf54b 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.json +++ b/erpnext/assets/doctype/asset_repair/asset_repair.json @@ -238,7 +238,6 @@ "no_copy": 1 }, { - "depends_on": "eval:!doc.__islocal", "fieldname": "purchase_invoice", "fieldtype": "Link", "label": "Purchase Invoice", @@ -257,6 +256,7 @@ "fieldname": "stock_entry", "fieldtype": "Link", "label": "Stock Entry", + "no_copy": 1, "options": "Stock Entry", "read_only": 1 } @@ -264,10 +264,11 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2021-06-25 13:14:38.307723", + "modified": "2022-08-16 15:55:25.023471", "modified_by": "Administrator", "module": "Assets", "name": "Asset Repair", + "naming_rule": "By \"Naming Series\" field", "owner": "Administrator", "permissions": [ { @@ -303,6 +304,7 @@ ], "sort_field": "modified", "sort_order": "DESC", + "states": [], "title_field": "asset_name", "track_changes": 1, "track_seen": 1 diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 5bf6011cf8..b4316ced62 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -1,11 +1,11 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt - import frappe from frappe import _ from frappe.utils import add_months, cint, flt, getdate, time_diff_in_hours +import erpnext from erpnext.accounts.general_ledger import make_gl_entries from erpnext.assets.doctype.asset.asset import get_asset_account from erpnext.controllers.accounts_controller import AccountsController @@ -17,7 +17,7 @@ class AssetRepair(AccountsController): self.update_status() if self.get("stock_items"): - self.set_total_value() + self.set_stock_items_cost() self.calculate_total_repair_cost() def update_status(self): @@ -26,7 +26,7 @@ class AssetRepair(AccountsController): else: self.asset_doc.set_status() - def set_total_value(self): + def set_stock_items_cost(self): for item in self.get("stock_items"): item.total_value = flt(item.valuation_rate) * flt(item.consumed_quantity) @@ -66,6 +66,7 @@ class AssetRepair(AccountsController): if self.get("capitalize_repair_cost"): self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry") self.make_gl_entries(cancel=True) + self.db_set("stock_entry", None) if ( frappe.db.get_value("Asset", self.asset, "calculate_depreciation") and self.increase_in_asset_life @@ -133,6 +134,7 @@ class AssetRepair(AccountsController): "qty": stock_item.consumed_quantity, "basic_rate": stock_item.valuation_rate, "serial_no": stock_item.serial_no, + "cost_center": self.cost_center, }, ) @@ -142,72 +144,42 @@ class AssetRepair(AccountsController): self.db_set("stock_entry", stock_entry.name) def increase_stock_quantity(self): - stock_entry = frappe.get_doc("Stock Entry", self.stock_entry) - stock_entry.flags.ignore_links = True - stock_entry.cancel() + if self.stock_entry: + stock_entry = frappe.get_doc("Stock Entry", self.stock_entry) + stock_entry.flags.ignore_links = True + stock_entry.cancel() def make_gl_entries(self, cancel=False): - if flt(self.repair_cost) > 0: + if flt(self.total_repair_cost) > 0: gl_entries = self.get_gl_entries() make_gl_entries(gl_entries, cancel) def get_gl_entries(self): gl_entries = [] - repair_and_maintenance_account = frappe.db.get_value( - "Company", self.company, "repair_and_maintenance_account" - ) + fixed_asset_account = get_asset_account( "fixed_asset_account", asset=self.asset, company=self.company ) - expense_account = ( + self.get_gl_entries_for_repair_cost(gl_entries, fixed_asset_account) + self.get_gl_entries_for_consumed_items(gl_entries, fixed_asset_account) + + return gl_entries + + def get_gl_entries_for_repair_cost(self, gl_entries, fixed_asset_account): + if flt(self.repair_cost) <= 0: + return + + pi_expense_account = ( frappe.get_doc("Purchase Invoice", self.purchase_invoice).items[0].expense_account ) - gl_entries.append( - self.get_gl_dict( - { - "account": expense_account, - "credit": self.repair_cost, - "credit_in_account_currency": self.repair_cost, - "against": repair_and_maintenance_account, - "voucher_type": self.doctype, - "voucher_no": self.name, - "cost_center": self.cost_center, - "posting_date": getdate(), - "company": self.company, - }, - item=self, - ) - ) - - if self.get("stock_consumption"): - # creating GL Entries for each row in Stock Items based on the Stock Entry created for it - stock_entry = frappe.get_doc("Stock Entry", self.stock_entry) - for item in stock_entry.items: - gl_entries.append( - self.get_gl_dict( - { - "account": item.expense_account, - "credit": item.amount, - "credit_in_account_currency": item.amount, - "against": repair_and_maintenance_account, - "voucher_type": self.doctype, - "voucher_no": self.name, - "cost_center": self.cost_center, - "posting_date": getdate(), - "company": self.company, - }, - item=self, - ) - ) - gl_entries.append( self.get_gl_dict( { "account": fixed_asset_account, - "debit": self.total_repair_cost, - "debit_in_account_currency": self.total_repair_cost, - "against": expense_account, + "debit": self.repair_cost, + "debit_in_account_currency": self.repair_cost, + "against": pi_expense_account, "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, @@ -220,7 +192,75 @@ class AssetRepair(AccountsController): ) ) - return gl_entries + gl_entries.append( + self.get_gl_dict( + { + "account": pi_expense_account, + "credit": self.repair_cost, + "credit_in_account_currency": self.repair_cost, + "against": fixed_asset_account, + "voucher_type": self.doctype, + "voucher_no": self.name, + "cost_center": self.cost_center, + "posting_date": getdate(), + "company": self.company, + }, + item=self, + ) + ) + + def get_gl_entries_for_consumed_items(self, gl_entries, fixed_asset_account): + if not (self.get("stock_consumption") and self.get("stock_items")): + return + + # creating GL Entries for each row in Stock Items based on the Stock Entry created for it + stock_entry = frappe.get_doc("Stock Entry", self.stock_entry) + + default_expense_account = None + if not erpnext.is_perpetual_inventory_enabled(self.company): + default_expense_account = frappe.get_cached_value( + "Company", self.company, "default_expense_account" + ) + if not default_expense_account: + frappe.throw(_("Please set default Expense Account in Company {0}").format(self.company)) + + for item in stock_entry.items: + if flt(item.amount) > 0: + gl_entries.append( + self.get_gl_dict( + { + "account": item.expense_account or default_expense_account, + "credit": item.amount, + "credit_in_account_currency": item.amount, + "against": fixed_asset_account, + "voucher_type": self.doctype, + "voucher_no": self.name, + "cost_center": self.cost_center, + "posting_date": getdate(), + "company": self.company, + }, + item=self, + ) + ) + + gl_entries.append( + self.get_gl_dict( + { + "account": fixed_asset_account, + "debit": item.amount, + "debit_in_account_currency": item.amount, + "against": item.expense_account, + "voucher_type": self.doctype, + "voucher_no": self.name, + "cost_center": self.cost_center, + "posting_date": getdate(), + "against_voucher_type": "Stock Entry", + "against_voucher": self.stock_entry, + "company": self.company, + }, + item=self, + ) + ) def modify_depreciation_schedule(self): for row in self.asset_doc.finance_books: diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index 4e7cf78090..6e06f52ac6 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -6,6 +6,7 @@ import unittest import frappe from frappe.utils import flt, nowdate +from erpnext.assets.doctype.asset.asset import get_asset_account from erpnext.assets.doctype.asset.test_asset import ( create_asset, create_asset_data, @@ -125,10 +126,109 @@ class TestAssetRepair(unittest.TestCase): asset_repair = create_asset_repair(capitalize_repair_cost=1, submit=1) self.assertTrue(asset_repair.purchase_invoice) - def test_gl_entries(self): - asset_repair = create_asset_repair(capitalize_repair_cost=1, submit=1) - gl_entry = frappe.get_last_doc("GL Entry") - self.assertEqual(asset_repair.name, gl_entry.voucher_no) + def test_gl_entries_with_perpetual_inventory(self): + set_depreciation_settings_in_company(company="_Test Company with perpetual inventory") + + asset_category = frappe.get_doc("Asset Category", "Computers") + asset_category.append( + "accounts", + { + "company_name": "_Test Company with perpetual inventory", + "fixed_asset_account": "_Test Fixed Asset - TCP1", + "accumulated_depreciation_account": "_Test Accumulated Depreciations - TCP1", + "depreciation_expense_account": "_Test Depreciations - TCP1", + }, + ) + asset_category.save() + + asset_repair = create_asset_repair( + capitalize_repair_cost=1, + stock_consumption=1, + warehouse="Stores - TCP1", + company="_Test Company with perpetual inventory", + submit=1, + ) + + gl_entries = frappe.db.sql( + """ + select + account, + sum(debit) as debit, + sum(credit) as credit + from `tabGL Entry` + where + voucher_type='Asset Repair' + and voucher_no=%s + group by + account + """, + asset_repair.name, + as_dict=1, + ) + + self.assertTrue(gl_entries) + + fixed_asset_account = get_asset_account( + "fixed_asset_account", asset=asset_repair.asset, company=asset_repair.company + ) + pi_expense_account = ( + frappe.get_doc("Purchase Invoice", asset_repair.purchase_invoice).items[0].expense_account + ) + stock_entry_expense_account = ( + frappe.get_doc("Stock Entry", asset_repair.stock_entry).get("items")[0].expense_account + ) + + expected_values = { + fixed_asset_account: [asset_repair.total_repair_cost, 0], + pi_expense_account: [0, asset_repair.repair_cost], + stock_entry_expense_account: [0, 100], + } + + for d in gl_entries: + self.assertEqual(expected_values[d.account][0], d.debit) + self.assertEqual(expected_values[d.account][1], d.credit) + + def test_gl_entries_with_periodical_inventory(self): + frappe.db.set_value( + "Company", "_Test Company", "default_expense_account", "Cost of Goods Sold - _TC" + ) + asset_repair = create_asset_repair( + capitalize_repair_cost=1, + stock_consumption=1, + submit=1, + ) + + gl_entries = frappe.db.sql( + """ + select + account, + sum(debit) as debit, + sum(credit) as credit + from `tabGL Entry` + where + voucher_type='Asset Repair' + and voucher_no=%s + group by + account + """, + asset_repair.name, + as_dict=1, + ) + + self.assertTrue(gl_entries) + + fixed_asset_account = get_asset_account( + "fixed_asset_account", asset=asset_repair.asset, company=asset_repair.company + ) + default_expense_account = frappe.get_cached_value( + "Company", asset_repair.company, "default_expense_account" + ) + + expected_values = {fixed_asset_account: [1100, 0], default_expense_account: [0, 1100]} + + for d in gl_entries: + self.assertEqual(expected_values[d.account][0], d.debit) + self.assertEqual(expected_values[d.account][1], d.credit) def test_increase_in_asset_life(self): asset = create_asset(calculate_depreciation=1, submit=1) @@ -160,7 +260,7 @@ def create_asset_repair(**args): if args.asset: asset = args.asset else: - asset = create_asset(is_existing_asset=1, submit=1) + asset = create_asset(is_existing_asset=1, submit=1, company=args.company) asset_repair = frappe.new_doc("Asset Repair") asset_repair.update( { @@ -192,7 +292,7 @@ def create_asset_repair(**args): if args.submit: asset_repair.repair_status = "Completed" - asset_repair.cost_center = "_Test Cost Center - _TC" + asset_repair.cost_center = frappe.db.get_value("Company", asset.company, "cost_center") if args.stock_consumption: stock_entry = frappe.get_doc( @@ -204,6 +304,8 @@ def create_asset_repair(**args): "t_warehouse": asset_repair.warehouse, "item_code": asset_repair.stock_items[0].item_code, "qty": asset_repair.stock_items[0].consumed_quantity, + "basic_rate": args.rate if args.get("rate") is not None else 100, + "cost_center": asset_repair.cost_center, }, ) stock_entry.submit() @@ -213,7 +315,13 @@ def create_asset_repair(**args): asset_repair.repair_cost = 1000 if asset.calculate_depreciation: asset_repair.increase_in_asset_life = 12 - asset_repair.purchase_invoice = make_purchase_invoice().name + pi = make_purchase_invoice( + company=asset.company, + expense_account=frappe.db.get_value("Company", asset.company, "default_expense_account"), + cost_center=asset_repair.cost_center, + warehouse=asset_repair.warehouse, + ) + asset_repair.purchase_invoice = pi.name asset_repair.submit() return asset_repair diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index f34ec56dc0..f087d996ff 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -85,7 +85,6 @@ "depreciation_expense_account", "series_for_depreciation_entry", "expenses_included_in_asset_valuation", - "repair_and_maintenance_account", "column_break_40", "disposal_account", "depreciation_cost_center", @@ -234,7 +233,6 @@ "label": "Default Warehouse for Sales Return", "options": "Warehouse" }, - { "fieldname": "country", "fieldtype": "Link", @@ -678,12 +676,6 @@ "fieldtype": "Section Break", "label": "Fixed Asset Defaults" }, - { - "fieldname": "repair_and_maintenance_account", - "fieldtype": "Link", - "label": "Repair and Maintenance Account", - "options": "Account" - }, { "fieldname": "section_break_28", "fieldtype": "Section Break", @@ -709,7 +701,7 @@ "image_field": "company_logo", "is_tree": 1, "links": [], - "modified": "2022-06-30 18:03:18.701314", + "modified": "2022-08-16 16:09:02.327724", "modified_by": "Administrator", "module": "Setup", "name": "Company", From 0e26df331c2358a9683f2e59b9b0ed3bfccad61e Mon Sep 17 00:00:00 2001 From: Solufyin <34390782+Solufyin@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:28:55 +0530 Subject: [PATCH 16/72] fix: Route condition set for stock ledger (#31935) --- erpnext/stock/doctype/item/item_dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/item/item_dashboard.py b/erpnext/stock/doctype/item/item_dashboard.py index 897acb7448..34bb4d1225 100644 --- a/erpnext/stock/doctype/item/item_dashboard.py +++ b/erpnext/stock/doctype/item/item_dashboard.py @@ -5,7 +5,7 @@ def get_data(): return { "heatmap": True, "heatmap_message": _("This is based on stock movement. See {0} for details").format( - '' + _("Stock Ledger") + "" + '' + _("Stock Ledger") + "" ), "fieldname": "item_code", "non_standard_fieldnames": { From 36f5883ddaf2b2215123d0b06f7b3965b27696c5 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Aug 2022 13:58:11 +0530 Subject: [PATCH 17/72] test: payments against so/po will show up as outstanding amount 1. Class will use FrappeTestCase fixture 2. setup and teardown methods are introduced 3. test for payments against SO --- .../test_accounts_receivable.py | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index edddbbce21..bac8beed2e 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -1,19 +1,27 @@ import unittest import frappe +from frappe.tests.utils import FrappeTestCase from frappe.utils import add_days, getdate, today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.accounts.report.accounts_receivable.accounts_receivable import execute +from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -class TestAccountsReceivable(unittest.TestCase): - def test_accounts_receivable(self): +class TestAccountsReceivable(FrappeTestCase): + def setUp(self): frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company 2'") + frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'") + frappe.db.sql("delete from `tabPayment Entry` where company='_Test Company 2'") frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 2'") frappe.db.sql("delete from `tabPayment Ledger Entry` where company='_Test Company 2'") + def tearDown(self): + frappe.db.rollback() + + def test_accounts_receivable(self): filters = { "company": "_Test Company 2", "based_on_payment_terms": 1, @@ -66,6 +74,50 @@ class TestAccountsReceivable(unittest.TestCase): ], ) + def test_payment_againt_po_in_receivable_report(self): + """ + Payments made against Purchase Order will show up as outstanding amount + """ + + so = make_sales_order( + company="_Test Company 2", + customer="_Test Customer 2", + warehouse="Finished Goods - _TC2", + currency="EUR", + debit_to="Debtors - _TC2", + income_account="Sales - _TC2", + expense_account="Cost of Goods Sold - _TC2", + cost_center="Main - _TC2", + ) + + pe = get_payment_entry(so.doctype, so.name) + pe = pe.save().submit() + + filters = { + "company": "_Test Company 2", + "based_on_payment_terms": 0, + "report_date": today(), + "range1": 30, + "range2": 60, + "range3": 90, + "range4": 120, + } + + report = execute(filters) + + expected_data_after_payment = [0, 1000, 0, -1000] + + row = report[1][0] + self.assertEqual( + expected_data_after_payment, + [ + row.invoiced, + row.paid, + row.credit_note, + row.outstanding, + ], + ) + def make_sales_invoice(): frappe.set_user("Administrator") From f9a7b31b5b39da7f3e12ad8274330dafda6ce2a8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 24 Aug 2022 17:16:01 +0530 Subject: [PATCH 18/72] fix: Purposes not set --- .../doctype/maintenance_schedule/maintenance_schedule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py index 09d4429712..3dc6b0f900 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py @@ -415,7 +415,7 @@ def make_maintenance_visit(source_name, target_doc=None, item_name=None, s_id=No }, "Maintenance Schedule Item": { "doctype": "Maintenance Visit Purpose", - "condition": lambda doc: doc.item_name == item_name, + "condition": lambda doc: doc.item_name == item_name if item_name else True, "field_map": {"sales_person": "service_person"}, "postprocess": update_serial, }, From 122f1c0cedf583451e85eb68093ede6f0ede43e4 Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Wed, 24 Aug 2022 18:24:39 +0530 Subject: [PATCH 19/72] fix: Explicitly commit "log_error" since its getting called during GET request (#31952) --- erpnext/erpnext_integrations/exotel_integration.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py index fd9f74e8c9..fd0f783575 100644 --- a/erpnext/erpnext_integrations/exotel_integration.py +++ b/erpnext/erpnext_integrations/exotel_integration.py @@ -26,6 +26,7 @@ def handle_incoming_call(**kwargs): except Exception as e: frappe.db.rollback() exotel_settings.log_error("Error in Exotel incoming call") + frappe.db.commit() @frappe.whitelist(allow_guest=True) From 264f98af140cb8b73c417ef18bca16b838926927 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 24 Aug 2022 15:52:00 +0200 Subject: [PATCH 20/72] chore: update french translation --- erpnext/translations/fr.csv | 104 +++++++++++++++++------------------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/erpnext/translations/fr.csv b/erpnext/translations/fr.csv index dbc319476b..1869411a1f 100644 --- a/erpnext/translations/fr.csv +++ b/erpnext/translations/fr.csv @@ -329,11 +329,11 @@ Average Rate,Prix moyen, Avg Daily Outgoing,Moy Quotidienne Sortante, Avg. Buying Price List Rate,Moyenne de la liste de prix d'achat, Avg. Selling Price List Rate,Prix moyen de la liste de prix de vente, -Avg. Selling Rate,Moy. Taux de vente, +Avg. Selling Rate,Moy. prix de vente, BOM,Nomenclature, BOM Browser,Explorateur Nomenclature, BOM No,N° Nomenclature, -BOM Rate,Valeur nomenclature, +BOM Rate,Cout nomenclature, BOM Stock Report,Rapport de Stock des nomenclatures, BOM and Manufacturing Quantity are required,Nomenclature et quantité de production sont nécessaires, BOM does not contain any stock item,Nomenclature ne contient aucun article en stock, @@ -561,9 +561,9 @@ Colour,Couleur, Combined invoice portion must equal 100%,La portion combinée de la facture doit être égale à 100%, Commercial,Commercial, Commission,Commission, -Commission Rate %,Taux de commission%, +Commission Rate %,Pourcentage de commission, Commission on Sales,Commission sur les ventes, -Commission rate cannot be greater than 100,Taux de commission ne peut pas être supérieure à 100, +Commission rate cannot be greater than 100,Pourcentage de commission ne peut pas être supérieure à 100, Community Forum,Forum de la communauté, Company (not Customer or Supplier) master.,Données de base de la Société (ni les Clients ni les Fournisseurs), Company Abbreviation,Abréviation de la Société, @@ -1072,7 +1072,7 @@ For Warehouse is required before Submit,Pour l’Entrepôt est requis avant de V "For an item {0}, quantity must be negative number","Pour l'article {0}, la quantité doit être un nombre négatif", "For an item {0}, quantity must be positive number","Pour un article {0}, la quantité doit être un nombre positif", "For job card {0}, you can only make the 'Material Transfer for Manufacture' type stock entry","Pour la carte de travail {0}, vous pouvez uniquement saisir une entrée de stock de type "Transfert d'article pour fabrication".", -"For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included","Pour la ligne {0} dans {1}. Pour inclure {2} dans le prix de l'Article, les lignes {3} doivent également être incluses", +"For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included","Pour la ligne {0} dans {1}. Pour inclure {2} dans le prix de l'article, les lignes {3} doivent également être incluses", For row {0}: Enter Planned Qty,Pour la ligne {0}: entrez la quantité planifiée, "For {0}, only credit accounts can be linked against another debit entry","Pour {0}, seuls les comptes de crédit peuvent être liés avec une autre écriture de débit", "For {0}, only debit accounts can be linked against another credit entry","Pour {0}, seuls les comptes de débit peuvent être liés avec une autre écriture de crédit", @@ -1235,7 +1235,7 @@ ITC Reversed,CTI inversé, Identifying Decision Makers,Identifier les décideurs, "If Auto Opt In is checked, then the customers will be automatically linked with the concerned Loyalty Program (on save)","Si l'option adhésion automatique est cochée, les clients seront automatiquement liés au programme de fidélité concerné (après l'enregistrement)", "If multiple Pricing Rules continue to prevail, users are asked to set Priority manually to resolve conflict.","Si plusieurs Règles de Prix continuent de prévaloir, les utilisateurs sont invités à définir manuellement la priorité pour résoudre les conflits.", -"If selected Pricing Rule is made for 'Rate', it will overwrite Price List. Pricing Rule rate is the final rate, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field.","Si la règle de tarification sélectionnée est définie pour le «Prix Unitaire», elle écrase la liste de prix. Le prix unitaire de la règle de tarification est le prix unitaire final, donc aucune autre réduction supplémentaire ne doit être appliquée. Par conséquent, dans les transactions telles que la commande client, la commande d'achat, etc., elle sera récupérée dans le champ ""Prix Unitaire"", plutôt que dans le champ ""Tarif de la liste de prix"".", +"If selected Pricing Rule is made for 'Rate', it will overwrite Price List. Pricing Rule rate is the final rate, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field.","Si la règle de tarification sélectionnée est définie pour le 'Prix Unitaire', elle écrase la liste de prix. Le prix unitaire de la règle de tarification est le prix unitaire final, donc aucune autre réduction supplémentaire ne doit être appliquée. Par conséquent, dans les transactions telles que la commande client, la commande d'achat, etc., elle sera récupérée dans le champ 'Prix Unitaire', plutôt que dans le champ 'Tarif de la liste de prix'.", "If two or more Pricing Rules are found based on the above conditions, Priority is applied. Priority is a number between 0 to 20 while default value is zero (blank). Higher number means it will take precedence if there are multiple Pricing Rules with same conditions.","Si deux Règles de Prix ou plus sont trouvées sur la base des conditions ci-dessus, une Priorité est appliquée. La Priorité est un nombre compris entre 0 et 20 avec une valeur par défaut de zéro (vide). Les nombres les plus élévés sont prioritaires s'il y a plusieurs Règles de Prix avec mêmes conditions.", "If unlimited expiry for the Loyalty Points, keep the Expiry Duration empty or 0.","Si vous souhaitez ne pas mettre de date d'expiration pour les points de fidélité, laissez la durée d'expiration vide ou mettez 0.", "If you have any questions, please get back to us.","Si vous avez des questions, veuillez revenir vers nous.", @@ -1269,7 +1269,7 @@ Income,Revenus, Income Account,Compte de Produits, Income Tax,Impôt sur le revenu, Incoming,Entrant, -Incoming Rate,Taux d'Entrée, +Incoming Rate,Prix d'Entrée, Incorrect number of General Ledger Entries found. You might have selected a wrong Account in the transaction.,Nombre incorrect d'Écritures Grand Livre trouvées. Vous avez peut-être choisi le mauvais Compte dans la transaction., Increment cannot be 0,Incrément ne peut pas être 0, Increment for Attribute {0} cannot be 0,Incrément pour l'Attribut {0} ne peut pas être 0, @@ -1365,7 +1365,7 @@ Item Variants,Variantes de l'Article, Item Variants updated,Variantes d'article mises à jour, Item has variants.,L'article a des variantes., Item must be added using 'Get Items from Purchase Receipts' button,L'article doit être ajouté à l'aide du bouton 'Obtenir des éléments de Reçus d'Achat', -Item valuation rate is recalculated considering landed cost voucher amount,Le taux d'évaluation de l'article est recalculé compte tenu du montant du bon de prix au débarquement, +Item valuation rate is recalculated considering landed cost voucher amount,Le taux de valorisation de l'article est recalculé compte tenu du montant du bon de prix au débarquement, Item variant {0} exists with same attributes,La variante de l'article {0} existe avec les mêmes caractéristiques, Item {0} does not exist,Article {0} n'existe pas, Item {0} does not exist in the system or has expired,L'article {0} n'existe pas dans le système ou a expiré, @@ -2147,7 +2147,7 @@ Previous Financial Year is not closed,L’Exercice Financier Précédent n’est Price,Prix, Price List,Liste de prix, Price List Currency not selected,Devise de la Liste de Prix non sélectionnée, -Price List Rate,Taux de la Liste des Prix, +Price List Rate,Prix de la Liste des Prix, Price List master.,Données de Base des Listes de Prix, Price List must be applicable for Buying or Selling,La Liste de Prix doit être applicable pour les Achats et les Ventes, Price List {0} is disabled or does not exist,Liste des Prix {0} est désactivée ou n'existe pas, @@ -2288,8 +2288,8 @@ Quotations: ,Devis :, Quotes to Leads or Customers.,Devis de Prospects ou Clients., RFQs are not allowed for {0} due to a scorecard standing of {1},Les Appels d'Offres ne sont pas autorisés pour {0} en raison d'une note de {1} sur la fiche d'évaluation, Range,Plage, -Rate,Taux, -Rate:,Taux:, +Rate,Prix, +Rate:,Prix:, Rating,Évaluation, Raw Material,Matières Premières, Raw Materials,Matières premières, @@ -2426,7 +2426,7 @@ Route,Route, Row # {0}: ,Ligne # {0} :, Row # {0}: Batch No must be same as {1} {2},Ligne # {0} : Le N° de Lot doit être le même que {1} {2}, Row # {0}: Cannot return more than {1} for Item {2},Ligne # {0} : Vous ne pouvez pas retourner plus de {1} pour l’Article {2}, -Row # {0}: Rate cannot be greater than the rate used in {1} {2},Ligne # {0}: Le Taux ne peut pas être supérieur au taux utilisé dans {1} {2}, +Row # {0}: Rate cannot be greater than the rate used in {1} {2},Ligne # {0}: Le prix ne peut pas être supérieur au prix utilisé dans {1} {2}, Row # {0}: Serial No is mandatory,Ligne # {0} : N° de série est obligatoire, Row # {0}: Serial No {1} does not match with {2} {3},Ligne # {0} : N° de série {1} ne correspond pas à {2} {3}, Row #{0} (Payment Table): Amount must be negative,Row # {0} (Table de paiement): le montant doit être négatif, @@ -2434,7 +2434,7 @@ Row #{0} (Payment Table): Amount must be positive,Ligne #{0} (Table de paiement) Row #{0}: Account {1} does not belong to company {2},Ligne # {0}: le compte {1} n'appartient pas à la société {2}, Row #{0}: Allocated Amount cannot be greater than outstanding amount.,Ligne # {0}: montant attribué ne peut pas être supérieur au montant en souffrance., "Row #{0}: Asset {1} cannot be submitted, it is already {2}","Ligne #{0} : L’Actif {1} ne peut pas être soumis, il est déjà {2}", -Row #{0}: Cannot set Rate if amount is greater than billed amount for Item {1}.,Ligne n ° {0}: impossible de définir le tarif si le montant est supérieur au montant facturé pour l'élément {1}., +Row #{0}: Cannot set Rate if amount is greater than billed amount for Item {1}.,Ligne n ° {0}: impossible de définir le prix si le montant est supérieur au montant facturé pour l'élément {1}., Row #{0}: Clearance date {1} cannot be before Cheque Date {2},Ligne #{0} : Date de compensation {1} ne peut pas être antérieure à la Date du Chèque {2}, Row #{0}: Duplicate entry in References {1} {2},Ligne # {0}: entrée en double dans les références {1} {2}, Row #{0}: Expected Delivery Date cannot be before Purchase Order Date,Ligne {0}: la date de livraison prévue ne peut pas être avant la date de commande, @@ -2898,7 +2898,7 @@ Sync has been temporarily disabled because maximum retries have been exceeded,La Syntax error in condition: {0},Erreur de syntaxe dans la condition: {0}, Syntax error in formula or condition: {0},Erreur de syntaxe dans la formule ou condition : {0}, System Manager,Responsable Système, -TDS Rate %,Taux de TDS%, +TDS Rate %,Pourcentage de TDS, Tap items to add them here,Choisissez des articles pour les ajouter ici, Target,Cible, Target ({}),Cible ({}), @@ -3190,7 +3190,7 @@ Update Print Format,Mettre à Jour le Format d'Impression, Update Response,Mettre à jour la réponse, Update bank payment dates with journals.,Mettre à jour les dates de paiement bancaires avec les journaux., Update in progress. It might take a while.,Mise à jour en cours. Ça peut prendre un moment., -Update rate as per last purchase,Taux de mise à jour selon le dernier achat, +Update rate as per last purchase,Mettre à jour les prix selon le dernier prix achat, Update stock must be enable for the purchase invoice {0},La mise à jour du stock doit être activée pour la facture d'achat {0}, Updating Variants...,Mise à jour des variantes ..., Upload your letter head and logo. (you can edit them later).,Charger votre en-tête et logo. (vous pouvez les modifier ultérieurement)., @@ -3326,7 +3326,6 @@ You are not authorized to add or update entries before {0},Vous n'êtes pas auto You are not authorized to approve leaves on Block Dates,Vous n'êtes pas autorisé à approuver les congés sur les Dates Bloquées, You are not authorized to set Frozen value,Vous n'êtes pas autorisé à définir des valeurs gelées, You are not present all day(s) between compensatory leave request days,Vous n'êtes pas présent(e) tous les jours vos demandes de congé compensatoire, -You can not change rate if BOM mentioned agianst any item,Vous ne pouvez pas modifier le taux si la nomenclature est mentionnée pour un article, You can not enter current voucher in 'Against Journal Entry' column,Vous ne pouvez pas entrer le bon actuel dans la colonne 'Pour l'Écriture de Journal', You can only have Plans with the same billing cycle in a Subscription,Vous ne pouvez avoir que des plans ayant le même cycle de facturation dans le même abonnement, You can only redeem max {0} points in this order.,Vous pouvez uniquement échanger un maximum de {0} points dans cet commande., @@ -3971,7 +3970,7 @@ Queued,File d'Attente, Quick Entry,Écriture Rapide, Quiz {0} does not exist,Le questionnaire {0} n'existe pas, Quotation Amount,Montant du devis, -Rate or Discount is required for the price discount.,Le taux ou la remise est requis pour la remise de prix., +Rate or Discount is required for the price discount.,Le prix ou la remise est requis pour la remise., Reason,Raison, Reconcile Entries,Réconcilier les entrées, Reconcile this account,Réconcilier ce compte, @@ -4348,7 +4347,7 @@ Valid Upto date cannot be before Valid From date,La date de validité valide ne Valid From date not in Fiscal Year {0},Date de début de validité non comprise dans l'exercice {0}, Valid Upto date not in Fiscal Year {0},Valable jusqu'à la date hors exercice {0}, Group Roll No,Groupe Roll Non, -Maintain Same Rate Throughout Sales Cycle,Maintenir le Même Taux Durant le Cycle de Vente, +Maintain Same Rate Throughout Sales Cycle,Maintenir le même prix Durant le Cycle de Vente, "Row {1}: Quantity ({0}) cannot be a fraction. To allow this, disable '{2}' in UOM {3}.","Ligne {1}: la quantité ({0}) ne peut pas être une fraction. Pour autoriser cela, désactivez «{2}» dans UdM {3}.", Must be Whole Number,Doit être un Nombre Entier, Please setup Razorpay Plan ID,Veuillez configurer l'ID du plan Razorpay, @@ -4961,7 +4960,7 @@ Threshold for Suggestion,Seuil de suggestion, System will notify to increase or decrease quantity or amount ,Le système notifiera d'augmenter ou de diminuer la quantité ou le montant, "Higher the number, higher the priority","Plus le nombre est grand, plus la priorité est haute", Apply Multiple Pricing Rules,Appliquer plusieurs règles de tarification, -Apply Discount on Rate,Appliquer une réduction sur le taux, +Apply Discount on Rate,Appliquer une réduction sur le prix, Validate Applied Rule,Valider la règle appliquée, Rule Description,Description de la règle, Pricing Rule Help,Aide pour les Règles de Tarification, @@ -5050,19 +5049,18 @@ End date of current invoice's period,Date de fin de la période de facturation e Update Auto Repeat Reference,Mettre à jour la référence de répétition automatique, Purchase Invoice Advance,Avance sur Facture d’Achat, Purchase Invoice Item,Article de la Facture d'Achat, -Quantity and Rate,Quantité et Taux, +Quantity and Rate,Quantité et Prix, Received Qty,Qté Reçue, Accepted Qty,Quantité acceptée, Rejected Qty,Qté Rejetée, UOM Conversion Factor,Facteur de Conversion de l'UDM, Discount on Price List Rate (%),Remise sur la Liste des Prix (%), Price List Rate (Company Currency),Taux de la Liste de Prix (Devise Société), -Rate ,Taux, Rate (Company Currency),Prix (Devise Société), Amount (Company Currency),Montant (Devise de la Société), Is Free Item,Est un article gratuit, -Net Rate,Taux Net, -Net Rate (Company Currency),Taux Net (Devise Société), +Net Rate,Prix Net, +Net Rate (Company Currency),Prix Net (Devise Société), Net Amount (Company Currency),Montant Net (Devise Société), Item Tax Amount Included in Value,Montant de la taxe incluse dans la valeur, Landed Cost Voucher Amount,Montant de la Référence de Coût au Débarquement, @@ -5080,7 +5078,7 @@ Enable Deferred Expense,Activer les frais reportés, Service Start Date,Date de début du service, Service End Date,Date de fin du service, Allow Zero Valuation Rate,Autoriser un Taux de Valorisation Égal à Zéro, -Item Tax Rate,Taux de la Taxe sur l'Article, +Item Tax Rate,Prix de la Taxe sur l'Article, Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges,La table de détails de taxe est récupérée depuis les données de base de l'article comme une chaîne de caractères et stockée dans ce champ. Elle est utilisée pour les Taxes et Frais., Purchase Order Item,Article de la Commande d'Achat, Purchase Receipt Detail,Détail du reçu d'achat, @@ -5098,8 +5096,8 @@ On Previous Row Amount,Le Montant de la Rangée Précédente, On Previous Row Total,Le Total de la Rangée Précédente, On Item Quantity,Sur quantité d'article, Reference Row #,Ligne de Référence #, -Is this Tax included in Basic Rate?,Cette Taxe est-elle incluse dans le Taux de Base ?, -"If checked, the tax amount will be considered as already included in the Print Rate / Print Amount","Si cochée, le montant de la taxe sera considéré comme déjà inclus dans le Taux d'Impression / Prix d'Impression", +Is this Tax included in Basic Rate?,Cette Taxe est-elle incluse dans le Prix de Base ?, +"If checked, the tax amount will be considered as already included in the Print Rate / Print Amount","Si cochée, le montant de la taxe sera considéré comme déjà inclus dans le Taux / Prix des documents (PDF, impressions)", Account Head,Compte Principal, Tax Amount After Discount Amount,Montant de la Taxe après Remise, Item Wise Tax Detail ,Détail de la taxe de l'article Wise, @@ -5147,7 +5145,7 @@ Accounting Details,Détails Comptabilité, Debit To,Débit Pour, Is Opening Entry,Est Écriture Ouverte, C-Form Applicable,Formulaire-C Applicable, -Commission Rate (%),Taux de Commission (%), +Commission Rate (%),Pourcentage de Commission, Sales Team1,Équipe des Ventes 1, Against Income Account,Pour le Compte de Produits, Sales Invoice Advance,Avance sur Facture de Vente, @@ -5157,9 +5155,9 @@ Customer's Item Code,Code de l'Article du Client, Brand Name,Nom de la Marque, Qty as per Stock UOM,Qté par UDM du Stock, Discount and Margin,Remise et Marge, -Rate With Margin,Tarif Avec Marge, -Discount (%) on Price List Rate with Margin,Remise (%) sur le Tarif de la Liste de Prix avec la Marge, -Rate With Margin (Company Currency),Taux avec marge (devise de l'entreprise), +Rate With Margin,Prix Avec Marge, +Discount (%) on Price List Rate with Margin,Remise (%) sur le prix de la Liste de Prix avec la Marge, +Rate With Margin (Company Currency),Prix avec marge (devise de l'entreprise), Delivered By Supplier,Livré par le Fournisseur, Deferred Revenue,Produits comptabilisés d'avance, Deferred Revenue Account,Compte de produits comptabilisés d'avance, @@ -5721,7 +5719,7 @@ Contact Mobile No,N° de Portable du Contact, Enter name of campaign if source of enquiry is campaign,Entrez le nom de la campagne si la source de l'enquête est une campagne, Opportunity Date,Date d'Opportunité, Opportunity Item,Article de l'Opportunité, -Basic Rate,Taux de Base, +Basic Rate,Prix de Base, Stage Name,Nom de scène, Social Media Post,Publication sur les réseaux sociaux, Post Status,Statut du message, @@ -7218,8 +7216,8 @@ Qty Consumed Per Unit,Qté Consommée Par Unité, Include Item In Manufacturing,Inclure l'article dans la fabrication, BOM Item,Article de la nomenclature, Item operation,Opération de l'article, -Rate & Amount,Taux et Montant, -Basic Rate (Company Currency),Taux de Base (Devise de la Société ), +Rate & Amount,Prix et Montant, +Basic Rate (Company Currency),Prix de Base (Devise de la Société ), Scrap %,% de Rebut, Original Item,Article original, BOM Operation,Opération de la nomenclature (gamme), @@ -7464,8 +7462,8 @@ Website Attribute,Attribut de site Web, Attribute,Attribut, Website Filter Field,Champ de filtrage de site Web, Activity Cost,Coût de l'Activité, -Billing Rate,Taux de Facturation, -Costing Rate,Taux des Coûts, +Billing Rate,Prix de Facturation, +Costing Rate,Tarifs des Coûts, title,Titre, Projects User,Utilisateur/Intervenant Projets, Default Costing Rate,Coût de Revient par Défaut, @@ -7963,7 +7961,7 @@ Reserved Quantity,Quantité Réservée, Actual Quantity,Quantité Réelle, Requested Quantity,Quantité Demandée, Reserved Qty for sub contract,Qté réservée pour le sous-contrat, -Moving Average Rate,Taux Mobile Moyen, +Moving Average Rate,Prix moyen pondéré, FCFS Rate,Montant PAPS, Customs Tariff Number,Tarifs Personnalisés, Tariff Number,Tarif, @@ -8311,7 +8309,7 @@ Total Additional Costs,Total des Coûts Additionnels, Customer or Supplier Details,Détails du Client ou du Fournisseur, Per Transferred,Par transféré, Stock Entry Detail,Détails de l'Écriture de Stock, -Basic Rate (as per Stock UOM),Taux de base (comme l’UDM du Stock), +Basic Rate (as per Stock UOM),Prix de base (comme l’UDM du Stock), Basic Amount,Montant de Base, Additional Cost,Frais Supplémentaire, Serial No / Batch,N° de Série / Lot, @@ -8323,7 +8321,7 @@ Stock Entry Child,Entrée de stock enfant, PO Supplied Item,PO article fourni, Reference Purchase Receipt,Reçu d'achat de référence, Stock Ledger Entry,Écriture du Livre d'Inventaire, -Outgoing Rate,Taux Sortant, +Outgoing Rate,Prix Sortant, Actual Qty After Transaction,Qté Réelle Après Transaction, Stock Value Difference,Différence de Valeur du Sock, Stock Queue (FIFO),File d'Attente du Stock (FIFO), @@ -8509,7 +8507,7 @@ Item Price Stock,Stock et prix de l'article, Item Prices,Prix des Articles, Item Shortage Report,Rapport de Rupture de Stock d'Article, Item Variant Details,Détails de la variante de l'article, -Item-wise Price List Rate,Taux de la Liste des Prix par Article, +Item-wise Price List Rate,Prix de la Liste des Prix par Article, Item-wise Purchase History,Historique d'Achats par Article, Item-wise Purchase Register,Registre des Achats par Article, Item-wise Sales History,Historique des Ventes par Article, @@ -8561,7 +8559,7 @@ Sales Partner Target Variance based on Item Group,Variance cible du partenaire c Sales Partner Transaction Summary,Récapitulatif des transactions du partenaire commercial, Sales Partners Commission,Commission des Partenaires de Vente, Invoiced Amount (Exclusive Tax),Montant facturé (taxe exclusive), -Average Commission Rate,Taux Moyen de la Commission, +Average Commission Rate,Coût Moyen de la Commission, Sales Payment Summary,Résumé du paiement des ventes, Sales Person Commission Summary,Récapitulatif de la commission des ventes, Sales Person Target Variance Based On Item Group,Écart cible du commercial basé sur le groupe de postes, @@ -8815,7 +8813,7 @@ Generate New Invoices Past Due Date,Générer de nouvelles factures en retard, New invoices will be generated as per schedule even if current invoices are unpaid or past due date,"De nouvelles factures seront générées selon le calendrier, même si les factures actuelles sont impayées ou en retard", Document Type ,Type de document, Subscription Price Based On,Prix d'abonnement basé sur, -Fixed Rate,Taux fixe, +Fixed Rate,Tarif fixe, Based On Price List,Basé sur la liste de prix, Monthly Rate,Tarif mensuel, Cancel Subscription After Grace Period,Annuler l'abonnement après la période de grâce, @@ -8886,10 +8884,6 @@ Practitioner Name,Nom du praticien, Enter a name for the Clinical Procedure Template,Entrez un nom pour le modèle de procédure clinique, Set the Item Code which will be used for billing the Clinical Procedure.,Définissez le code article qui sera utilisé pour facturer la procédure clinique., Select an Item Group for the Clinical Procedure Item.,Sélectionnez un groupe d'articles pour l'article de procédure clinique., -Clinical Procedure Rate,Taux de procédure clinique, -Check this if the Clinical Procedure is billable and also set the rate.,Cochez cette case si la procédure clinique est facturable et définissez également le tarif., -Check this if the Clinical Procedure utilises consumables. Click ,Vérifiez ceci si la procédure clinique utilise des consommables. Cliquez sur, - to know more,en savoir plus, "You can also set the Medical Department for the template. After saving the document, an Item will automatically be created for billing this Clinical Procedure. You can then use this template while creating Clinical Procedures for Patients. Templates save you from filling up redundant data every single time. You can also create templates for other operations like Lab Tests, Therapy Sessions, etc.","Vous pouvez également définir le service médical du modèle. Après avoir enregistré le document, un élément sera automatiquement créé pour facturer cette procédure clinique. Vous pouvez ensuite utiliser ce modèle lors de la création de procédures cliniques pour les patients. Les modèles vous évitent de remplir des données redondantes à chaque fois. Vous pouvez également créer des modèles pour d'autres opérations telles que des tests de laboratoire, des séances de thérapie, etc.", Descriptive Test Result,Résultat du test descriptif, Allow Blank,Autoriser le blanc, @@ -9033,7 +9027,7 @@ Work In Progress Warehouse,Entrepôt de travaux en cours, This Warehouse will be auto-updated in the Work In Progress Warehouse field of Work Orders.,Cet entrepôt sera mis à jour automatiquement dans le champ Entrepôt de travaux en cours des bons de travail., Finished Goods Warehouse,Entrepôt de produits finis, This Warehouse will be auto-updated in the Target Warehouse field of Work Order.,Cet entrepôt sera mis à jour automatiquement dans le champ Entrepôt cible de l'ordre de fabrication. -"If ticked, the BOM cost will be automatically updated based on Valuation Rate / Price List Rate / last purchase rate of raw materials.","Si coché, le coût de la nomenclature sera automatiquement mis à jour en fonction du taux de valorisation / tarif tarifaire / dernier taux d'achat des matières premières.", +"If ticked, the BOM cost will be automatically updated based on Valuation Rate / Price List Rate / last purchase rate of raw materials.","Si coché, le coût de la nomenclature sera automatiquement mis à jour en fonction du taux de valorisation / prix de la liste prix / dernier prix d'achat des matières premières.", Source Warehouses (Optional),Entrepôts d'origine (facultatif), "System will pickup the materials from the selected warehouses. If not specified, system will create material request for purchase.","Le système ramassera les matériaux dans les entrepôts sélectionnés. S'il n'est pas spécifié, le système créera une demande de matériel pour l'achat.", Lead Time,Délai de mise en œuvre, @@ -9107,7 +9101,7 @@ MAT-PR-RET-.YYYY.-,MAT-PR-RET-.YYYY.-, Track this Purchase Receipt against any Project,Suivre ce reçu d'achat par rapport à n'importe quel projet, Please Select a Supplier,Veuillez sélectionner un fournisseur, Add to Transit,Ajouter à Transit, -Set Basic Rate Manually,Définir manuellement le taux de base, +Set Basic Rate Manually,Définir manuellement le prix de base, "By default, the Item Name is set as per the Item Code entered. If you want Items to be named by a ","Par défaut, le nom de l'article est défini selon le code d'article entré. Si vous souhaitez que les éléments soient nommés par un", Set a Default Warehouse for Inventory Transactions. This will be fetched into the Default Warehouse in the Item master.,Définissez un entrepôt par défaut pour les mouvements de stock. Ce sera récupéré dans l'entrepôt par défaut dans la base d'articles., "This will allow stock items to be displayed in negative values. Using this option depends on your use case. With this option unchecked, the system warns before obstructing a transaction that is causing negative stock.","Cela permettra aux articles en stock d'être affichés avec des valeurs négatives. L'utilisation de cette option dépend de votre cas d'utilisation. Lorsque cette option n'est pas cochée, le système avertit avant d'entraver une transaction entraînant un stock négatif.", @@ -9495,7 +9489,7 @@ Normal Range: ,Plage normale:, Row #{0}: Check Out datetime cannot be less than Check In datetime,Ligne n ° {0}: la date de sortie ne peut pas être inférieure à la date de sortie, "Missing required details, did not create Inpatient Record","Détails requis manquants, n'a pas créé de dossier d'hospitalisation", Unbilled Invoices,Factures non facturées, -Standard Selling Rate should be greater than zero.,Le taux de vente standard doit être supérieur à zéro., +Standard Selling Rate should be greater than zero.,Le prix de vente standard doit être supérieur à zéro., Conversion Factor is mandatory,Le facteur de conversion est obligatoire, Row #{0}: Conversion Factor is mandatory,Ligne n ° {0}: le facteur de conversion est obligatoire, Sample Quantity cannot be negative or 0,La quantité d'échantillon ne peut pas être négative ou 0, @@ -9559,7 +9553,7 @@ The Request for Quotation can be accessed by clicking on the following button,La Regards,Cordialement, Please click on the following button to set your new password,Veuillez cliquer sur le bouton suivant pour définir votre nouveau mot de passe, Update Password,Mettre à jour le mot de passe, -Row #{}: Selling rate for item {} is lower than its {}. Selling {} should be atleast {},Ligne n ° {}: le taux de vente de l'article {} est inférieur à son {}. La vente {} doit être au moins {}, +Row #{}: Selling rate for item {} is lower than its {}. Selling {} should be atleast {},Ligne n ° {}: le prix de vente de l'article {} est inférieur à son {}. La vente {} doit être au moins {}, You can alternatively disable selling price validation in {} to bypass this validation.,Vous pouvez également désactiver la validation du prix de vente dans {} pour contourner cette validation., Invalid Selling Price,Prix de vente invalide, Address needs to be linked to a Company. Please add a row for Company in the Links table.,L'adresse doit être liée à une entreprise. Veuillez ajouter une ligne pour Entreprise dans le tableau Liens., @@ -9581,7 +9575,7 @@ Only select this if you have set up the Cash Flow Mapper documents,Sélectionnez Payment Channel,Canal de paiement, Is Purchase Order Required for Purchase Invoice & Receipt Creation?,Une Commande d'Achat est-il requis pour la création de factures d'achat et de reçus?, Is Purchase Receipt Required for Purchase Invoice Creation?,Un reçu d'achat est-il requis pour la création d'une facture d'achat?, -Maintain Same Rate Throughout the Purchase Cycle,Maintenir le même taux tout au long du cycle d'achat, +Maintain Same Rate Throughout the Purchase Cycle,Maintenir les même prix tout au long du cycle d'achat, Allow Item To Be Added Multiple Times in a Transaction,Autoriser l'ajout d'un article plusieurs fois dans une transaction, Suppliers,Fournisseurs, Send Emails to Suppliers,Envoyer des e-mails aux fournisseurs, @@ -9633,7 +9627,7 @@ Plan operations X days in advance,Planifier les opérations X jours à l'avance, Time Between Operations (Mins),Temps entre les opérations (minutes), Default: 10 mins,Par défaut: 10 minutes, Overproduction for Sales and Work Order,Surproduction pour les ventes et les bons de travail, -"Update BOM cost automatically via scheduler, based on the latest Valuation Rate/Price List Rate/Last Purchase Rate of raw materials","Mettre à jour automatiquement le coût de la nomenclature via le planificateur, en fonction du dernier taux de valorisation / tarif tarifaire / dernier taux d'achat de matières premières", +"Update BOM cost automatically via scheduler, based on the latest Valuation Rate/Price List Rate/Last Purchase Rate of raw materials","Mettre à jour automatiquement le coût de la nomenclature via le planificateur, en fonction du dernier taux de valorisation / prix de la liste de prix / dernier prix d'achat de matières premières", Purchase Order already created for all Sales Order items,Commande d'Achat déjà créé pour tous les articles de commande client, Select Items,Sélectionner des éléments, Against Default Supplier,Contre le fournisseur par défaut, @@ -9641,14 +9635,14 @@ Auto close Opportunity after the no. of days mentioned above,Opportunité de fer Is Sales Order Required for Sales Invoice & Delivery Note Creation?,Une commande client est-elle requise pour la création de factures clients et de bons de livraison?, Is Delivery Note Required for Sales Invoice Creation?,Un bon de livraison est-il nécessaire pour la création de factures de vente?, How often should Project and Company be updated based on Sales Transactions?,À quelle fréquence le projet et l'entreprise doivent-ils être mis à jour en fonction des transactions de vente?, -Allow User to Edit Price List Rate in Transactions,Autoriser l'utilisateur à modifier le tarif tarifaire dans les transactions, +Allow User to Edit Price List Rate in Transactions,Autoriser l'utilisateur à modifier le prix de la liste prix dans les transactions, Allow Item to Be Added Multiple Times in a Transaction,Autoriser l'ajout d'un article plusieurs fois dans une transaction, Allow Multiple Sales Orders Against a Customer's Purchase Order,Autoriser plusieurs commandes client par rapport à la commande d'achat d'un client, -Validate Selling Price for Item Against Purchase Rate or Valuation Rate,Valider le prix de vente de l'article par rapport au taux d'achat ou au taux de valorisation, +Validate Selling Price for Item Against Purchase Rate or Valuation Rate,Valider le prix de vente de l'article par rapport au prix d'achat ou au taux de valorisation, Hide Customer's Tax ID from Sales Transactions,Masquer le numéro d'identification fiscale du client dans les transactions de vente, "The percentage you are allowed to receive or deliver more against the quantity ordered. For example, if you have ordered 100 units, and your Allowance is 10%, then you are allowed to receive 110 units.","Le pourcentage que vous êtes autorisé à recevoir ou à livrer plus par rapport à la quantité commandée. Par exemple, si vous avez commandé 100 unités et que votre allocation est de 10%, vous êtes autorisé à recevoir 110 unités.", Action If Quality Inspection Is Not Submitted,Action si l'inspection qualité n'est pas soumise, -Auto Insert Price List Rate If Missing,Taux de liste de prix d'insertion automatique s'il est manquant, +Auto Insert Price List Rate If Missing,Insérer automatiquement le prix dand liste de prix s'il est manquant, Automatically Set Serial Nos Based on FIFO,Définir automatiquement les numéros de série en fonction de FIFO, Set Qty in Transactions Based on Serial No Input,Définir la quantité dans les transactions en fonction du numéro de série, Raise Material Request When Stock Reaches Re-order Level,Augmenter la demande d'article lorsque le stock atteint le niveau de commande, @@ -9722,7 +9716,7 @@ No Inpatient Record found against patient {0},Aucun dossier d'hospitalisation tr An Inpatient Medication Order {0} against Patient Encounter {1} already exists.,Une ordonnance de médicament pour patients hospitalisés {0} contre rencontre avec un patient {1} existe déjà., Allow In Returns,Autoriser les retours, Hide Unavailable Items,Masquer les éléments non disponibles, -Apply Discount on Discounted Rate,Appliquer une remise sur un tarif réduit, +Apply Discount on Discounted Rate,Appliquer une remise sur un prix réduit, Therapy Plan Template,Modèle de plan de thérapie, Fetching Template Details,Récupération des détails du modèle, Linked Item Details,Détails de l'élément lié, From 1f6f2747d49604bd3707d9017a219989d8df57b8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 24 Aug 2022 21:20:23 +0200 Subject: [PATCH 21/72] chore: update fr translation --- erpnext/translations/fr.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/translations/fr.csv b/erpnext/translations/fr.csv index 1869411a1f..b5de5784c5 100644 --- a/erpnext/translations/fr.csv +++ b/erpnext/translations/fr.csv @@ -658,7 +658,7 @@ Create Invoice,Créer une facture, Create Invoices,Créer des factures, Create Job Card,Créer une carte de travail, Create Journal Entry,Créer une entrée de journal, -Create Lead,Créer une piste, +Create Lead,Créer un Prospect, Create Leads,Créer des Prospects, Create Maintenance Visit,Créer une visite de maintenance, Create Material Request,Créer une demande de matériel, @@ -3881,7 +3881,7 @@ Only expired allocation can be cancelled,Seule l'allocation expirée peut être Only users with the {0} role can create backdated leave applications,Seuls les utilisateurs avec le rôle {0} peuvent créer des demandes de congé antidatées, Open,Ouvert, Open Contact,Contact ouvert, -Open Lead,Ouvrir le fil, +Open Lead,Ouvrir le Prospect, Opening and Closing,Ouverture et fermeture, Operating Cost as per Work Order / BOM,Coût d'exploitation selon l'ordre de fabrication / nomenclature, Order Amount,Montant de la commande, From 299da5d596f29d195c224af3021edd26f752d390 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 24 Aug 2022 21:29:22 +0200 Subject: [PATCH 22/72] chore: update fr translation --- erpnext/translations/fr.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/translations/fr.csv b/erpnext/translations/fr.csv index b5de5784c5..b2074618a6 100644 --- a/erpnext/translations/fr.csv +++ b/erpnext/translations/fr.csv @@ -9921,4 +9921,3 @@ Enable Reviews and Ratings,Activer les avis et notes Enable Recommendations,Activer les recommendations Item Search Settings,Paramétrage de la recherche d'article Purchase demande,Demande de materiel -Calendar,Calendier From e5b04d54ffbc6c2bed5df8280e39f9afb7c6555b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Aug 2022 17:05:13 +0530 Subject: [PATCH 23/72] fix: display amount in account currency if party is supplied --- .../report/accounts_receivable/accounts_receivable.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index eb2959e197..63242e83fe 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -192,7 +192,11 @@ class ReceivablePayableReport(object): if not row: return - amount = ple.amount + # amount in "Party Currency", if its supplied. If not, amount in company currency + if self.filters.get(scrub(self.party_type)): + amount = ple.amount_in_account_currency + else: + amount = ple.amount amount_in_account_currency = ple.amount_in_account_currency # update voucher @@ -690,7 +694,7 @@ class ReceivablePayableReport(object): ple.party, ple.posting_date, ple.due_date, - ple.account_currency.as_("currency"), + ple.account_currency, ple.amount, ple.amount_in_account_currency, ) From 915102a40040e38239024acb2647f54fe350809b Mon Sep 17 00:00:00 2001 From: Samuel Danieli <23150094+scdanieli@users.noreply.github.com> Date: Thu, 25 Aug 2022 07:53:38 +0200 Subject: [PATCH 24/72] chore: german translations (#31463) --- erpnext/translations/de.csv | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/erpnext/translations/de.csv b/erpnext/translations/de.csv index d6bceb342d..ca16403d95 100644 --- a/erpnext/translations/de.csv +++ b/erpnext/translations/de.csv @@ -196,7 +196,7 @@ All other ITC,Alle anderen ITC, All the mandatory Task for employee creation hasn't been done yet.,Alle obligatorischen Aufgaben zur Mitarbeitererstellung wurden noch nicht erledigt., Allocate Payment Amount,Zahlungsbetrag zuweisen, Allocated Amount,Zugewiesene Menge, -Allocated Leaves,Zugewiesene Blätter, +Allocated Leaves,Zugewiesene Urlaubstage, Allocating leaves...,Blätter zuordnen..., Already record exists for the item {0},Es existiert bereits ein Datensatz für den Artikel {0}, "Already set default in pos profile {0} for user {1}, kindly disabled default","Im Standardprofil {0} für den Benutzer {1} ist der Standard bereits festgelegt, standardmäßig deaktiviert", @@ -8623,8 +8623,8 @@ Material Request Warehouse,Materialanforderungslager, Select warehouse for material requests,Wählen Sie Lager für Materialanfragen, Transfer Materials For Warehouse {0},Material für Lager übertragen {0}, Production Plan Material Request Warehouse,Produktionsplan Materialanforderungslager, -Sets 'Source Warehouse' in each row of the items table.,Legt 'Source Warehouse' in jeder Zeile der Artikeltabelle fest., -Sets 'Target Warehouse' in each row of the items table.,"Füllt das Feld ""Ziel Lager"" in allen Positionen der folgenden Tabelle.", +Sets 'Source Warehouse' in each row of the items table.,Legt in jeder Zeile der Artikeltabelle das „Ausgangslager“ fest., +Sets 'Target Warehouse' in each row of the items table.,Legt in jeder Zeile der Artikeltabelle das „Eingangslager“ fest., Show Cancelled Entries,Abgebrochene Einträge anzeigen, Backdated Stock Entry,Backdated Stock Entry, Row #{}: Currency of {} - {} doesn't matches company currency.,Zeile # {}: Die Währung von {} - {} stimmt nicht mit der Firmenwährung überein., @@ -9871,3 +9871,31 @@ Leave Type Allocation,Zuordnung Abwesenheitsarten, From Lead,Aus Lead, From Opportunity,Aus Chance, Publish in Website,Auf Webseite veröffentlichen, +Total Allocated Leave(s),Gesamte zugewiesene Urlaubstage, +Expired Leave(s),Verfallene Urlaubstage, +Used Leave(s),Verbrauchte Urlaubstage, +Leave(s) Pending Approval,Urlaubstage zur Genehmigung ausstehend, +Available Leave(s),Verfügbare Urlaubstage, +Party Specific Item,Parteispezifischer Artikel, +Active Customers,Aktive Kunden, +Annual Sales,Jährlicher Umsatz, +Total Outgoing Bills,Ausgangsrechnungen insgesamt, +Total Incoming Bills,Eingangsrechnungen insgesamt, +Total Incoming Payment,Zahlungseingang insgesamt, +Total Outgoing Payment,Zahlungsausgang insgesamt, +Incoming Bills (Purchase Invoice),Eingehende Rechnungen (Eingangsrechnung), +Outgoing Bills (Sales Invoice),Ausgehende Rechnungen (Ausgangsrechnung), +Accounts Receivable Ageing,Fälligkeit Forderungen, +Accounts Payable Ageing,Fälligkeit Verbindlichkeiten, +Budget Variance,Budgetabweichung, +Based On Value,Basierend auf Wert, +Restrict Items Based On,Artikel einschränken auf Basis von, +Earnings & Deductions,Erträge & Abzüge, +Is Process Loss,Ist Prozessverlust, +Is Finished Item,Ist fertiger Artikel, +Is Scrap Item,Ist Schrott, +Issue a debit note with 0 qty against an existing Sales Invoice,Lastschrift mit Menge 0 gegen eine bestehende Ausgangsrechnung ausstellen, +Show Remarks,Bemerkungen anzeigen, +Website Item,Webseiten-Artikel, +Update Property,Eigenschaft aktualisieren, +Recurring Sales Invoice,Wiederkehrende Ausgangsrechnung, From 5fd468d9ec74cef05a6142c2a1112ee8c6c45ae3 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 25 Aug 2022 11:44:12 +0530 Subject: [PATCH 25/72] fix: default supplier not set in the PP --- .../production_plan/production_plan.py | 28 +++++++++++++++++++ .../production_plan/test_production_plan.py | 25 +++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 2cdf8d3ea9..66d458bf75 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -656,6 +656,8 @@ class ProductionPlan(Document): row.idx = idx + 1 self.append("sub_assembly_items", row) + self.set_default_supplier_for_subcontracting_order() + def set_sub_assembly_items_based_on_level(self, row, bom_data, manufacturing_type=None): "Modify bom_data, set additional details." for data in bom_data: @@ -667,6 +669,32 @@ class ProductionPlan(Document): "Subcontract" if data.is_sub_contracted_item else "In House" ) + def set_default_supplier_for_subcontracting_order(self): + items = [ + d.production_item for d in self.sub_assembly_items if d.type_of_manufacturing == "Subcontract" + ] + + if not items: + return + + default_supplier = frappe._dict( + frappe.get_all( + "Item Default", + fields=["parent", "default_supplier"], + filters={"parent": ("in", items), "default_supplier": ("is", "set")}, + as_list=1, + ) + ) + + if not default_supplier: + return + + for row in self.sub_assembly_items: + if row.type_of_manufacturing != "Subcontract": + continue + + row.supplier = default_supplier.get(row.production_item) + def combine_subassembly_items(self, sub_assembly_items_store): "Aggregate if same: Item, Warehouse, Inhouse/Outhouse Manu.g, BOM No." key_wise_data = {} diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index e2415ad848..1d2d1bd9a8 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -281,6 +281,31 @@ class TestProductionPlan(FrappeTestCase): pln.reload() pln.cancel() + def test_production_plan_subassembly_default_supplier(self): + from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom + + bom_tree_1 = {"Test Laptop": {"Test Motherboard": {"Test Motherboard Wires": {}}}} + bom = create_nested_bom(bom_tree_1, prefix="") + + item_doc = frappe.get_doc("Item", "Test Motherboard") + company = "_Test Company" + + item_doc.is_sub_contracted_item = 1 + for row in item_doc.item_defaults: + if row.company == company and not row.default_supplier: + row.default_supplier = "_Test Supplier" + + if not item_doc.item_defaults: + item_doc.append("item_defaults", {"company": company, "default_supplier": "_Test Supplier"}) + + item_doc.save() + + plan = create_production_plan(item_code="Test Laptop", use_multi_level_bom=1, do_not_submit=True) + plan.get_sub_assembly_items() + plan.set_default_supplier_for_subcontracting_order() + + self.assertEqual(plan.sub_assembly_items[0].supplier, "_Test Supplier") + def test_production_plan_combine_subassembly(self): """ Test combining Sub assembly items belonging to the same BOM in Prod Plan. From c1f6dd46d186750146697312d0e10e6ea5c86104 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 25 Aug 2022 12:10:52 +0530 Subject: [PATCH 26/72] chore: fix against account --- erpnext/assets/doctype/asset_repair/asset_repair.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index b4316ced62..8758e9c17d 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -249,7 +249,7 @@ class AssetRepair(AccountsController): "account": fixed_asset_account, "debit": item.amount, "debit_in_account_currency": item.amount, - "against": item.expense_account, + "against": item.expense_account or default_expense_account, "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, From 9ab10def4936424e9825bf0a999a20bb6039d31e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 25 Aug 2022 12:13:17 +0530 Subject: [PATCH 27/72] fix: material request connection on work order --- .../doctype/work_order/work_order_dashboard.py | 2 +- .../doctype/material_request/material_request.json | 14 ++++++++++++-- erpnext/stock/doctype/stock_entry/stock_entry.js | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order_dashboard.py b/erpnext/manufacturing/doctype/work_order/work_order_dashboard.py index 465460f95d..d0dcc55932 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order_dashboard.py +++ b/erpnext/manufacturing/doctype/work_order/work_order_dashboard.py @@ -7,6 +7,6 @@ def get_data(): "non_standard_fieldnames": {"Batch": "reference_name"}, "transactions": [ {"label": _("Transactions"), "items": ["Stock Entry", "Job Card", "Pick List"]}, - {"label": _("Reference"), "items": ["Serial No", "Batch"]}, + {"label": _("Reference"), "items": ["Serial No", "Batch", "Material Request"]}, ], } diff --git a/erpnext/stock/doctype/material_request/material_request.json b/erpnext/stock/doctype/material_request/material_request.json index cb46a6c368..35931307af 100644 --- a/erpnext/stock/doctype/material_request/material_request.json +++ b/erpnext/stock/doctype/material_request/material_request.json @@ -37,7 +37,8 @@ "tc_name", "terms", "reference", - "job_card" + "job_card", + "work_order" ], "fields": [ { @@ -309,16 +310,24 @@ "label": "Transfer Status", "options": "\nNot Started\nIn Transit\nCompleted", "read_only": 1 + }, + { + "fieldname": "work_order", + "fieldtype": "Link", + "label": "Work Order", + "options": "Work Order", + "read_only": 1 } ], "icon": "fa fa-ticket", "idx": 70, "is_submittable": 1, "links": [], - "modified": "2021-08-17 20:16:12.737743", + "modified": "2022-08-25 11:49:28.155048", "modified_by": "Administrator", "module": "Stock", "name": "Material Request", + "naming_rule": "By \"Naming Series\" field", "owner": "Administrator", "permissions": [ { @@ -386,5 +395,6 @@ "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", + "states": [], "title_field": "title" } \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index e3a8438d95..1bbe570807 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -174,6 +174,8 @@ frappe.ui.form.on('Stock Entry', { if(!items.length) { items = frm.doc.items; } + + mr.work_order = frm.doc.work_order; items.forEach(function(item) { var mr_item = frappe.model.add_child(mr, 'items'); mr_item.item_code = item.item_code; From 8566832dd51bc78d04ae2b0268883b4ae890a98a Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Thu, 25 Aug 2022 15:05:13 +0530 Subject: [PATCH 28/72] fix: add validation for PO in Stock Entry (#31974) --- erpnext/stock/doctype/stock_entry/stock_entry.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index f719c1efda..c68d1db279 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -116,6 +116,7 @@ class StockEntry(StockController): self.validate_warehouse() self.validate_work_order() self.validate_bom() + self.validate_purchase_order() if self.purpose in ("Manufacture", "Repack"): self.mark_finished_and_scrap_items() @@ -946,6 +947,19 @@ class StockEntry(StockController): item_code = d.original_item or d.item_code validate_bom_no(item_code, d.bom_no) + def validate_purchase_order(self): + if self.purpose == "Send to Subcontractor" and self.get("purchase_order"): + is_old_subcontracting_flow = frappe.db.get_value( + "Purchase Order", self.purchase_order, "is_old_subcontracting_flow" + ) + + if not is_old_subcontracting_flow: + frappe.throw( + _("Please select Subcontracting Order instead of Purchase Order {0}").format( + self.purchase_order + ) + ) + def mark_finished_and_scrap_items(self): if any([d.item_code for d in self.items if (d.is_finished_item and d.t_warehouse)]): return From 6aa8fd0f7b35d3bed60888b1aefec0d817f1c325 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 25 Aug 2022 15:50:06 +0530 Subject: [PATCH 29/72] fix: restrict party types to Supplier/Customer for AR/AP report --- .../accounts/report/accounts_receivable/accounts_receivable.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 63242e83fe..f4f2989490 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -731,6 +731,7 @@ class ReceivablePayableReport(object): def prepare_conditions(self): self.qb_selection_filter = [] party_type_field = scrub(self.party_type) + self.qb_selection_filter.append(self.ple.party_type == self.party_type) self.add_common_filters(party_type_field=party_type_field) From 9d02fbadb43d729141422321996084daf31543d1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 25 Aug 2022 20:45:35 +0200 Subject: [PATCH 30/72] fix: upgrade process to version-14 when currency opportunity wass not set --- .../update_opportunity_currency_fields.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erpnext/patches/v14_0/update_opportunity_currency_fields.py b/erpnext/patches/v14_0/update_opportunity_currency_fields.py index 076de52619..3a6f1b3a5d 100644 --- a/erpnext/patches/v14_0/update_opportunity_currency_fields.py +++ b/erpnext/patches/v14_0/update_opportunity_currency_fields.py @@ -4,6 +4,8 @@ from frappe.utils import flt import erpnext from erpnext.setup.utils import get_exchange_rate +import click + def execute(): frappe.reload_doctype("Opportunity") @@ -16,6 +18,19 @@ def execute(): for opportunity in opportunities: company_currency = erpnext.get_company_currency(opportunity.company) + if opportunity.currency is None or opportunity.currency == '': + opportunity.currency = company_currency + frappe.db.set_value( + "Opportunity", + opportunity.name, + {"currency": opportunity.currency}, + update_modified=False, + ) + click.secho( + f" Opportunity `{opportunity.name}` has no currency set. We for it to company currency : `{opportunity.currency}`\"\n", + fg="yellow", + ) + # base total and total will be 0 only since item table did not have amount field earlier if opportunity.currency != company_currency: conversion_rate = get_exchange_rate(opportunity.currency, company_currency) @@ -24,6 +39,10 @@ def execute(): conversion_rate = 1 base_opportunity_amount = flt(opportunity.opportunity_amount) + if conversion_rate is None: + print(opportunity.name,conversion_rate,opportunity.currency) + + frappe.db.set_value( "Opportunity", opportunity.name, From ac66538651f3b66c300678a89d7e53642af46e97 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 25 Aug 2022 22:35:08 +0200 Subject: [PATCH 31/72] chore: remove debug --- .../v14_0/update_opportunity_currency_fields.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/erpnext/patches/v14_0/update_opportunity_currency_fields.py b/erpnext/patches/v14_0/update_opportunity_currency_fields.py index 3a6f1b3a5d..7f093ce8c6 100644 --- a/erpnext/patches/v14_0/update_opportunity_currency_fields.py +++ b/erpnext/patches/v14_0/update_opportunity_currency_fields.py @@ -1,11 +1,10 @@ +import click import frappe from frappe.utils import flt import erpnext from erpnext.setup.utils import get_exchange_rate -import click - def execute(): frappe.reload_doctype("Opportunity") @@ -18,7 +17,7 @@ def execute(): for opportunity in opportunities: company_currency = erpnext.get_company_currency(opportunity.company) - if opportunity.currency is None or opportunity.currency == '': + if opportunity.currency is None or opportunity.currency == "": opportunity.currency = company_currency frappe.db.set_value( "Opportunity", @@ -27,7 +26,7 @@ def execute(): update_modified=False, ) click.secho( - f" Opportunity `{opportunity.name}` has no currency set. We for it to company currency : `{opportunity.currency}`\"\n", + f' Opportunity `{opportunity.name}` has no currency set. We for it to company currency : `{opportunity.currency}`"\n', fg="yellow", ) @@ -39,10 +38,6 @@ def execute(): conversion_rate = 1 base_opportunity_amount = flt(opportunity.opportunity_amount) - if conversion_rate is None: - print(opportunity.name,conversion_rate,opportunity.currency) - - frappe.db.set_value( "Opportunity", opportunity.name, From d19b664ba950828c375f312f25356b474b53759b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 25 Aug 2022 22:35:44 +0200 Subject: [PATCH 32/72] chore: better text --- erpnext/patches/v14_0/update_opportunity_currency_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches/v14_0/update_opportunity_currency_fields.py b/erpnext/patches/v14_0/update_opportunity_currency_fields.py index 7f093ce8c6..17df853fb1 100644 --- a/erpnext/patches/v14_0/update_opportunity_currency_fields.py +++ b/erpnext/patches/v14_0/update_opportunity_currency_fields.py @@ -26,7 +26,7 @@ def execute(): update_modified=False, ) click.secho( - f' Opportunity `{opportunity.name}` has no currency set. We for it to company currency : `{opportunity.currency}`"\n', + f' Opportunity `{opportunity.name}` has no currency set. We force it to company currency : `{opportunity.currency}`"\n', fg="yellow", ) From bd4b4ddd8beae9f9bcaa2e6f46d5690ee2fd64c3 Mon Sep 17 00:00:00 2001 From: Solufyin <34390782+Solufyin@users.noreply.github.com> Date: Fri, 26 Aug 2022 11:18:56 +0530 Subject: [PATCH 33/72] fix: Purchase Order creation from Sales Order --- erpnext/selling/doctype/sales_order/sales_order.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 8c03cb5b41..09a9652cca 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -892,6 +892,7 @@ def make_purchase_order_for_default_supplier(source_name, selected_items=None, t target.additional_discount_percentage = 0.0 target.discount_amount = 0.0 target.inter_company_order_reference = "" + target.shipping_rule = "" default_price_list = frappe.get_value("Supplier", supplier, "default_price_list") if default_price_list: @@ -1010,6 +1011,7 @@ def make_purchase_order(source_name, selected_items=None, target_doc=None): target.additional_discount_percentage = 0.0 target.discount_amount = 0.0 target.inter_company_order_reference = "" + target.shipping_rule = "" target.customer = "" target.customer_name = "" target.run_method("set_missing_values") From c42fef541a37223e1a7878f7b24a98be8d8df1fc Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 26 Aug 2022 13:15:55 +0530 Subject: [PATCH 34/72] chore: remove precision on discount_percentage of Sales Invoice Item --- .../doctype/sales_invoice_item/sales_invoice_item.json | 3 +-- 1 file changed, 1 insertion(+), 2 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 b417c7de03..7cddf123e2 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -282,7 +282,6 @@ "label": "Discount (%) on Price List Rate with Margin", "oldfieldname": "adj_rate", "oldfieldtype": "Float", - "precision": "2", "print_hide": 1 }, { @@ -846,7 +845,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2022-06-17 05:33:15.335912", + "modified": "2022-08-26 12:06:31.205417", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", From ac571018336c70062b9bcbf182628845eb7ff16d Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 26 Aug 2022 17:37:13 +0530 Subject: [PATCH 35/72] chore: Update code owners --- CODEOWNERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index b6aadb3f2e..e406f8f56e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -14,8 +14,8 @@ pos* @nextchamp-saqib erpnext/buying/ @rohitwaghchaure @s-aga-r erpnext/maintenance/ @rohitwaghchaure @s-aga-r erpnext/manufacturing/ @rohitwaghchaure @s-aga-r -erpnext/quality_management/ @marination @rohitwaghchaure @s-aga-r -erpnext/stock/ @marination @rohitwaghchaure @s-aga-r +erpnext/quality_management/ @rohitwaghchaure @s-aga-r +erpnext/stock/ @rohitwaghchaure @s-aga-r erpnext/crm/ @NagariaHussain erpnext/education/ @rutwikhdev From af5cbc881f03f93d0bc0b057a13e717a457ea6db Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Fri, 26 Aug 2022 22:49:40 +0530 Subject: [PATCH 36/72] chore: allow return of components in SCO (#31994) chore: allow return of components in sco --- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- .../subcontracting_order/subcontracting_order.js | 6 +++--- .../subcontracting_order/subcontracting_order.py | 11 +++++++++-- .../subcontracting_order_list.js | 1 + .../test_subcontracting_order.py | 15 ++++++++++++++- .../subcontracting_order_supplied_item.json | 5 ++--- .../subcontracting_receipt.json | 4 ++-- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index c68d1db279..7721efb639 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -2229,7 +2229,7 @@ class StockEntry(StockController): return sorted(list(set(get_serial_nos(self.pro_doc.serial_no)) - set(used_serial_nos))) def update_subcontracting_order_status(self): - if self.subcontracting_order and self.purpose == "Send to Subcontractor": + if self.subcontracting_order and self.purpose in ["Send to Subcontractor", "Material Transfer"]: from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order import ( update_subcontracting_order_status, ) diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js index c20f8ab665..bbc58fe29b 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js @@ -107,9 +107,9 @@ frappe.ui.form.on('Subcontracting Order', { get_materials_from_supplier: function (frm) { let sco_rm_details = []; - if (frm.doc.supplied_items && (frm.doc.per_received == 100)) { + if (frm.doc.supplied_items && frm.doc.per_received > 0) { frm.doc.supplied_items.forEach(d => { - if (d.total_supplied_qty && d.total_supplied_qty != d.consumed_qty) { + if (d.total_supplied_qty > 0 && d.total_supplied_qty != d.consumed_qty) { sco_rm_details.push(d.name); } }); @@ -160,7 +160,7 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll var me = this; if (doc.docstatus == 1) { - if (doc.status != 'Completed') { + if (!['Closed', 'Completed'].includes(doc.status)) { if (flt(doc.per_received) < 100) { cur_frm.add_custom_button(__('Subcontracting Receipt'), this.make_subcontracting_receipt, __('Create')); if (me.has_unsupplied_items()) { diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py index 156f027617..e6de72d494 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py @@ -153,7 +153,7 @@ class SubcontractingOrder(SubcontractingController): else: self.set_missing_values() - def update_status(self, status=None, update_modified=False): + def update_status(self, status=None, update_modified=True): if self.docstatus >= 1 and not status: if self.docstatus == 1: if self.status == "Draft": @@ -162,6 +162,10 @@ class SubcontractingOrder(SubcontractingController): status = "Completed" elif self.per_received > 0 and self.per_received < 100: status = "Partially Received" + for item in self.supplied_items: + if item.returned_qty: + status = "Closed" + break else: total_required_qty = total_supplied_qty = 0 for item in self.supplied_items: @@ -176,7 +180,10 @@ class SubcontractingOrder(SubcontractingController): elif self.docstatus == 2: status = "Cancelled" - frappe.db.set_value("Subcontracting Order", self.name, "status", status, update_modified) + if status: + frappe.db.set_value( + "Subcontracting Order", self.name, "status", status, update_modified=update_modified + ) @frappe.whitelist() diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js index 650419cf74..aab2fc927d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js @@ -10,6 +10,7 @@ frappe.listview_settings['Subcontracting Order'] = { "Completed": "green", "Partial Material Transferred": "purple", "Material Transferred": "blue", + "Closed": "red", }; return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; }, diff --git a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py index 94bb38e980..098242aed8 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py @@ -7,7 +7,10 @@ import frappe from frappe.tests.utils import FrappeTestCase from erpnext.buying.doctype.purchase_order.purchase_order import get_mapped_subcontracting_order -from erpnext.controllers.subcontracting_controller import make_rm_stock_entry +from erpnext.controllers.subcontracting_controller import ( + get_materials_from_supplier, + make_rm_stock_entry, +) from erpnext.controllers.tests.test_subcontracting_controller import ( get_rm_items, get_subcontracting_order, @@ -89,6 +92,16 @@ class TestSubcontractingOrder(FrappeTestCase): sco.load_from_db() self.assertEqual(sco.status, "Partially Received") + # Closed + ste = get_materials_from_supplier(sco.name, [d.name for d in sco.supplied_items]) + ste.save() + ste.submit() + sco.load_from_db() + self.assertEqual(sco.status, "Closed") + ste.cancel() + sco.load_from_db() + self.assertEqual(sco.status, "Partially Received") + # Completed scr = make_subcontracting_receipt(sco.name) scr.save() diff --git a/erpnext/subcontracting/doctype/subcontracting_order_supplied_item/subcontracting_order_supplied_item.json b/erpnext/subcontracting/doctype/subcontracting_order_supplied_item/subcontracting_order_supplied_item.json index a206a21ca6..8f7128be9a 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order_supplied_item/subcontracting_order_supplied_item.json +++ b/erpnext/subcontracting/doctype/subcontracting_order_supplied_item/subcontracting_order_supplied_item.json @@ -150,8 +150,7 @@ "label": "Returned Qty", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "hidden": 1 + "read_only": 1 }, { "fieldname": "total_supplied_qty", @@ -166,7 +165,7 @@ "hide_toolbar": 1, "istable": 1, "links": [], - "modified": "2022-04-07 12:58:28.208847", + "modified": "2022-08-26 16:04:56.125951", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Order Supplied Item", diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json index 84e95548e1..5cd4e637cc 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json @@ -369,7 +369,7 @@ "in_standard_filter": 1, "label": "Status", "no_copy": 1, - "options": "\nDraft\nCompleted\nReturn\nReturn Issued\nCancelled", + "options": "\nDraft\nCompleted\nReturn\nReturn Issued\nCancelled\nClosed", "print_hide": 1, "print_width": "150px", "read_only": 1, @@ -628,7 +628,7 @@ "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2022-08-22 17:30:40.827517", + "modified": "2022-08-26 21:02:26.353870", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt", From 318da16b99232033b592cc6e59f931a360758b1d Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 29 Aug 2022 14:18:39 +0530 Subject: [PATCH 37/72] fix: Rounded total for cash and non trade discount invoices --- erpnext/controllers/taxes_and_totals.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index bc38d08b80..9dbcdb04c5 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -41,6 +41,7 @@ class calculate_taxes_and_totals(object): if self.doc.apply_discount_on == "Grand Total" and self.doc.get("is_cash_or_non_trade_discount"): self.doc.grand_total -= self.doc.discount_amount self.doc.base_grand_total -= self.doc.base_discount_amount + self.set_rounded_total() self.calculate_shipping_charges() From 69ffef8c0ee728779dfb76b5eee4f15ef3421b6d Mon Sep 17 00:00:00 2001 From: MOHAMMED NIYAS <76736615+niyazrazak@users.noreply.github.com> Date: Mon, 29 Aug 2022 14:47:43 +0530 Subject: [PATCH 38/72] fix: lost quotation not to expired --- erpnext/selling/doctype/quotation/quotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 863fbc4059..96092b1523 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -268,7 +268,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): def set_expired_status(): # filter out submitted non expired quotations whose validity has been ended - cond = "`tabQuotation`.docstatus = 1 and `tabQuotation`.status != 'Expired' and `tabQuotation`.valid_till < %s" + cond = "`tabQuotation`.docstatus = 1 and `tabQuotation`.status NOT IN ('Expired', 'Lost') and `tabQuotation`.valid_till < %s" # check if those QUO have SO against it so_against_quo = """ SELECT From 9dbaaa33f5ec7df8904e71e305c26a5c904e2028 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Mon, 29 Aug 2022 15:07:20 +0530 Subject: [PATCH 39/72] fix: AD not getting copied from SCO while creating a SE (#32004) --- .../stock/doctype/stock_entry/stock_entry.py | 40 ++++-- .../subcontracting_order.js | 128 ++---------------- 2 files changed, 38 insertions(+), 130 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 7721efb639..d70952282d 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -2568,27 +2568,26 @@ def get_supplied_items( @frappe.whitelist() def get_items_from_subcontracting_order(source_name, target_doc=None): - sco = frappe.get_doc("Subcontracting Order", source_name) + def post_process(source, target): + target.stock_entry_type = target.purpose = "Send to Subcontractor" + target.subcontracting_order = source_name - if sco.docstatus == 1: - if target_doc and isinstance(target_doc, str): - target_doc = frappe.get_doc(json.loads(target_doc)) - - if target_doc.items: - target_doc.items = [] + if target.items: + target.items = [] warehouses = {} - for item in sco.items: + for item in source.items: warehouses[item.name] = item.warehouse - for item in sco.supplied_items: - target_doc.append( + for item in source.supplied_items: + target.append( "items", { "s_warehouse": warehouses.get(item.reference_name), - "t_warehouse": sco.supplier_warehouse, + "t_warehouse": source.supplier_warehouse, + "subcontracted_item": item.main_item_code, "item_code": item.rm_item_code, - "qty": item.required_qty, + "qty": max(item.required_qty - item.total_supplied_qty, 0), "transfer_qty": item.required_qty, "uom": item.stock_uom, "stock_uom": item.stock_uom, @@ -2596,6 +2595,23 @@ def get_items_from_subcontracting_order(source_name, target_doc=None): }, ) + target_doc = get_mapped_doc( + "Subcontracting Order", + source_name, + { + "Subcontracting Order": { + "doctype": "Stock Entry", + "field_no_map": ["purchase_order"], + "validation": { + "docstatus": ["=", 1], + }, + }, + }, + target_doc, + post_process, + ignore_child_tables=True, + ) + return target_doc diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js index bbc58fe29b..065ef39db3 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js @@ -164,10 +164,7 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll if (flt(doc.per_received) < 100) { cur_frm.add_custom_button(__('Subcontracting Receipt'), this.make_subcontracting_receipt, __('Create')); if (me.has_unsupplied_items()) { - cur_frm.add_custom_button(__('Material to Supplier'), - () => { - me.make_stock_entry(); - }, __('Transfer')); + cur_frm.add_custom_button(__('Material to Supplier'), this.make_stock_entry, __('Transfer')); } } cur_frm.page.set_inner_btn_group_as_primary(__('Create')); @@ -195,120 +192,6 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll transaction_controller.autofill_warehouse(child_table, warehouse_field, warehouse); } - make_stock_entry() { - var items = $.map(cur_frm.doc.items, (d) => d.bom ? d.item_code : false); - var me = this; - - if (items.length >= 1) { - me.raw_material_data = []; - me.show_dialog = 1; - let title = __('Transfer Material to Supplier'); - let fields = [ - { fieldtype: 'Section Break', label: __('Raw Materials') }, - { - fieldname: 'sub_con_rm_items', fieldtype: 'Table', label: __('Items'), - fields: [ - { - fieldtype: 'Data', - fieldname: 'item_code', - label: __('Item'), - read_only: 1, - in_list_view: 1 - }, - { - fieldtype: 'Data', - fieldname: 'rm_item_code', - label: __('Raw Material'), - read_only: 1, - in_list_view: 1 - }, - { - fieldtype: 'Float', - read_only: 1, - fieldname: 'qty', - label: __('Quantity'), - in_list_view: 1 - }, - { - fieldtype: 'Data', - read_only: 1, - fieldname: 'warehouse', - label: __('Reserve Warehouse'), - in_list_view: 1 - }, - { - fieldtype: 'Float', - read_only: 1, - fieldname: 'rate', - label: __('Rate'), - hidden: 1 - }, - { - fieldtype: 'Float', - read_only: 1, - fieldname: 'amount', - label: __('Amount'), - hidden: 1 - }, - { - fieldtype: 'Link', - read_only: 1, - fieldname: 'uom', - label: __('UOM'), - hidden: 1 - } - ], - data: me.raw_material_data, - get_data: () => me.raw_material_data - } - ]; - - me.dialog = new frappe.ui.Dialog({ - title: title, fields: fields - }); - - if (me.frm.doc['supplied_items']) { - me.frm.doc['supplied_items'].forEach((item) => { - if (item.rm_item_code && item.main_item_code && item.required_qty - item.supplied_qty != 0) { - me.raw_material_data.push({ - 'name': item.name, - 'item_code': item.main_item_code, - 'rm_item_code': item.rm_item_code, - 'item_name': item.rm_item_code, - 'qty': item.required_qty - item.supplied_qty, - 'warehouse': item.reserve_warehouse, - 'rate': item.rate, - 'amount': item.amount, - 'stock_uom': item.stock_uom - }); - me.dialog.fields_dict.sub_con_rm_items.grid.refresh(); - } - }); - } - - me.dialog.get_field('sub_con_rm_items').check_all_rows(); - - me.dialog.show(); - this.dialog.set_primary_action(__('Transfer'), () => { - me.values = me.dialog.get_values(); - if (me.values) { - me.values.sub_con_rm_items.map((row, i) => { - if (!row.item_code || !row.rm_item_code || !row.warehouse || !row.qty || row.qty === 0) { - let row_id = i + 1; - frappe.throw(__('Item Code, warehouse and quantity are required on row {0}', [row_id])); - } - }); - me.make_rm_stock_entry(me.dialog.fields_dict.sub_con_rm_items.grid.get_selected_children()); - me.dialog.hide(); - } - }); - } - - me.dialog.get_close_btn().on('click', () => { - me.dialog.hide(); - }); - } - has_unsupplied_items() { return this.frm.doc['supplied_items'].some(item => item.required_qty > item.supplied_qty); } @@ -321,6 +204,15 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll }); } + make_stock_entry() { + frappe.model.open_mapped_doc({ + method: 'erpnext.stock.doctype.stock_entry.stock_entry.get_items_from_subcontracting_order', + source_name: cur_frm.doc.name, + freeze: true, + freeze_message: __('Creating Stock Entry ...') + }); + } + make_rm_stock_entry(rm_items) { frappe.call({ method: 'erpnext.controllers.subcontracting_controller.make_rm_stock_entry', From 5782c4469ac98b691564af8f1e38330934584558 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 22 Aug 2022 15:46:04 +0530 Subject: [PATCH 40/72] refactor: re-add remarks field to payment ledger and AR/AP report --- .../payment_ledger_entry/payment_ledger_entry.json | 10 ++++++++-- .../report/accounts_receivable/accounts_receivable.js | 5 +++++ .../report/accounts_receivable/accounts_receivable.py | 5 +++++ erpnext/accounts/utils.py | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json index 4596b00fc1..22842cec0f 100644 --- a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json +++ b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json @@ -22,7 +22,8 @@ "amount", "account_currency", "amount_in_account_currency", - "delinked" + "delinked", + "remarks" ], "fields": [ { @@ -136,12 +137,17 @@ "fieldtype": "Link", "label": "Finance Book", "options": "Finance Book" + }, + { + "fieldname": "remarks", + "fieldtype": "Text", + "label": "Remarks" } ], "in_create": 1, "index_web_pages_for_search": 1, "links": [], - "modified": "2022-07-11 09:13:54.379168", + "modified": "2022-08-22 15:32:56.629430", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Ledger Entry", diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js index 0238711a70..0b4e577f6c 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js @@ -178,6 +178,11 @@ frappe.query_reports["Accounts Receivable"] = { "fieldtype": "Data", "hidden": 1 }, + { + "fieldname": "show_remarks", + "label": __("Show Remarks"), + "fieldtype": "Check", + }, { "fieldname": "customer_name", "label": __("Customer Name"), diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 63242e83fe..90a431d63c 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -119,6 +119,7 @@ class ReceivablePayableReport(object): party_account=ple.account, posting_date=ple.posting_date, account_currency=ple.account_currency, + remarks=ple.remarks, invoiced=0.0, paid=0.0, credit_note=0.0, @@ -697,6 +698,7 @@ class ReceivablePayableReport(object): ple.account_currency, ple.amount, ple.amount_in_account_currency, + ple.remarks, ) .where(ple.delinked == 0) .where(Criterion.all(self.qb_selection_filter)) @@ -974,6 +976,9 @@ class ReceivablePayableReport(object): options="Supplier Group", ) + if self.filters.show_remarks: + self.add_column(label=_("Remarks"), fieldname="remarks", fieldtype="Text", width=200), + def add_column(self, label, fieldname=None, fieldtype="Currency", options=None, width=120): if not fieldname: fieldname = scrub(label) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 018e8f9301..f61e8ac960 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1424,6 +1424,7 @@ def create_payment_ledger_entry( "amount": dr_or_cr, "amount_in_account_currency": dr_or_cr_account_currency, "delinked": True if cancel else False, + "remarks": gle.remarks, } ) From 3a6b095ed45fbc47628e4b189e1d1a89e17ffc25 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 23 Aug 2022 15:10:55 +0530 Subject: [PATCH 41/72] chore: patch for migrating remarks to payment ledger --- ...grate_remarks_from_gl_to_payment_ledger.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 erpnext/patches/v14_0/migrate_remarks_from_gl_to_payment_ledger.py diff --git a/erpnext/patches/v14_0/migrate_remarks_from_gl_to_payment_ledger.py b/erpnext/patches/v14_0/migrate_remarks_from_gl_to_payment_ledger.py new file mode 100644 index 0000000000..062d24b78b --- /dev/null +++ b/erpnext/patches/v14_0/migrate_remarks_from_gl_to_payment_ledger.py @@ -0,0 +1,56 @@ +import frappe +from frappe import qb +from frappe.utils import create_batch + + +def execute(): + if frappe.reload_doc("accounts", "doctype", "payment_ledger_entry"): + + gle = qb.DocType("GL Entry") + ple = qb.DocType("Payment Ledger Entry") + + # get ple and their remarks from GL Entry + pl_entries = ( + qb.from_(ple) + .left_join(gle) + .on( + (ple.account == gle.account) + & (ple.party_type == gle.party_type) + & (ple.party == gle.party) + & (ple.voucher_type == gle.voucher_type) + & (ple.voucher_no == gle.voucher_no) + & (ple.company == gle.company) + ) + .select( + ple.company, + ple.account, + ple.party_type, + ple.party, + ple.voucher_type, + ple.voucher_no, + gle.remarks.as_("gle_remarks"), + ) + .where((ple.delinked == 0) & (gle.is_cancelled == 0)) + .run(as_dict=True) + ) + + if pl_entries: + # split into multiple batches, update and commit for each batch + batch_size = 1000 + for batch in create_batch(pl_entries, batch_size): + for entry in batch: + query = ( + qb.update(ple) + .set(ple.remarks, entry.gle_remarks) + .where( + (ple.company == entry.company) + & (ple.account == entry.account) + & (ple.party_type == entry.party_type) + & (ple.party == entry.party) + & (ple.voucher_type == entry.voucher_type) + & (ple.voucher_no == entry.voucher_no) + ) + ) + query.run() + + frappe.db.commit() From d522f13d556af53ba6b6cb9c833e14aefc0226cb Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 29 Aug 2022 15:31:26 +0530 Subject: [PATCH 42/72] chore: add remarks migration to patches.txt --- erpnext/patches.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d92353aca4..4729add16b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -311,4 +311,5 @@ erpnext.patches.v14_0.remove_india_localisation # 14-07-2022 erpnext.patches.v13_0.fix_number_and_frequency_for_monthly_depreciation erpnext.patches.v14_0.remove_hr_and_payroll_modules # 20-07-2022 erpnext.patches.v14_0.fix_crm_no_of_employees -erpnext.patches.v14_0.create_accounting_dimensions_in_subcontracting_doctypes \ No newline at end of file +erpnext.patches.v14_0.create_accounting_dimensions_in_subcontracting_doctypes +erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger From 2d41704424899a8cc1992a9c379a5d340effbce8 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 29 Aug 2022 20:50:27 +0530 Subject: [PATCH 43/72] fix(patch): update sla doctype directly (#32014) fix: update sla doctype directly --- erpnext/patches/v13_0/add_doctype_to_sla.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v13_0/add_doctype_to_sla.py b/erpnext/patches/v13_0/add_doctype_to_sla.py index 5f5974f65d..2d3b0de5b5 100644 --- a/erpnext/patches/v13_0/add_doctype_to_sla.py +++ b/erpnext/patches/v13_0/add_doctype_to_sla.py @@ -14,7 +14,8 @@ def execute(): for sla in frappe.get_all("Service Level Agreement"): agreement = frappe.get_doc("Service Level Agreement", sla.name) - agreement.document_type = "Issue" + agreement.db_set("document_type", "Issue") + agreement.reload() agreement.apply_sla_for_resolution = 1 agreement.append("sla_fulfilled_on", {"status": "Resolved"}) agreement.append("sla_fulfilled_on", {"status": "Closed"}) From 73f4d5931d881b1eacc4fde89affd291f88c5ef1 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Mon, 29 Aug 2022 18:26:07 +0200 Subject: [PATCH 44/72] fix: permissions for Task Type (#32016) --- .../projects/doctype/task_type/task_type.json | 123 +++++------------- 1 file changed, 33 insertions(+), 90 deletions(-) diff --git a/erpnext/projects/doctype/task_type/task_type.json b/erpnext/projects/doctype/task_type/task_type.json index 3254444a48..b04264e9c7 100644 --- a/erpnext/projects/doctype/task_type/task_type.json +++ b/erpnext/projects/doctype/task_type/task_type.json @@ -1,127 +1,70 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, + "actions": [], "autoname": "Prompt", - "beta": 0, "creation": "2019-04-19 15:04:05.317138", - "custom": 0, - "docstatus": 0, "doctype": "DocType", - "document_type": "", - "editable_grid": 0, "engine": "InnoDB", + "field_order": [ + "weight", + "description" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, "fieldname": "weight", "fieldtype": "Float", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Weight", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Weight" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, "fieldname": "description", "fieldtype": "Small Text", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Description", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Description" } ], - "has_web_view": 0, - "hide_toolbar": 0, - "idx": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2019-04-19 15:31:48.080164", + "links": [], + "modified": "2022-08-29 17:46:41.342979", "modified_by": "Administrator", "module": "Projects", "name": "Task Type", - "name_case": "", + "naming_rule": "Set by user", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "System Manager", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects User", + "share": 1 } ], "quick_entry": 1, - "read_only": 0, - "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "ASC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "states": [], + "track_changes": 1 } \ No newline at end of file From ffa3071d36e62eb721bc9a3105fb7af4b93cf8fc Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 30 Aug 2022 15:43:57 +0530 Subject: [PATCH 45/72] fix: force delete old report docs (#32026) --- erpnext/patches/v13_0/delete_old_sales_reports.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v13_0/delete_old_sales_reports.py b/erpnext/patches/v13_0/delete_old_sales_reports.py index b31c9d17d7..1b53da755c 100644 --- a/erpnext/patches/v13_0/delete_old_sales_reports.py +++ b/erpnext/patches/v13_0/delete_old_sales_reports.py @@ -16,18 +16,18 @@ def execute(): delete_auto_email_reports(report) check_and_delete_linked_reports(report) - frappe.delete_doc("Report", report) + frappe.delete_doc("Report", report, force=True) def delete_auto_email_reports(report): """Check for one or multiple Auto Email Reports and delete""" auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": report}, ["name"]) for auto_email_report in auto_email_reports: - frappe.delete_doc("Auto Email Report", auto_email_report[0]) + frappe.delete_doc("Auto Email Report", auto_email_report[0], force=True) def delete_links_from_desktop_icons(report): """Check for one or multiple Desktop Icons and delete""" desktop_icons = frappe.db.get_values("Desktop Icon", {"_report": report}, ["name"]) for desktop_icon in desktop_icons: - frappe.delete_doc("Desktop Icon", desktop_icon[0]) + frappe.delete_doc("Desktop Icon", desktop_icon[0], force=True) From eefc9b71725d5530e3bd259a299d3c0673385a4a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 30 Aug 2022 19:16:36 +0530 Subject: [PATCH 46/72] fix: Loan Interest accruals for 0 rated loans --- .../loan_interest_accrual/loan_interest_accrual.py | 1 - .../doctype/loan_repayment/loan_repayment.py | 1 + .../process_loan_interest_accrual.py | 13 ++++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py index 6d62aefdca..9a6bcd4daa 100644 --- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py @@ -236,7 +236,6 @@ def get_term_loans(date, term_loan=None, loan_type=None): AND l.is_term_loan =1 AND rs.payment_date <= %s AND rs.is_accrued=0 {0} - AND rs.interest_amount > 0 AND l.status = 'Disbursed' ORDER BY rs.payment_date""".format( condition diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index 29da988ce4..018832c7d7 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -735,6 +735,7 @@ def get_amounts(amounts, against_loan, posting_date): ) amounts["pending_accrual_entries"] = pending_accrual_entries amounts["unaccrued_interest"] = flt(unaccrued_interest, precision) + amounts["written_off_amount"] = flt(against_loan_doc.written_off_amount, precision) if final_due_date: amounts["due_date"] = final_due_date diff --git a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py index 81464a36c3..25c72d91a7 100644 --- a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py @@ -57,7 +57,7 @@ def process_loan_interest_accrual_for_demand_loans( def process_loan_interest_accrual_for_term_loans(posting_date=None, loan_type=None, loan=None): - if not term_loan_accrual_pending(posting_date or nowdate()): + if not term_loan_accrual_pending(posting_date or nowdate(), loan=loan): return loan_process = frappe.new_doc("Process Loan Interest Accrual") @@ -71,9 +71,12 @@ def process_loan_interest_accrual_for_term_loans(posting_date=None, loan_type=No return loan_process.name -def term_loan_accrual_pending(date): - pending_accrual = frappe.db.get_value( - "Repayment Schedule", {"payment_date": ("<=", date), "is_accrued": 0} - ) +def term_loan_accrual_pending(date, loan=None): + filters = {"payment_date": ("<=", date), "is_accrued": 0} + + if loan: + filters.update({"parent": loan}) + + pending_accrual = frappe.db.get_value("Repayment Schedule", filters) return pending_accrual From a76d3827ec5355b7eecedc3e66bfd85b119d5211 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 30 Aug 2022 19:24:57 +0530 Subject: [PATCH 47/72] chore: Add check for principal amount --- .../doctype/loan_interest_accrual/loan_interest_accrual.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py index 9a6bcd4daa..cac3f1f0f3 100644 --- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py @@ -236,6 +236,7 @@ def get_term_loans(date, term_loan=None, loan_type=None): AND l.is_term_loan =1 AND rs.payment_date <= %s AND rs.is_accrued=0 {0} + AND rs.principal_amount > 0 AND l.status = 'Disbursed' ORDER BY rs.payment_date""".format( condition From 4a38ce659d4da7400fd219060cbcdd77ce6ccf1b Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 22 Aug 2022 00:23:22 +0530 Subject: [PATCH 48/72] refactor!: drop redisearch incr: replace text and tag fields incr: use rediswrapper's make key incr: indexDefinition from redis incr: replace index creation incr: replace AutoCompleter incr: replace product search ac incr: replace client querying fix: broken redisearch load test fix: pass actual query to get suggestion --- erpnext/e_commerce/redisearch_utils.py | 58 ++++++++++++----------- erpnext/templates/pages/product_search.py | 21 ++++---- pyproject.toml | 1 - 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/erpnext/e_commerce/redisearch_utils.py b/erpnext/e_commerce/redisearch_utils.py index 1f649c7b48..87ca9bd83d 100644 --- a/erpnext/e_commerce/redisearch_utils.py +++ b/erpnext/e_commerce/redisearch_utils.py @@ -7,7 +7,9 @@ import frappe from frappe import _ from frappe.utils.redis_wrapper import RedisWrapper from redis import ResponseError -from redisearch import AutoCompleter, Client, IndexDefinition, Suggestion, TagField, TextField +from redis.commands.search.field import TagField, TextField +from redis.commands.search.indexDefinition import IndexDefinition +from redis.commands.search.suggestion import Suggestion WEBSITE_ITEM_INDEX = "website_items_index" WEBSITE_ITEM_KEY_PREFIX = "website_item:" @@ -35,12 +37,9 @@ def is_redisearch_enabled(): def is_search_module_loaded(): try: cache = frappe.cache() - out = cache.execute_command("MODULE LIST") - - parsed_output = " ".join( - (" ".join([frappe.as_unicode(s) for s in o if not isinstance(s, int)]) for o in out) - ) - return "search" in parsed_output + for module in cache.module_list(): + if module.get(b"name") == b"search": + return True except Exception: return False # handling older redis versions @@ -58,18 +57,18 @@ def if_redisearch_enabled(function): def make_key(key): - return "{0}|{1}".format(frappe.conf.db_name, key).encode("utf-8") + return frappe.cache().make_key(key) @if_redisearch_enabled def create_website_items_index(): "Creates Index Definition." - # CREATE index - client = Client(make_key(WEBSITE_ITEM_INDEX), conn=frappe.cache()) + redis = frappe.cache() + index = redis.ft(WEBSITE_ITEM_INDEX) try: - client.drop_index() # drop if already exists + index.dropindex() # drop if already exists except ResponseError: # will most likely raise a ResponseError if index does not exist # ignore and create index @@ -86,9 +85,10 @@ def create_website_items_index(): if "web_item_name" in idx_fields: idx_fields.remove("web_item_name") - idx_fields = list(map(to_search_field, idx_fields)) + idx_fields = [to_search_field(f) for f in idx_fields] - client.create_index( + # TODO: sortable? + index.create_index( [TextField("web_item_name", sortable=True)] + idx_fields, definition=idx_def, ) @@ -119,8 +119,8 @@ def insert_item_to_index(website_item_doc): @if_redisearch_enabled def insert_to_name_ac(web_name, doc_name): - ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=frappe.cache()) - ac.add_suggestions(Suggestion(web_name, payload=doc_name)) + ac = frappe.cache().ft() + ac.sugadd(WEBSITE_ITEM_NAME_AUTOCOMPLETE, Suggestion(web_name, payload=doc_name)) def create_web_item_map(website_item_doc): @@ -157,9 +157,8 @@ def delete_item_from_index(website_item_doc): @if_redisearch_enabled def delete_from_ac_dict(website_item_doc): """Removes this items's name from autocomplete dictionary""" - cache = frappe.cache() - name_ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=cache) - name_ac.delete(website_item_doc.web_item_name) + ac = frappe.cache().ft() + ac.sugdel(website_item_doc.web_item_name) @if_redisearch_enabled @@ -170,8 +169,6 @@ def define_autocomplete_dictionary(): """ cache = frappe.cache() - item_ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=cache) - item_group_ac = AutoCompleter(make_key(WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE), conn=cache) # Delete both autocomplete dicts try: @@ -180,38 +177,43 @@ def define_autocomplete_dictionary(): except Exception: raise_redisearch_error() - create_items_autocomplete_dict(autocompleter=item_ac) - create_item_groups_autocomplete_dict(autocompleter=item_group_ac) + create_items_autocomplete_dict() + create_item_groups_autocomplete_dict() @if_redisearch_enabled -def create_items_autocomplete_dict(autocompleter): +def create_items_autocomplete_dict(): "Add items as suggestions in Autocompleter." + + ac = frappe.cache().ft() items = frappe.get_all( "Website Item", fields=["web_item_name", "item_group"], filters={"published": 1} ) - for item in items: - autocompleter.add_suggestions(Suggestion(item.web_item_name)) + ac.sugadd(WEBSITE_ITEM_NAME_AUTOCOMPLETE, Suggestion(item.web_item_name)) @if_redisearch_enabled -def create_item_groups_autocomplete_dict(autocompleter): +def create_item_groups_autocomplete_dict(): "Add item groups with weightage as suggestions in Autocompleter." + published_item_groups = frappe.get_all( "Item Group", fields=["name", "route", "weightage"], filters={"show_in_website": 1} ) if not published_item_groups: return + ac = frappe.cache().ft() + for item_group in published_item_groups: payload = json.dumps({"name": item_group.name, "route": item_group.route}) - autocompleter.add_suggestions( + ac.sugadd( + WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE, Suggestion( string=item_group.name, score=frappe.utils.flt(item_group.weightage) or 1.0, payload=payload, # additional info that can be retrieved later - ) + ), ) diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py index 0768cc3fa6..f40fd479f4 100644 --- a/erpnext/templates/pages/product_search.py +++ b/erpnext/templates/pages/product_search.py @@ -5,14 +5,13 @@ import json import frappe from frappe.utils import cint, cstr -from redisearch import AutoCompleter, Client, Query +from redis.commands.search.query import Query from erpnext.e_commerce.redisearch_utils import ( WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE, WEBSITE_ITEM_INDEX, WEBSITE_ITEM_NAME_AUTOCOMPLETE, is_redisearch_enabled, - make_key, ) from erpnext.e_commerce.shopping_cart.product_info import set_product_info_for_website from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html @@ -88,15 +87,17 @@ def product_search(query, limit=10, fuzzy_search=True): if not query: return search_results - red = frappe.cache() + redis = frappe.cache() query = clean_up_query(query) # TODO: Check perf/correctness with Suggestions & Query vs only Query # TODO: Use Levenshtein Distance in Query (max=3) - ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=red) - client = Client(make_key(WEBSITE_ITEM_INDEX), conn=red) - suggestions = ac.get_suggestions( - query, num=limit, fuzzy=fuzzy_search and len(query) > 3 # Fuzzy on length < 3 can be real slow + redisearch = redis.ft(WEBSITE_ITEM_INDEX) + suggestions = redisearch.sugget( + WEBSITE_ITEM_NAME_AUTOCOMPLETE, + query, + num=limit, + fuzzy=fuzzy_search and len(query) > 3, ) # Build a query @@ -106,8 +107,8 @@ def product_search(query, limit=10, fuzzy_search=True): query_string += f"|('{clean_up_query(s.string)}')" q = Query(query_string) + results = redisearch.search(q) - results = client.search(q) search_results["results"] = list(map(convert_to_dict, results.docs)) search_results["results"] = sorted( search_results["results"], key=lambda k: frappe.utils.cint(k["ranking"]), reverse=True @@ -141,8 +142,8 @@ def get_category_suggestions(query): if not query: return search_results - ac = AutoCompleter(make_key(WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE), conn=frappe.cache()) - suggestions = ac.get_suggestions(query, num=10, with_payloads=True) + ac = frappe.cache().ft() + suggestions = ac.sugget(WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE, query, num=10, with_payloads=True) results = [json.loads(s.payload) for s in suggestions] diff --git a/pyproject.toml b/pyproject.toml index 5acfd39272..14684f3491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ dependencies = [ "pycountry~=20.7.3", "python-stdnum~=1.16", "Unidecode~=1.2.0", - "redisearch~=2.1.0", # integration dependencies "gocardless-pro~=1.22.0", From 30039e8e624f341f1f32b845094d1a1e96e29799 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 31 Aug 2022 15:38:05 +0530 Subject: [PATCH 49/72] fix: encode thumbnail URL If it contains space the URL won't load --- erpnext/e_commerce/product_ui/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/e_commerce/product_ui/search.js b/erpnext/e_commerce/product_ui/search.js index 61922459e5..1688cc1fb6 100644 --- a/erpnext/e_commerce/product_ui/search.js +++ b/erpnext/e_commerce/product_ui/search.js @@ -200,7 +200,7 @@ erpnext.ProductSearch = class { let thumbnail = res.thumbnail || '/assets/erpnext/images/ui-states/cart-empty-state.png'; html += `