From 2834d25ce31801808781a9fc203e942c89636cc3 Mon Sep 17 00:00:00 2001 From: Wolfram Schmidt Date: Sun, 24 Mar 2024 07:43:40 +0100 Subject: [PATCH 01/15] refactor: better pop message for Internal Customer validation -added more meaningful description to message when using "internal Customer" scenario (cherry picked from commit b132892b257dcad80cb85092b3b19cfc5532ece6) --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 2a86d0daf45..6a1a5f3a7c9 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1817,9 +1817,9 @@ def validate_inter_company_party(doctype, party, company, inter_company_referenc companies = [d.company for d in companies] if not company in companies: frappe.throw( - _("{0} not allowed to transact with {1}. Please change the Company.").format( - partytype, company - ) + _( + "{0} not allowed to transact with {1}. Please change the Company or add the Company in the 'Allowed To Transact With'-Section in the Customer record." + ).format(_(partytype), company) ) From 4f4470b9d209dc5b2c04a2c61029d69dd4f976c8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 27 Mar 2024 15:07:44 +0530 Subject: [PATCH 02/15] fix: Priority not copied from project template (cherry picked from commit 33fd7b8a1f125e0387a7a7851a149f91297b9958) --- erpnext/projects/doctype/project/project.py | 1 + erpnext/projects/doctype/project/test_project.py | 9 +++++++-- erpnext/projects/doctype/task/test_task.py | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 748c755d377..8704147cd22 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -87,6 +87,7 @@ class Project(Document): is_group=task_details.is_group, color=task_details.color, template_task=task_details.name, + priority=task_details.priority, ) ).insert() diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index e49fecd1f47..b8340ffe193 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -23,7 +23,11 @@ class TestProject(FrappeTestCase): task1 = task_exists("Test Template Task with No Parent and Dependency") if not task1: task1 = create_task( - subject="Test Template Task with No Parent and Dependency", is_template=1, begin=5, duration=3 + subject="Test Template Task with No Parent and Dependency", + is_template=1, + begin=5, + duration=3, + priority="High", ) template = make_project_template( @@ -32,11 +36,12 @@ class TestProject(FrappeTestCase): project = get_project(project_name, template) tasks = frappe.get_all( "Task", - ["subject", "exp_end_date", "depends_on_tasks"], + ["subject", "exp_end_date", "depends_on_tasks", "priority"], dict(project=project.name), order_by="creation asc", ) + self.assertEqual(tasks[0].priority, "High") self.assertEqual(tasks[0].subject, "Test Template Task with No Parent and Dependency") self.assertEqual(getdate(tasks[0].exp_end_date), calculate_end_date(project, 5, 3)) self.assertEqual(len(tasks), 1) diff --git a/erpnext/projects/doctype/task/test_task.py b/erpnext/projects/doctype/task/test_task.py index c0333f8f590..ea7d6edcdf9 100644 --- a/erpnext/projects/doctype/task/test_task.py +++ b/erpnext/projects/doctype/task/test_task.py @@ -122,6 +122,7 @@ def create_task( begin=0, duration=0, save=True, + priority=None, ): if not frappe.db.exists("Task", subject): task = frappe.new_doc("Task") @@ -139,6 +140,7 @@ def create_task( task.duration = duration task.is_group = is_group task.parent_task = parent_task + task.priority = priority if save: task.save() else: From e778d7e69041f2f4cd63c6ecaa23a8146c86fe4f Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 27 Mar 2024 20:05:27 +0530 Subject: [PATCH 03/15] fix: do not fetch received items in purchase receipt (cherry picked from commit 5bff4349020f3c54fdd7e30a294f1042b714a6fc) --- erpnext/controllers/stock_controller.py | 2 +- erpnext/stock/doctype/delivery_note/delivery_note.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index bc3ec7f93c2..8d7d888c2c9 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -669,7 +669,7 @@ class StockController(AccountsController): self.validate_multi_currency() self.validate_packed_items() - if self.get("is_internal_supplier"): + if self.get("is_internal_supplier") and self.docstatus == 1: self.validate_internal_transfer_qty() else: self.validate_internal_transfer_warehouse() diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index a402bb5aed2..0a389b602a5 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -965,6 +965,9 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None): for tax in get_taxes_and_charges(master_doctype, target.get("taxes_and_charges")): target.append("taxes", tax) + if not target.get("items"): + frappe.throw(_("All items have already been received")) + def update_details(source_doc, target_doc, source_parent): target_doc.inter_company_invoice_reference = source_doc.name if target_doc.doctype == "Purchase Receipt": @@ -1020,6 +1023,10 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None): shipping_address_name=target_doc.shipping_address_name, ) + def update_item(source, target, source_parent): + if source_parent.doctype == "Delivery Note" and source.received_qty: + target.qty = flt(source.qty) + flt(source.returned_qty) - flt(source.received_qty) + doclist = get_mapped_doc( doctype, source_name, @@ -1043,6 +1050,8 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None): "Material_request_item": "material_request_item", }, "field_no_map": ["warehouse"], + "condition": lambda item: item.received_qty < item.qty + item.returned_qty, + "postprocess": update_item, }, }, target_doc, From b5629d2d4e93adffda39f027a2de861167b709b6 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Thu, 28 Mar 2024 10:30:13 +0530 Subject: [PATCH 04/15] fix: markdown to text editor set for supplier quotation (cherry picked from commit 9828d34b19e575697b4d5bbc624689535160aa69) # Conflicts: # erpnext/buying/doctype/supplier_quotation/supplier_quotation.json # erpnext/buying/doctype/supplier_quotation/supplier_quotation.py --- .../supplier_quotation.json | 6 +- .../supplier_quotation/supplier_quotation.py | 92 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index f13ceb04a50..a35719f81ad 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -461,7 +461,7 @@ }, { "fieldname": "other_charges_calculation", - "fieldtype": "Markdown Editor", + "fieldtype": "Text Editor", "label": "Taxes and Charges Calculation", "no_copy": 1, "oldfieldtype": "HTML", @@ -927,7 +927,11 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2024-03-20 16:03:59.069145", +======= + "modified": "2024-03-28 10:20:30.231915", +>>>>>>> 9828d34b19 (fix: markdown to text editor set for supplier quotation) "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation", diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index e27fbe8aaa2..7570063aef1 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -14,6 +14,98 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class SupplierQuotation(BuyingController): +<<<<<<< HEAD +======= + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail + from erpnext.accounts.doctype.purchase_taxes_and_charges.purchase_taxes_and_charges import ( + PurchaseTaxesandCharges, + ) + from erpnext.buying.doctype.supplier_quotation_item.supplier_quotation_item import ( + SupplierQuotationItem, + ) + + additional_discount_percentage: DF.Float + address_display: DF.TextEditor | None + amended_from: DF.Link | None + apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] + auto_repeat: DF.Link | None + base_discount_amount: DF.Currency + base_grand_total: DF.Currency + base_in_words: DF.Data | None + base_net_total: DF.Currency + base_rounded_total: DF.Currency + base_rounding_adjustment: DF.Currency + base_taxes_and_charges_added: DF.Currency + base_taxes_and_charges_deducted: DF.Currency + base_total: DF.Currency + base_total_taxes_and_charges: DF.Currency + billing_address: DF.Link | None + billing_address_display: DF.TextEditor | None + buying_price_list: DF.Link | None + company: DF.Link + contact_display: DF.SmallText | None + contact_email: DF.Data | None + contact_mobile: DF.SmallText | None + contact_person: DF.Link | None + conversion_rate: DF.Float + cost_center: DF.Link | None + currency: DF.Link + disable_rounded_total: DF.Check + discount_amount: DF.Currency + grand_total: DF.Currency + group_same_items: DF.Check + ignore_pricing_rule: DF.Check + in_words: DF.Data | None + incoterm: DF.Link | None + is_subcontracted: DF.Check + items: DF.Table[SupplierQuotationItem] + language: DF.Data | None + letter_head: DF.Link | None + named_place: DF.Data | None + naming_series: DF.Literal["PUR-SQTN-.YYYY.-"] + net_total: DF.Currency + opportunity: DF.Link | None + other_charges_calculation: DF.TextEditor | None + plc_conversion_rate: DF.Float + price_list_currency: DF.Link | None + pricing_rules: DF.Table[PricingRuleDetail] + project: DF.Link | None + quotation_number: DF.Data | None + rounded_total: DF.Currency + rounding_adjustment: DF.Currency + select_print_heading: DF.Link | None + shipping_address: DF.Link | None + shipping_address_display: DF.TextEditor | None + shipping_rule: DF.Link | None + status: DF.Literal["", "Draft", "Submitted", "Stopped", "Cancelled", "Expired"] + supplier: DF.Link + supplier_address: DF.Link | None + supplier_name: DF.Data | None + tax_category: DF.Link | None + taxes: DF.Table[PurchaseTaxesandCharges] + taxes_and_charges: DF.Link | None + taxes_and_charges_added: DF.Currency + taxes_and_charges_deducted: DF.Currency + tc_name: DF.Link | None + terms: DF.TextEditor | None + title: DF.Data | None + total: DF.Currency + total_net_weight: DF.Float + total_qty: DF.Float + total_taxes_and_charges: DF.Currency + transaction_date: DF.Date + valid_till: DF.Date | None + # end: auto-generated types + +>>>>>>> 9828d34b19 (fix: markdown to text editor set for supplier quotation) def validate(self): super(SupplierQuotation, self).validate() From 4d6fad26f3fee7f54c7b64e4f8720f1759a82e8f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 28 Mar 2024 13:28:59 +0530 Subject: [PATCH 05/15] refactor: use sql to clear comments (cherry picked from commit 1f46c1530e68263ca2b5f9f86f59bb06063cd05e) --- .../transaction_deletion_record.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py index db5024bbc19..c32df4ec9d0 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py +++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.py @@ -388,17 +388,11 @@ class TransactionDeletionRecord(Document): frappe.delete_doc("Communication", batch, ignore_permissions=True) def delete_comments(self, doctype, reference_doc_names): - comments = frappe.get_all( - "Comment", - filters={"reference_doctype": doctype, "reference_name": ["in", reference_doc_names]}, - ) - comment_names = [c.name for c in comments] - - if not comment_names: - return - - for batch in create_batch(comment_names, self.batch_size): - frappe.delete_doc("Comment", batch, ignore_permissions=True) + if reference_doc_names: + comment = qb.DocType("Comment") + qb.from_(comment).delete().where( + (comment.reference_doctype == doctype) & (comment.reference_name.isin(reference_doc_names)) + ).run() def unlink_attachments(self, doctype, reference_doc_names): files = frappe.get_all( From f66b53b2c1f2855ad72500731c350bc37ccf8218 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 29 Mar 2024 11:21:27 +0530 Subject: [PATCH 06/15] fix: cost center shouldn't update debit/credit in Exc gain/loss JV (cherry picked from commit 398d3022eff1df4d7179bf795570eab02fc0816b) --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index a2f5455f2f7..cda0adc7257 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -428,7 +428,10 @@ frappe.ui.form.on("Journal Entry Account", { } }, cost_center: function (frm, dt, dn) { - erpnext.journal_entry.set_account_details(frm, dt, dn); + // Don't reset for Gain/Loss type journals, as it will make Debit and Credit values '0' + if (frm.doc.voucher_type != "Exchange Gain Or Loss") { + erpnext.journal_entry.set_account_details(frm, dt, dn); + } }, account: function (frm, dt, dn) { From 8dff18eab478a3a17d485dc500dbcdeda84eaf0f Mon Sep 17 00:00:00 2001 From: Ashish Shah Date: Fri, 29 Mar 2024 10:52:52 +0530 Subject: [PATCH 07/15] fix: payment_order_status should be no_copy payment_order_status should be no_copy (cherry picked from commit adee2ba5413f5f8c73cbc30204b9ba507866f4ec) --- erpnext/accounts/doctype/payment_entry/payment_entry.json | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index bd43fb77c23..d3db789c336 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -576,6 +576,7 @@ "fieldtype": "Select", "hidden": 1, "label": "Payment Order Status", + "no_copy": 1, "options": "Initiated\nPayment Ordered", "read_only": 1 }, From ceac42dfaa691d169603a529545c6fd70facf247 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 30 Mar 2024 10:18:16 +0530 Subject: [PATCH 08/15] fix: Warehouse linked company name in multicompany setup (backport #40779) (#40780) fix: Warehouse linked company name in multicompany setup (#40779) (cherry picked from commit 679aea607b1bf7c9303a2cbe1a7b5629a03f3f4f) Co-authored-by: jeshani <56191568+jeshani@users.noreply.github.com> --- erpnext/stock/doctype/warehouse/warehouse.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 4f44db023dd..9457c25b22d 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -49,6 +49,7 @@ frappe.ui.form.on("Warehouse", { frm.add_custom_button(__("Stock Balance"), function () { frappe.set_route("query-report", "Stock Balance", { warehouse: frm.doc.name, + company: frm.doc.company, }); }); From 9b8bb4d6a2c88b133208d488ca0d275edf7798d7 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Sun, 31 Mar 2024 11:41:44 +0530 Subject: [PATCH 09/15] chore: fix conflicts --- .../supplier_quotation/supplier_quotation.py | 92 ------------------- 1 file changed, 92 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 7570063aef1..e27fbe8aaa2 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -14,98 +14,6 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class SupplierQuotation(BuyingController): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail - from erpnext.accounts.doctype.purchase_taxes_and_charges.purchase_taxes_and_charges import ( - PurchaseTaxesandCharges, - ) - from erpnext.buying.doctype.supplier_quotation_item.supplier_quotation_item import ( - SupplierQuotationItem, - ) - - additional_discount_percentage: DF.Float - address_display: DF.TextEditor | None - amended_from: DF.Link | None - apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] - auto_repeat: DF.Link | None - base_discount_amount: DF.Currency - base_grand_total: DF.Currency - base_in_words: DF.Data | None - base_net_total: DF.Currency - base_rounded_total: DF.Currency - base_rounding_adjustment: DF.Currency - base_taxes_and_charges_added: DF.Currency - base_taxes_and_charges_deducted: DF.Currency - base_total: DF.Currency - base_total_taxes_and_charges: DF.Currency - billing_address: DF.Link | None - billing_address_display: DF.TextEditor | None - buying_price_list: DF.Link | None - company: DF.Link - contact_display: DF.SmallText | None - contact_email: DF.Data | None - contact_mobile: DF.SmallText | None - contact_person: DF.Link | None - conversion_rate: DF.Float - cost_center: DF.Link | None - currency: DF.Link - disable_rounded_total: DF.Check - discount_amount: DF.Currency - grand_total: DF.Currency - group_same_items: DF.Check - ignore_pricing_rule: DF.Check - in_words: DF.Data | None - incoterm: DF.Link | None - is_subcontracted: DF.Check - items: DF.Table[SupplierQuotationItem] - language: DF.Data | None - letter_head: DF.Link | None - named_place: DF.Data | None - naming_series: DF.Literal["PUR-SQTN-.YYYY.-"] - net_total: DF.Currency - opportunity: DF.Link | None - other_charges_calculation: DF.TextEditor | None - plc_conversion_rate: DF.Float - price_list_currency: DF.Link | None - pricing_rules: DF.Table[PricingRuleDetail] - project: DF.Link | None - quotation_number: DF.Data | None - rounded_total: DF.Currency - rounding_adjustment: DF.Currency - select_print_heading: DF.Link | None - shipping_address: DF.Link | None - shipping_address_display: DF.TextEditor | None - shipping_rule: DF.Link | None - status: DF.Literal["", "Draft", "Submitted", "Stopped", "Cancelled", "Expired"] - supplier: DF.Link - supplier_address: DF.Link | None - supplier_name: DF.Data | None - tax_category: DF.Link | None - taxes: DF.Table[PurchaseTaxesandCharges] - taxes_and_charges: DF.Link | None - taxes_and_charges_added: DF.Currency - taxes_and_charges_deducted: DF.Currency - tc_name: DF.Link | None - terms: DF.TextEditor | None - title: DF.Data | None - total: DF.Currency - total_net_weight: DF.Float - total_qty: DF.Float - total_taxes_and_charges: DF.Currency - transaction_date: DF.Date - valid_till: DF.Date | None - # end: auto-generated types - ->>>>>>> 9828d34b19 (fix: markdown to text editor set for supplier quotation) def validate(self): super(SupplierQuotation, self).validate() From 31017774f63d0a9a8c46b748c6b2942207fbe09a Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Sun, 31 Mar 2024 11:42:05 +0530 Subject: [PATCH 10/15] chore: fix conflicts --- .../doctype/supplier_quotation/supplier_quotation.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index a35719f81ad..d87db06a4a9 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -927,11 +927,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2024-03-20 16:03:59.069145", -======= "modified": "2024-03-28 10:20:30.231915", ->>>>>>> 9828d34b19 (fix: markdown to text editor set for supplier quotation) "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation", @@ -999,4 +995,4 @@ "states": [], "timeline_field": "supplier", "title_field": "title" -} \ No newline at end of file +} From 72db656054e90a02bb7f2fee86fdb5f6488a852e Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Wed, 28 Feb 2024 20:33:16 -0500 Subject: [PATCH 11/15] test: show future payments allocated sales returns is considered as payment (cherry picked from commit daaa00bd4aa7414fde65bfc0e23538678f38aa12) --- .../test_accounts_receivable.py | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index de49139adc1..01129824bca 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -469,11 +469,30 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): ) def test_future_payments(self): + sr = self.create_sales_invoice(do_not_submit=True) + sr.is_return = 1 + sr.items[0].qty = -1 + sr.items[0].rate = 10 + sr.calculate_taxes_and_totals() + sr.submit() + si = self.create_sales_invoice() pe = get_payment_entry(si.doctype, si.name) + pe.append( + "references", + { + "reference_doctype": sr.doctype, + "reference_name": sr.name, + "due_date": sr.due_date, + "total_amount": sr.grand_total, + "outstanding_amount": sr.outstanding_amount, + "allocated_amount": sr.outstanding_amount, + }, + ) + pe.posting_date = add_days(today(), 1) - pe.paid_amount = 90.0 - pe.references[0].allocated_amount = 90.0 + pe.paid_amount = 80 + pe.references[0].allocated_amount = 90.0 # pe.paid_amount + sr.grand_total pe.save().submit() filters = { "company": self.company, @@ -485,16 +504,21 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): "show_future_payments": True, } report = execute(filters)[1] - self.assertEqual(len(report), 1) + self.assertEqual(len(report), 2) - expected_data = [100.0, 100.0, 10.0, 90.0] + expected_data = {sr.name: [10.0, -10.0, 0.0, -10], si.name: [100.0, 100.0, 10.0, 90.0]} - row = report[0] - self.assertEqual( - expected_data, [row.invoiced, row.outstanding, row.remaining_balance, row.future_amount] - ) + rows = report[:2] + for row in rows: + self.assertEqual( + expected_data[row.voucher_no], + [row.invoiced or row.paid, row.outstanding, row.remaining_balance, row.future_amount], + ) pe.cancel() + sr.load_from_db() # Outstanding amount is updated so a updated timestamp is needed. + sr.cancel() + # full payment in future date pe = get_payment_entry(si.doctype, si.name) pe.posting_date = add_days(today(), 1) From 803ed904a9aa1201af0b7a701861ad03a8306fcd Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Wed, 28 Feb 2024 20:33:25 -0500 Subject: [PATCH 12/15] fix: show future payments allocated sales returns is considered as payment (cherry picked from commit 3381d0d94525cc2900ba23a69be644b6dae7a483) --- .../accounts/report/accounts_receivable/accounts_receivable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index c3ebb018ae9..609a4abe66f 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -673,7 +673,7 @@ class ReceivablePayableReport(object): else: future_amount_field = "future_amount_in_base_currency" - if row.remaining_balance > 0 and future.get(future_amount_field): + if row.remaining_balance != 0 and future.get(future_amount_field): if future.get(future_amount_field) > row.outstanding: row.future_amount = row.outstanding future[future_amount_field] = future.get(future_amount_field) - row.outstanding From cfe5f009f6eef125d836601ab72d1913b50d90e9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 21 Mar 2024 12:43:08 +0530 Subject: [PATCH 13/15] fix: show currency symbol in base currency in fixed asset register report (cherry picked from commit 8b6220efd8e6a29a3e972c5d0e3af9cd2d26b631) --- .../report/pos_register/pos_register.py | 13 ++++++-- .../fixed_asset_register.py | 31 ++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/report/pos_register/pos_register.py b/erpnext/accounts/report/pos_register/pos_register.py index 488bb9957c9..36e49250ee4 100644 --- a/erpnext/accounts/report/pos_register/pos_register.py +++ b/erpnext/accounts/report/pos_register/pos_register.py @@ -62,7 +62,7 @@ def get_pos_entries(filters, group_by_field): return frappe.db.sql( """ SELECT - p.posting_date, p.name as pos_invoice, p.pos_profile, + p.posting_date, p.name as pos_invoice, p.pos_profile, p.company, p.owner, p.customer, p.is_return, p.base_grand_total as grand_total {select_mop_field} FROM `tabPOS Invoice` p {from_sales_invoice_payment} @@ -207,14 +207,14 @@ def get_columns(filters): "label": _("Grand Total"), "fieldname": "grand_total", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 120, }, { "label": _("Paid Amount"), "fieldname": "paid_amount", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 120, }, { @@ -224,6 +224,13 @@ def get_columns(filters): "width": 150, }, {"label": _("Is Return"), "fieldname": "is_return", "fieldtype": "Data", "width": 80}, + { + "label": _("Company"), + "fieldname": "company", + "fieldtype": "Link", + "options": "Company", + "width": 120, + }, ] return columns diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py index 45811a93444..4150494e22f 100644 --- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py +++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py @@ -149,6 +149,7 @@ def get_data(filters): "asset_category": asset.asset_category, "purchase_date": asset.purchase_date, "asset_value": asset_value, + "company": asset.company, } data.append(row) @@ -379,30 +380,37 @@ def get_columns(filters): "label": _("Gross Purchase Amount"), "fieldname": "gross_purchase_amount", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 250, }, { "label": _("Opening Accumulated Depreciation"), "fieldname": "opening_accumulated_depreciation", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 250, }, { "label": _("Depreciated Amount"), "fieldname": "depreciated_amount", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 250, }, { "label": _("Asset Value"), "fieldname": "asset_value", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 250, }, + { + "label": _("Company"), + "fieldname": "company", + "fieldtype": "Link", + "options": "Company", + "width": 120, + }, ] return [ @@ -433,28 +441,28 @@ def get_columns(filters): "label": _("Gross Purchase Amount"), "fieldname": "gross_purchase_amount", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 100, }, { "label": _("Asset Value"), "fieldname": "asset_value", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 100, }, { "label": _("Opening Accumulated Depreciation"), "fieldname": "opening_accumulated_depreciation", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 90, }, { "label": _("Depreciated Amount"), "fieldname": "depreciated_amount", "fieldtype": "Currency", - "options": "company:currency", + "options": "Company:company:default_currency", "width": 100, }, { @@ -479,4 +487,11 @@ def get_columns(filters): "options": "Location", "width": 100, }, + { + "label": _("Company"), + "fieldname": "company", + "fieldtype": "Link", + "options": "Company", + "width": 120, + }, ] From 515f93336263b4a865b66bd79fe8e884c88b79aa Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Apr 2024 15:35:06 +0530 Subject: [PATCH 14/15] fix: linter issues (cherry picked from commit 21a40a22361c9bad92947e3ea4329f6c6815ee0f) --- erpnext/accounts/report/pos_register/pos_register.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/report/pos_register/pos_register.py b/erpnext/accounts/report/pos_register/pos_register.py index 36e49250ee4..3c687d0b48e 100644 --- a/erpnext/accounts/report/pos_register/pos_register.py +++ b/erpnext/accounts/report/pos_register/pos_register.py @@ -59,6 +59,7 @@ def get_pos_entries(filters, group_by_field): order_by += ", p.{}".format(group_by_field) select_mop_field = ", p.base_paid_amount - p.change_amount as paid_amount " + # nosemgrep return frappe.db.sql( """ SELECT From abc0294cbf472f1b4f3563d2e34a2a2776c50df4 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 2 Apr 2024 15:35:21 +0530 Subject: [PATCH 15/15] chore: remove enqueue submit and cancel from stock entry --- .../stock/doctype/stock_entry/stock_entry.py | 47 +------------------ .../doctype/stock_entry/test_stock_entry.py | 30 ------------ 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index ca31a9a3d31..81658c42e91 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -9,17 +9,7 @@ import frappe from frappe import _ from frappe.model.mapper import get_mapped_doc from frappe.query_builder.functions import Sum -from frappe.utils import ( - cint, - comma_or, - cstr, - flt, - format_time, - formatdate, - getdate, - month_diff, - nowdate, -) +from frappe.utils import cint, comma_or, cstr, flt, format_time, formatdate, getdate, nowdate import erpnext from erpnext.accounts.general_ledger import process_gl_map @@ -168,41 +158,6 @@ class StockEntry(StockController): self.reset_default_field_value("from_warehouse", "items", "s_warehouse") self.reset_default_field_value("to_warehouse", "items", "t_warehouse") - def submit(self): - if self.is_enqueue_action(): - frappe.msgprint( - _( - "The task has been enqueued as a background job. In case there is any issue on processing in background, the system will add a comment about the error on this Stock Entry and revert to the Draft stage" - ) - ) - self.queue_action("submit", timeout=2000) - else: - self._submit() - - def cancel(self): - if self.is_enqueue_action(): - frappe.msgprint( - _( - "The task has been enqueued as a background job. In case there is any issue on processing in background, the system will add a comment about the error on this Stock Entry and revert to the Submitted stage" - ) - ) - self.queue_action("cancel", timeout=2000) - else: - self._cancel() - - def is_enqueue_action(self, force=False) -> bool: - if force: - return True - - if frappe.flags.in_test: - return False - - # If line items are more than 100 or record is older than 6 months - if len(self.items) > 50 or month_diff(nowdate(), self.posting_date) > 6: - return True - - return False - def on_submit(self): self.update_stock_ledger() diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 771dae53864..c6814558ce1 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -1702,36 +1702,6 @@ class TestStockEntry(FrappeTestCase): self.assertRaises(frappe.ValidationError, sr_doc.submit) - def test_enqueue_action(self): - frappe.flags.in_test = False - item_code = "Test Enqueue Item - 001" - create_item(item_code=item_code, is_stock_item=1, valuation_rate=10) - - doc = make_stock_entry( - item_code=item_code, - posting_date=add_to_date(today(), months=-7), - posting_time="00:00:00", - purpose="Material Receipt", - qty=10, - to_warehouse="_Test Warehouse - _TC", - do_not_submit=True, - ) - - self.assertTrue(doc.is_enqueue_action()) - - doc = make_stock_entry( - item_code=item_code, - posting_date=today(), - posting_time="00:00:00", - purpose="Material Receipt", - qty=10, - to_warehouse="_Test Warehouse - _TC", - do_not_submit=True, - ) - - self.assertFalse(doc.is_enqueue_action()) - frappe.flags.in_test = True - def test_auto_reorder_level(self): from erpnext.stock.reorder_item import reorder_item