From 1a7efbb65466518d25de853c71ca324ddf048ee5 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 15 Jul 2024 11:33:46 +0530 Subject: [PATCH 01/27] fix(gross profit): incorrect valuation rate on different warehouses (cherry picked from commit f9d2dd0a62a42681871af874d8f6093ee6fdd715) --- erpnext/accounts/report/gross_profit/gross_profit.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 5d656bb0a79..d6a0acce427 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -694,7 +694,8 @@ class GrossProfitGenerator: def get_average_buying_rate(self, row, item_code): args = row - if item_code not in self.average_buying_rate: + key = (item_code, row.warehouse) + if key not in self.average_buying_rate: args.update( { "voucher_type": row.parenttype, @@ -705,9 +706,9 @@ class GrossProfitGenerator: ) average_buying_rate = get_incoming_rate(args) - self.average_buying_rate[item_code] = flt(average_buying_rate) + self.average_buying_rate[key] = flt(average_buying_rate) - return self.average_buying_rate[item_code] + return self.average_buying_rate[key] def get_last_purchase_rate(self, item_code, row): purchase_invoice = frappe.qb.DocType("Purchase Invoice") From 99bc8e849cf73587089d675f06e2d890002a11bc Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 18 Jul 2024 10:07:02 +0530 Subject: [PATCH 02/27] fix: ignore duplicates while creating default templates (cherry picked from commit cf55c2ab3d4c935e562cbb551714bdbcc3e2624f) --- erpnext/setup/setup_wizard/operations/taxes_setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/setup_wizard/operations/taxes_setup.py b/erpnext/setup/setup_wizard/operations/taxes_setup.py index 14fcb800ae7..354a68434b0 100644 --- a/erpnext/setup/setup_wizard/operations/taxes_setup.py +++ b/erpnext/setup/setup_wizard/operations/taxes_setup.py @@ -162,7 +162,7 @@ def make_taxes_and_charges_template(company_name, doctype, template): doc.flags.ignore_links = True doc.flags.ignore_validate = True doc.flags.ignore_mandatory = True - doc.insert(ignore_permissions=True) + doc.insert(ignore_permissions=True, ignore_if_duplicate=True) return doc @@ -195,7 +195,7 @@ def make_item_tax_template(company_name, template): # Ingone validations to make doctypes faster doc.flags.ignore_links = True doc.flags.ignore_validate = True - doc.insert(ignore_permissions=True) + doc.insert(ignore_permissions=True, ignore_if_duplicate=True) return doc @@ -232,7 +232,7 @@ def get_or_create_account(company_name, account): doc = frappe.get_doc(account) doc.flags.ignore_links = True doc.flags.ignore_validate = True - doc.insert(ignore_permissions=True, ignore_mandatory=True) + doc.insert(ignore_permissions=True, ignore_mandatory=True, ignore_if_duplicate=True) return doc From 67d402024144cfa42b2719db3c6d9cd3ec2f2118 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:29:30 +0530 Subject: [PATCH 03/27] chore: remove stale code from sales invoice (cherry picked from commit f3fda9ce989f98aa971537799afa9ecf5b848547) # Conflicts: # erpnext/accounts/doctype/sales_invoice/sales_invoice.js --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 4c899b901ca..13be7f23ff7 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -49,6 +49,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); +<<<<<<< HEAD if (this.frm.doc.repost_required && this.frm.doc.docstatus===1) { this.frm.set_intro(__("Accounting entries for this invoice needs to be reposted. Please click on 'Repost' button to update.")); this.frm.add_custom_button(__('Repost Accounting Entries'), @@ -68,6 +69,8 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e }).removeClass('btn-default').addClass('btn-warning'); } +======= +>>>>>>> f3fda9ce98 (chore: remove stale code from sales invoice) if (this.frm.doc.is_return) { this.frm.return_print_format = "Sales Invoice Return"; } From 8f1a4b9717b26e9cf4044b2b8c6fad1f3b639042 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:31:01 +0530 Subject: [PATCH 04/27] chore: remove stale 'repost_required' flag from sales invoice (cherry picked from commit 06c5334f2a6db3114b675dbf393abe94afe9bdb7) # Conflicts: # erpnext/accounts/doctype/sales_invoice/sales_invoice.json # erpnext/accounts/doctype/sales_invoice/sales_invoice.py --- .../doctype/sales_invoice/sales_invoice.json | 5 +- .../doctype/sales_invoice/sales_invoice.py | 184 ++++++++++++++++++ 2 files changed, 188 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index cf7d01c4035..3fea7dcab5d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -213,7 +213,6 @@ "is_internal_customer", "is_discounted", "remarks", - "repost_required", "connections_tab" ], "fields": [ @@ -2184,7 +2183,11 @@ "link_fieldname": "consolidated_invoice" } ], +<<<<<<< HEAD "modified": "2024-05-08 18:02:28.549041", +======= + "modified": "2024-07-18 15:30:39.428519", +>>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index d01e494e60d..f3e7bca6f15 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -49,6 +49,190 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class SalesInvoice(SellingController): +<<<<<<< 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.payment_schedule.payment_schedule import PaymentSchedule + from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail + from erpnext.accounts.doctype.sales_invoice_advance.sales_invoice_advance import SalesInvoiceAdvance + from erpnext.accounts.doctype.sales_invoice_item.sales_invoice_item import SalesInvoiceItem + from erpnext.accounts.doctype.sales_invoice_payment.sales_invoice_payment import SalesInvoicePayment + from erpnext.accounts.doctype.sales_invoice_timesheet.sales_invoice_timesheet import ( + SalesInvoiceTimesheet, + ) + from erpnext.accounts.doctype.sales_taxes_and_charges.sales_taxes_and_charges import ( + SalesTaxesandCharges, + ) + from erpnext.selling.doctype.sales_team.sales_team import SalesTeam + from erpnext.stock.doctype.packed_item.packed_item import PackedItem + + account_for_change_amount: DF.Link | None + additional_discount_account: DF.Link | None + additional_discount_percentage: DF.Float + address_display: DF.TextEditor | None + advances: DF.Table[SalesInvoiceAdvance] + against_income_account: DF.SmallText | None + allocate_advances_automatically: DF.Check + amended_from: DF.Link | None + amount_eligible_for_commission: DF.Currency + apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] + auto_repeat: DF.Link | None + base_change_amount: DF.Currency + base_discount_amount: DF.Currency + base_grand_total: DF.Currency + base_in_words: DF.SmallText | None + base_net_total: DF.Currency + base_paid_amount: DF.Currency + base_rounded_total: DF.Currency + base_rounding_adjustment: DF.Currency + base_total: DF.Currency + base_total_taxes_and_charges: DF.Currency + base_write_off_amount: DF.Currency + campaign: DF.Link | None + cash_bank_account: DF.Link | None + change_amount: DF.Currency + commission_rate: DF.Float + company: DF.Link + company_address: DF.Link | None + company_address_display: DF.TextEditor | None + company_tax_id: DF.Data | None + 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 + coupon_code: DF.Link | None + currency: DF.Link + customer: DF.Link | None + customer_address: DF.Link | None + customer_group: DF.Link | None + customer_name: DF.SmallText | None + debit_to: DF.Link + disable_rounded_total: DF.Check + discount_amount: DF.Currency + dispatch_address: DF.TextEditor | None + dispatch_address_name: DF.Link | None + dont_create_loyalty_points: DF.Check + due_date: DF.Date | None + from_date: DF.Date | None + grand_total: DF.Currency + group_same_items: DF.Check + ignore_default_payment_terms_template: DF.Check + ignore_pricing_rule: DF.Check + in_words: DF.SmallText | None + incoterm: DF.Link | None + inter_company_invoice_reference: DF.Link | None + is_cash_or_non_trade_discount: DF.Check + is_consolidated: DF.Check + is_debit_note: DF.Check + is_discounted: DF.Check + is_internal_customer: DF.Check + is_opening: DF.Literal["No", "Yes"] + is_pos: DF.Check + is_return: DF.Check + items: DF.Table[SalesInvoiceItem] + language: DF.Link | None + letter_head: DF.Link | None + loyalty_amount: DF.Currency + loyalty_points: DF.Int + loyalty_program: DF.Link | None + loyalty_redemption_account: DF.Link | None + loyalty_redemption_cost_center: DF.Link | None + named_place: DF.Data | None + naming_series: DF.Literal["ACC-SINV-.YYYY.-", "ACC-SINV-RET-.YYYY.-"] + net_total: DF.Currency + only_include_allocated_payments: DF.Check + other_charges_calculation: DF.TextEditor | None + outstanding_amount: DF.Currency + packed_items: DF.Table[PackedItem] + paid_amount: DF.Currency + party_account_currency: DF.Link | None + payment_schedule: DF.Table[PaymentSchedule] + payment_terms_template: DF.Link | None + payments: DF.Table[SalesInvoicePayment] + plc_conversion_rate: DF.Float + po_date: DF.Date | None + po_no: DF.Data | None + pos_profile: DF.Link | None + posting_date: DF.Date + posting_time: DF.Time | None + price_list_currency: DF.Link + pricing_rules: DF.Table[PricingRuleDetail] + project: DF.Link | None + redeem_loyalty_points: DF.Check + remarks: DF.SmallText | None + represents_company: DF.Link | None + return_against: DF.Link | None + rounded_total: DF.Currency + rounding_adjustment: DF.Currency + sales_partner: DF.Link | None + sales_team: DF.Table[SalesTeam] + scan_barcode: DF.Data | None + select_print_heading: DF.Link | None + selling_price_list: DF.Link + set_posting_time: DF.Check + set_target_warehouse: DF.Link | None + set_warehouse: DF.Link | None + shipping_address: DF.TextEditor | None + shipping_address_name: DF.Link | None + shipping_rule: DF.Link | None + source: DF.Link | None + status: DF.Literal[ + "", + "Draft", + "Return", + "Credit Note Issued", + "Submitted", + "Paid", + "Partly Paid", + "Unpaid", + "Unpaid and Discounted", + "Partly Paid and Discounted", + "Overdue and Discounted", + "Overdue", + "Cancelled", + "Internal Transfer", + ] + subscription: DF.Link | None + tax_category: DF.Link | None + tax_id: DF.Data | None + taxes: DF.Table[SalesTaxesandCharges] + taxes_and_charges: DF.Link | None + tc_name: DF.Link | None + terms: DF.TextEditor | None + territory: DF.Link | None + timesheets: DF.Table[SalesInvoiceTimesheet] + title: DF.Data | None + to_date: DF.Date | None + total: DF.Currency + total_advance: DF.Currency + total_billing_amount: DF.Currency + total_billing_hours: DF.Float + total_commission: DF.Currency + total_net_weight: DF.Float + total_qty: DF.Float + total_taxes_and_charges: DF.Currency + unrealized_profit_loss_account: DF.Link | None + update_billed_amount_in_delivery_note: DF.Check + update_billed_amount_in_sales_order: DF.Check + update_outstanding_for_self: DF.Check + update_stock: DF.Check + use_company_roundoff_cost_center: DF.Check + write_off_account: DF.Link | None + write_off_amount: DF.Currency + write_off_cost_center: DF.Link | None + write_off_outstanding_amount_automatically: DF.Check + # end: auto-generated types + +>>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.status_updater = [ From 925a164101f7d463d9816944f3be6f309c7bac04 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:31:59 +0530 Subject: [PATCH 05/27] chore: remove 'repost_required' from purchase invoice (cherry picked from commit a467888a67088e1a7997bf5d2b800817e64b08cb) # Conflicts: # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py --- .../purchase_invoice/purchase_invoice.json | 14 +- .../purchase_invoice/purchase_invoice.py | 170 ++++++++++++++++++ 2 files changed, 174 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 6b0ec8e8c85..6c6f8537d4a 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -170,7 +170,6 @@ "against_expense_account", "column_break_63", "unrealized_profit_loss_account", - "repost_required", "subscription_section", "auto_repeat", "update_auto_repeat_reference", @@ -1590,15 +1589,6 @@ "fieldtype": "Check", "label": "Use Company Default Round Off Cost Center" }, - { - "default": "0", - "fieldname": "repost_required", - "fieldtype": "Check", - "hidden": 1, - "label": "Repost Required", - "options": "Account", - "read_only": 1 - }, { "default": "0", "fieldname": "use_transaction_date_exchange_rate", @@ -1619,7 +1609,11 @@ "idx": 204, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2024-03-20 15:57:00.736868", +======= + "modified": "2024-07-18 15:31:49.488566", +>>>>>>> a467888a67 (chore: remove 'repost_required' from purchase invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index fd018309282..0003933c88f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -54,6 +54,176 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class PurchaseInvoice(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.advance_tax.advance_tax import AdvanceTax + from erpnext.accounts.doctype.payment_schedule.payment_schedule import PaymentSchedule + from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail + from erpnext.accounts.doctype.purchase_invoice_advance.purchase_invoice_advance import ( + PurchaseInvoiceAdvance, + ) + from erpnext.accounts.doctype.purchase_invoice_item.purchase_invoice_item import PurchaseInvoiceItem + from erpnext.accounts.doctype.purchase_taxes_and_charges.purchase_taxes_and_charges import ( + PurchaseTaxesandCharges, + ) + from erpnext.accounts.doctype.tax_withheld_vouchers.tax_withheld_vouchers import TaxWithheldVouchers + from erpnext.buying.doctype.purchase_receipt_item_supplied.purchase_receipt_item_supplied import ( + PurchaseReceiptItemSupplied, + ) + + additional_discount_percentage: DF.Float + address_display: DF.TextEditor | None + advance_tax: DF.Table[AdvanceTax] + advances: DF.Table[PurchaseInvoiceAdvance] + against_expense_account: DF.SmallText | None + allocate_advances_automatically: DF.Check + amended_from: DF.Link | None + apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] + apply_tds: DF.Check + 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_paid_amount: DF.Currency + base_rounded_total: DF.Currency + base_rounding_adjustment: DF.Currency + base_tax_withholding_net_total: 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 + base_write_off_amount: DF.Currency + bill_date: DF.Date | None + bill_no: DF.Data | None + billing_address: DF.Link | None + billing_address_display: DF.TextEditor | None + buying_price_list: DF.Link | None + cash_bank_account: DF.Link | None + clearance_date: DF.Date | None + company: DF.Link | None + contact_display: DF.SmallText | None + contact_email: DF.SmallText | None + contact_mobile: DF.SmallText | None + contact_person: DF.Link | None + conversion_rate: DF.Float + cost_center: DF.Link | None + credit_to: DF.Link + currency: DF.Link | None + disable_rounded_total: DF.Check + discount_amount: DF.Currency + due_date: DF.Date | None + from_date: DF.Date | None + grand_total: DF.Currency + group_same_items: DF.Check + hold_comment: DF.SmallText | None + ignore_default_payment_terms_template: DF.Check + ignore_pricing_rule: DF.Check + in_words: DF.Data | None + incoterm: DF.Link | None + inter_company_invoice_reference: DF.Link | None + is_internal_supplier: DF.Check + is_old_subcontracting_flow: DF.Check + is_opening: DF.Literal["No", "Yes"] + is_paid: DF.Check + is_return: DF.Check + is_subcontracted: DF.Check + items: DF.Table[PurchaseInvoiceItem] + language: DF.Data | None + letter_head: DF.Link | None + mode_of_payment: DF.Link | None + named_place: DF.Data | None + naming_series: DF.Literal["ACC-PINV-.YYYY.-", "ACC-PINV-RET-.YYYY.-"] + net_total: DF.Currency + on_hold: DF.Check + only_include_allocated_payments: DF.Check + other_charges_calculation: DF.TextEditor | None + outstanding_amount: DF.Currency + paid_amount: DF.Currency + party_account_currency: DF.Link | None + payment_schedule: DF.Table[PaymentSchedule] + payment_terms_template: DF.Link | None + per_received: DF.Percent + plc_conversion_rate: DF.Float + posting_date: DF.Date + posting_time: DF.Time | None + price_list_currency: DF.Link | None + pricing_rules: DF.Table[PricingRuleDetail] + project: DF.Link | None + rejected_warehouse: DF.Link | None + release_date: DF.Date | None + remarks: DF.SmallText | None + represents_company: DF.Link | None + return_against: DF.Link | None + rounded_total: DF.Currency + rounding_adjustment: DF.Currency + scan_barcode: DF.Data | None + select_print_heading: DF.Link | None + set_from_warehouse: DF.Link | None + set_posting_time: DF.Check + set_warehouse: DF.Link | None + shipping_address: DF.Link | None + shipping_address_display: DF.TextEditor | None + shipping_rule: DF.Link | None + status: DF.Literal[ + "", + "Draft", + "Return", + "Debit Note Issued", + "Submitted", + "Paid", + "Partly Paid", + "Unpaid", + "Overdue", + "Cancelled", + "Internal Transfer", + ] + subscription: DF.Link | None + supplied_items: DF.Table[PurchaseReceiptItemSupplied] + supplier: DF.Link + supplier_address: DF.Link | None + supplier_group: DF.Link | None + supplier_name: DF.Data | None + supplier_warehouse: DF.Link | None + tax_category: DF.Link | None + tax_id: DF.ReadOnly | None + tax_withheld_vouchers: DF.Table[TaxWithheldVouchers] + tax_withholding_category: DF.Link | None + tax_withholding_net_total: DF.Currency + 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 + to_date: DF.Date | None + total: DF.Currency + total_advance: DF.Currency + total_net_weight: DF.Float + total_qty: DF.Float + total_taxes_and_charges: DF.Currency + unrealized_profit_loss_account: DF.Link | None + update_billed_amount_in_purchase_order: DF.Check + update_billed_amount_in_purchase_receipt: DF.Check + update_outstanding_for_self: DF.Check + update_stock: DF.Check + use_company_roundoff_cost_center: DF.Check + use_transaction_date_exchange_rate: DF.Check + write_off_account: DF.Link | None + write_off_amount: DF.Currency + write_off_cost_center: DF.Link | None + # end: auto-generated types + +>>>>>>> a467888a67 (chore: remove 'repost_required' from purchase invoice) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.status_updater = [ From 197e043fc9e23815ff36b69d58159186f909a643 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:32:51 +0530 Subject: [PATCH 06/27] chore: remove 'repost_required' from Journal Entry (cherry picked from commit e81373bb6ae1bde6c5b3261f776ba647cd9b65e3) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.json # erpnext/accounts/doctype/journal_entry/journal_entry.py --- .../doctype/journal_entry/journal_entry.json | 4 + .../doctype/journal_entry/journal_entry.py | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index 906760ec312..021c9e19c15 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -557,7 +557,11 @@ "table_fieldname": "payment_entries" } ], +<<<<<<< HEAD "modified": "2023-11-23 12:11:04.128015", +======= + "modified": "2024-07-18 15:32:29.413598", +>>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry", diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index b4fb13e42c3..d6ee0d4a68f 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -32,6 +32,79 @@ class StockAccountInvalidTransaction(frappe.ValidationError): class JournalEntry(AccountsController): +<<<<<<< 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.journal_entry_account.journal_entry_account import JournalEntryAccount + + accounts: DF.Table[JournalEntryAccount] + amended_from: DF.Link | None + apply_tds: DF.Check + auto_repeat: DF.Link | None + bill_date: DF.Date | None + bill_no: DF.Data | None + cheque_date: DF.Date | None + cheque_no: DF.Data | None + clearance_date: DF.Date | None + company: DF.Link + difference: DF.Currency + due_date: DF.Date | None + finance_book: DF.Link | None + from_template: DF.Link | None + inter_company_journal_entry_reference: DF.Link | None + is_opening: DF.Literal["No", "Yes"] + is_system_generated: DF.Check + letter_head: DF.Link | None + mode_of_payment: DF.Link | None + multi_currency: DF.Check + naming_series: DF.Literal["ACC-JV-.YYYY.-"] + paid_loan: DF.Data | None + pay_to_recd_from: DF.Data | None + payment_order: DF.Link | None + posting_date: DF.Date + process_deferred_accounting: DF.Link | None + remark: DF.SmallText | None + reversal_of: DF.Link | None + select_print_heading: DF.Link | None + stock_entry: DF.Link | None + tax_withholding_category: DF.Link | None + title: DF.Data | None + total_amount: DF.Currency + total_amount_currency: DF.Link | None + total_amount_in_words: DF.Data | None + total_credit: DF.Currency + total_debit: DF.Currency + user_remark: DF.SmallText | None + voucher_type: DF.Literal[ + "Journal Entry", + "Inter Company Journal Entry", + "Bank Entry", + "Cash Entry", + "Credit Card Entry", + "Debit Note", + "Credit Note", + "Contra Entry", + "Excise Entry", + "Write Off Entry", + "Opening Entry", + "Depreciation Entry", + "Exchange Rate Revaluation", + "Exchange Gain Or Loss", + "Deferred Revenue", + "Deferred Expense", + ] + write_off_amount: DF.Currency + write_off_based_on: DF.Literal["Accounts Receivable", "Accounts Payable"] + # end: auto-generated types + +>>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) From a243873ab04d24d5662d4eab8636fdcb5189a93f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:34:02 +0530 Subject: [PATCH 07/27] chore: remove stale UI code related to repost (cherry picked from commit fe46e1d0899724efdbbdd32881be62112b97c11c) # Conflicts: # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index c29ec5fd12f..e51bd10082e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -59,6 +59,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. this.show_stock_ledger(); } +<<<<<<< HEAD if (this.frm.doc.repost_required && this.frm.doc.docstatus===1) { this.frm.set_intro(__("Accounting entries for this invoice need to be reposted. Please click on 'Repost' button to update.")); this.frm.add_custom_button(__('Repost Accounting Entries'), @@ -80,6 +81,10 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. if(!doc.is_return && doc.docstatus == 1 && doc.outstanding_amount != 0){ if(doc.on_hold) { +======= + if (!doc.is_return && doc.docstatus == 1 && doc.outstanding_amount != 0) { + if (doc.on_hold) { +>>>>>>> fe46e1d089 (chore: remove stale UI code related to repost) this.frm.add_custom_button( __('Change Release Date'), function() {me.change_release_date()}, From 0284328e2c6ce16efbd5167bb028277ded7f3206 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:34:59 +0530 Subject: [PATCH 08/27] refactor: repost without checking on flag (cherry picked from commit 09f429ffba15f1b9cd43ad8967efd71eb95b963c) --- erpnext/controllers/accounts_controller.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 792a0c02caf..a9494cf6e80 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2376,16 +2376,12 @@ class AccountsController(TransactionBase): @frappe.whitelist() def repost_accounting_entries(self): - if self.repost_required: - repost_ledger = frappe.new_doc("Repost Accounting Ledger") - repost_ledger.company = self.company - repost_ledger.append("vouchers", {"voucher_type": self.doctype, "voucher_no": self.name}) - repost_ledger.flags.ignore_permissions = True - repost_ledger.insert() - repost_ledger.submit() - self.db_set("repost_required", 0) - else: - frappe.throw(_("No updates pending for reposting")) + repost_ledger = frappe.new_doc("Repost Accounting Ledger") + repost_ledger.company = self.company + repost_ledger.append("vouchers", {"voucher_type": self.doctype, "voucher_no": self.name}) + repost_ledger.flags.ignore_permissions = True + repost_ledger.insert() + repost_ledger.submit() @frappe.whitelist() From 149109649de3d68f2a34c17b5ec7bddfd7caf081 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:38:15 +0530 Subject: [PATCH 09/27] refactor: remove attribute check on 'repost_required' (cherry picked from commit 07fc952a4383de79ee7c327719047b7c7e02dcd7) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.py # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py # erpnext/accounts/doctype/sales_invoice/sales_invoice.py --- .../doctype/journal_entry/journal_entry.py | 10 +++++++++ .../purchase_invoice/purchase_invoice.py | 14 +++++++++++++ .../doctype/sales_invoice/sales_invoice.py | 21 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index d6ee0d4a68f..68e5bdc1391 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -172,6 +172,16 @@ class JournalEntry(AccountsController): self.update_asset_value() self.update_inter_company_jv() self.update_invoice_discounting() +<<<<<<< HEAD +======= + self.update_booked_depreciation() + + def on_update_after_submit(self): + self.needs_repost = self.check_if_fields_updated(fields_to_check=[], child_tables={"accounts": []}) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() +>>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def on_cancel(self): # References for this Journal are removed on the `on_cancel` event in accounts_controller diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 0003933c88f..0aa97f195a7 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -760,6 +760,7 @@ class PurchaseInvoice(BuyingController): self.process_common_party_accounting() def on_update_after_submit(self): +<<<<<<< HEAD if hasattr(self, "repost_required"): fields_to_check = [ "cash_bank_account", @@ -772,6 +773,19 @@ class PurchaseInvoice(BuyingController): self.validate_for_repost() self.db_set("repost_required", self.needs_repost) self.repost_accounting_entries() +======= + fields_to_check = [ + "cash_bank_account", + "write_off_account", + "unrealized_profit_loss_account", + "is_opening", + ] + child_tables = {"items": ("expense_account",), "taxes": ("account_head",)} + self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() +>>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def make_gl_entries(self, gl_entries=None, from_repost=False): update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index f3e7bca6f15..7f64bee6a4a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -569,7 +569,6 @@ class SalesInvoice(SellingController): self.repost_future_sle_and_gle() self.db_set("status", "Cancelled") - self.db_set("repost_required", 0) if frappe.db.get_single_value("Selling Settings", "sales_update_frequency") == "Each Transaction": update_company_current_month_sales(self.company) @@ -716,6 +715,7 @@ class SalesInvoice(SellingController): data.sales_invoice = sales_invoice def on_update_after_submit(self): +<<<<<<< HEAD if hasattr(self, "repost_required"): fields_to_check = [ "additional_discount_account", @@ -734,6 +734,25 @@ class SalesInvoice(SellingController): self.validate_for_repost() self.db_set("repost_required", self.needs_repost) self.repost_accounting_entries() +======= + fields_to_check = [ + "additional_discount_account", + "cash_bank_account", + "account_for_change_amount", + "write_off_account", + "loyalty_redemption_account", + "unrealized_profit_loss_account", + "is_opening", + ] + child_tables = { + "items": ("income_account", "expense_account", "discount_account"), + "taxes": ("account_head",), + } + self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() +>>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def set_paid_amount(self): paid_amount = 0.0 From 56b158202766e6edd6cc52b56b6a7b3ac769ad66 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:39:30 +0530 Subject: [PATCH 10/27] refactor(test): remove assert on 'repost_required' (cherry picked from commit e71cb4eab7f07cad2f4245778a205750e5f0d768) --- .../accounts/doctype/purchase_invoice/test_purchase_invoice.py | 2 -- erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py | 3 --- 2 files changed, 5 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index b3a3a9634fb..f1f7f54a135 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -1917,8 +1917,6 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): ["Service - _TC", 1000, 0.0, nowdate()], ] check_gl_entries(self, pi.name, expected_gle, nowdate()) - pi.load_from_db() - self.assertFalse(pi.repost_required) def test_default_cost_center_for_purchase(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 159ed405686..9e81fcf502f 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2896,9 +2896,6 @@ class TestSalesInvoice(FrappeTestCase): check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1)) - si.load_from_db() - self.assertFalse(si.repost_required) - def test_asset_depreciation_on_sale_with_pro_rata(self): """ Tests if an Asset set to depreciate yearly on June 30, that gets sold on Sept 30, creates an additional depreciation entry on its date of sale. From 99d5b6dc71b3f471e6aa6a2761fdd0fe2ef28b55 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 13:03:43 +0530 Subject: [PATCH 11/27] chore: resolve conflicts --- erpnext/accounts/doctype/journal_entry/journal_entry.json | 4 ---- .../accounts/doctype/purchase_invoice/purchase_invoice.json | 4 ---- erpnext/accounts/doctype/sales_invoice/sales_invoice.json | 4 ---- 3 files changed, 12 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index 021c9e19c15..b229a20f7eb 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -557,11 +557,7 @@ "table_fieldname": "payment_entries" } ], -<<<<<<< HEAD - "modified": "2023-11-23 12:11:04.128015", -======= "modified": "2024-07-18 15:32:29.413598", ->>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 6c6f8537d4a..7568e3486e5 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -1609,11 +1609,7 @@ "idx": 204, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2024-03-20 15:57:00.736868", -======= "modified": "2024-07-18 15:31:49.488566", ->>>>>>> a467888a67 (chore: remove 'repost_required' from purchase invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 3fea7dcab5d..632392511bd 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -2183,11 +2183,7 @@ "link_fieldname": "consolidated_invoice" } ], -<<<<<<< HEAD - "modified": "2024-05-08 18:02:28.549041", -======= "modified": "2024-07-18 15:30:39.428519", ->>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", From 07509b5e993ab0c6c895fb196058c044de8fbb51 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 13:06:07 +0530 Subject: [PATCH 12/27] chore: resolve conflicts --- .../doctype/journal_entry/journal_entry.py | 83 ------- .../purchase_invoice/purchase_invoice.js | 24 -- .../purchase_invoice/purchase_invoice.py | 185 ---------------- .../doctype/sales_invoice/sales_invoice.js | 22 -- .../doctype/sales_invoice/sales_invoice.py | 205 ------------------ 5 files changed, 519 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 68e5bdc1391..b4fb13e42c3 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -32,79 +32,6 @@ class StockAccountInvalidTransaction(frappe.ValidationError): class JournalEntry(AccountsController): -<<<<<<< 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.journal_entry_account.journal_entry_account import JournalEntryAccount - - accounts: DF.Table[JournalEntryAccount] - amended_from: DF.Link | None - apply_tds: DF.Check - auto_repeat: DF.Link | None - bill_date: DF.Date | None - bill_no: DF.Data | None - cheque_date: DF.Date | None - cheque_no: DF.Data | None - clearance_date: DF.Date | None - company: DF.Link - difference: DF.Currency - due_date: DF.Date | None - finance_book: DF.Link | None - from_template: DF.Link | None - inter_company_journal_entry_reference: DF.Link | None - is_opening: DF.Literal["No", "Yes"] - is_system_generated: DF.Check - letter_head: DF.Link | None - mode_of_payment: DF.Link | None - multi_currency: DF.Check - naming_series: DF.Literal["ACC-JV-.YYYY.-"] - paid_loan: DF.Data | None - pay_to_recd_from: DF.Data | None - payment_order: DF.Link | None - posting_date: DF.Date - process_deferred_accounting: DF.Link | None - remark: DF.SmallText | None - reversal_of: DF.Link | None - select_print_heading: DF.Link | None - stock_entry: DF.Link | None - tax_withholding_category: DF.Link | None - title: DF.Data | None - total_amount: DF.Currency - total_amount_currency: DF.Link | None - total_amount_in_words: DF.Data | None - total_credit: DF.Currency - total_debit: DF.Currency - user_remark: DF.SmallText | None - voucher_type: DF.Literal[ - "Journal Entry", - "Inter Company Journal Entry", - "Bank Entry", - "Cash Entry", - "Credit Card Entry", - "Debit Note", - "Credit Note", - "Contra Entry", - "Excise Entry", - "Write Off Entry", - "Opening Entry", - "Depreciation Entry", - "Exchange Rate Revaluation", - "Exchange Gain Or Loss", - "Deferred Revenue", - "Deferred Expense", - ] - write_off_amount: DF.Currency - write_off_based_on: DF.Literal["Accounts Receivable", "Accounts Payable"] - # end: auto-generated types - ->>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -172,16 +99,6 @@ class JournalEntry(AccountsController): self.update_asset_value() self.update_inter_company_jv() self.update_invoice_discounting() -<<<<<<< HEAD -======= - self.update_booked_depreciation() - - def on_update_after_submit(self): - self.needs_repost = self.check_if_fields_updated(fields_to_check=[], child_tables={"accounts": []}) - if self.needs_repost: - self.validate_for_repost() - self.repost_accounting_entries() ->>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def on_cancel(self): # References for this Journal are removed on the `on_cancel` event in accounts_controller diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index e51bd10082e..ff5550489c2 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -59,32 +59,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. this.show_stock_ledger(); } -<<<<<<< HEAD - if (this.frm.doc.repost_required && this.frm.doc.docstatus===1) { - this.frm.set_intro(__("Accounting entries for this invoice need to be reposted. Please click on 'Repost' button to update.")); - this.frm.add_custom_button(__('Repost Accounting Entries'), - () => { - this.frm.call({ - doc: this.frm.doc, - method: 'repost_accounting_entries', - freeze: true, - freeze_message: __('Reposting...'), - callback: (r) => { - if (!r.exc) { - frappe.msgprint(__('Accounting Entries are reposted.')); - me.frm.refresh(); - } - } - }); - }).removeClass('btn-default').addClass('btn-warning'); - } - if(!doc.is_return && doc.docstatus == 1 && doc.outstanding_amount != 0){ if(doc.on_hold) { -======= - if (!doc.is_return && doc.docstatus == 1 && doc.outstanding_amount != 0) { - if (doc.on_hold) { ->>>>>>> fe46e1d089 (chore: remove stale UI code related to repost) this.frm.add_custom_button( __('Change Release Date'), function() {me.change_release_date()}, diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 0aa97f195a7..d571ccc28a0 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -54,176 +54,6 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class PurchaseInvoice(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.advance_tax.advance_tax import AdvanceTax - from erpnext.accounts.doctype.payment_schedule.payment_schedule import PaymentSchedule - from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail - from erpnext.accounts.doctype.purchase_invoice_advance.purchase_invoice_advance import ( - PurchaseInvoiceAdvance, - ) - from erpnext.accounts.doctype.purchase_invoice_item.purchase_invoice_item import PurchaseInvoiceItem - from erpnext.accounts.doctype.purchase_taxes_and_charges.purchase_taxes_and_charges import ( - PurchaseTaxesandCharges, - ) - from erpnext.accounts.doctype.tax_withheld_vouchers.tax_withheld_vouchers import TaxWithheldVouchers - from erpnext.buying.doctype.purchase_receipt_item_supplied.purchase_receipt_item_supplied import ( - PurchaseReceiptItemSupplied, - ) - - additional_discount_percentage: DF.Float - address_display: DF.TextEditor | None - advance_tax: DF.Table[AdvanceTax] - advances: DF.Table[PurchaseInvoiceAdvance] - against_expense_account: DF.SmallText | None - allocate_advances_automatically: DF.Check - amended_from: DF.Link | None - apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] - apply_tds: DF.Check - 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_paid_amount: DF.Currency - base_rounded_total: DF.Currency - base_rounding_adjustment: DF.Currency - base_tax_withholding_net_total: 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 - base_write_off_amount: DF.Currency - bill_date: DF.Date | None - bill_no: DF.Data | None - billing_address: DF.Link | None - billing_address_display: DF.TextEditor | None - buying_price_list: DF.Link | None - cash_bank_account: DF.Link | None - clearance_date: DF.Date | None - company: DF.Link | None - contact_display: DF.SmallText | None - contact_email: DF.SmallText | None - contact_mobile: DF.SmallText | None - contact_person: DF.Link | None - conversion_rate: DF.Float - cost_center: DF.Link | None - credit_to: DF.Link - currency: DF.Link | None - disable_rounded_total: DF.Check - discount_amount: DF.Currency - due_date: DF.Date | None - from_date: DF.Date | None - grand_total: DF.Currency - group_same_items: DF.Check - hold_comment: DF.SmallText | None - ignore_default_payment_terms_template: DF.Check - ignore_pricing_rule: DF.Check - in_words: DF.Data | None - incoterm: DF.Link | None - inter_company_invoice_reference: DF.Link | None - is_internal_supplier: DF.Check - is_old_subcontracting_flow: DF.Check - is_opening: DF.Literal["No", "Yes"] - is_paid: DF.Check - is_return: DF.Check - is_subcontracted: DF.Check - items: DF.Table[PurchaseInvoiceItem] - language: DF.Data | None - letter_head: DF.Link | None - mode_of_payment: DF.Link | None - named_place: DF.Data | None - naming_series: DF.Literal["ACC-PINV-.YYYY.-", "ACC-PINV-RET-.YYYY.-"] - net_total: DF.Currency - on_hold: DF.Check - only_include_allocated_payments: DF.Check - other_charges_calculation: DF.TextEditor | None - outstanding_amount: DF.Currency - paid_amount: DF.Currency - party_account_currency: DF.Link | None - payment_schedule: DF.Table[PaymentSchedule] - payment_terms_template: DF.Link | None - per_received: DF.Percent - plc_conversion_rate: DF.Float - posting_date: DF.Date - posting_time: DF.Time | None - price_list_currency: DF.Link | None - pricing_rules: DF.Table[PricingRuleDetail] - project: DF.Link | None - rejected_warehouse: DF.Link | None - release_date: DF.Date | None - remarks: DF.SmallText | None - represents_company: DF.Link | None - return_against: DF.Link | None - rounded_total: DF.Currency - rounding_adjustment: DF.Currency - scan_barcode: DF.Data | None - select_print_heading: DF.Link | None - set_from_warehouse: DF.Link | None - set_posting_time: DF.Check - set_warehouse: DF.Link | None - shipping_address: DF.Link | None - shipping_address_display: DF.TextEditor | None - shipping_rule: DF.Link | None - status: DF.Literal[ - "", - "Draft", - "Return", - "Debit Note Issued", - "Submitted", - "Paid", - "Partly Paid", - "Unpaid", - "Overdue", - "Cancelled", - "Internal Transfer", - ] - subscription: DF.Link | None - supplied_items: DF.Table[PurchaseReceiptItemSupplied] - supplier: DF.Link - supplier_address: DF.Link | None - supplier_group: DF.Link | None - supplier_name: DF.Data | None - supplier_warehouse: DF.Link | None - tax_category: DF.Link | None - tax_id: DF.ReadOnly | None - tax_withheld_vouchers: DF.Table[TaxWithheldVouchers] - tax_withholding_category: DF.Link | None - tax_withholding_net_total: DF.Currency - 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 - to_date: DF.Date | None - total: DF.Currency - total_advance: DF.Currency - total_net_weight: DF.Float - total_qty: DF.Float - total_taxes_and_charges: DF.Currency - unrealized_profit_loss_account: DF.Link | None - update_billed_amount_in_purchase_order: DF.Check - update_billed_amount_in_purchase_receipt: DF.Check - update_outstanding_for_self: DF.Check - update_stock: DF.Check - use_company_roundoff_cost_center: DF.Check - use_transaction_date_exchange_rate: DF.Check - write_off_account: DF.Link | None - write_off_amount: DF.Currency - write_off_cost_center: DF.Link | None - # end: auto-generated types - ->>>>>>> a467888a67 (chore: remove 'repost_required' from purchase invoice) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.status_updater = [ @@ -760,20 +590,6 @@ class PurchaseInvoice(BuyingController): self.process_common_party_accounting() def on_update_after_submit(self): -<<<<<<< HEAD - if hasattr(self, "repost_required"): - fields_to_check = [ - "cash_bank_account", - "write_off_account", - "unrealized_profit_loss_account", - ] - child_tables = {"items": ("expense_account",), "taxes": ("account_head",)} - self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) - if self.needs_repost: - self.validate_for_repost() - self.db_set("repost_required", self.needs_repost) - self.repost_accounting_entries() -======= fields_to_check = [ "cash_bank_account", "write_off_account", @@ -785,7 +601,6 @@ class PurchaseInvoice(BuyingController): if self.needs_repost: self.validate_for_repost() self.repost_accounting_entries() ->>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def make_gl_entries(self, gl_entries=None, from_repost=False): update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 13be7f23ff7..bc458ffa272 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -49,28 +49,6 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); -<<<<<<< HEAD - if (this.frm.doc.repost_required && this.frm.doc.docstatus===1) { - this.frm.set_intro(__("Accounting entries for this invoice needs to be reposted. Please click on 'Repost' button to update.")); - this.frm.add_custom_button(__('Repost Accounting Entries'), - () => { - this.frm.call({ - doc: this.frm.doc, - method: 'repost_accounting_entries', - freeze: true, - freeze_message: __('Reposting...'), - callback: (r) => { - if (!r.exc) { - frappe.msgprint(__('Accounting Entries are reposted')); - me.frm.refresh(); - } - } - }); - }).removeClass('btn-default').addClass('btn-warning'); - } - -======= ->>>>>>> f3fda9ce98 (chore: remove stale code from sales invoice) if (this.frm.doc.is_return) { this.frm.return_print_format = "Sales Invoice Return"; } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7f64bee6a4a..a254c917189 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -49,190 +49,6 @@ form_grid_templates = {"items": "templates/form_grid/item_grid.html"} class SalesInvoice(SellingController): -<<<<<<< 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.payment_schedule.payment_schedule import PaymentSchedule - from erpnext.accounts.doctype.pricing_rule_detail.pricing_rule_detail import PricingRuleDetail - from erpnext.accounts.doctype.sales_invoice_advance.sales_invoice_advance import SalesInvoiceAdvance - from erpnext.accounts.doctype.sales_invoice_item.sales_invoice_item import SalesInvoiceItem - from erpnext.accounts.doctype.sales_invoice_payment.sales_invoice_payment import SalesInvoicePayment - from erpnext.accounts.doctype.sales_invoice_timesheet.sales_invoice_timesheet import ( - SalesInvoiceTimesheet, - ) - from erpnext.accounts.doctype.sales_taxes_and_charges.sales_taxes_and_charges import ( - SalesTaxesandCharges, - ) - from erpnext.selling.doctype.sales_team.sales_team import SalesTeam - from erpnext.stock.doctype.packed_item.packed_item import PackedItem - - account_for_change_amount: DF.Link | None - additional_discount_account: DF.Link | None - additional_discount_percentage: DF.Float - address_display: DF.TextEditor | None - advances: DF.Table[SalesInvoiceAdvance] - against_income_account: DF.SmallText | None - allocate_advances_automatically: DF.Check - amended_from: DF.Link | None - amount_eligible_for_commission: DF.Currency - apply_discount_on: DF.Literal["", "Grand Total", "Net Total"] - auto_repeat: DF.Link | None - base_change_amount: DF.Currency - base_discount_amount: DF.Currency - base_grand_total: DF.Currency - base_in_words: DF.SmallText | None - base_net_total: DF.Currency - base_paid_amount: DF.Currency - base_rounded_total: DF.Currency - base_rounding_adjustment: DF.Currency - base_total: DF.Currency - base_total_taxes_and_charges: DF.Currency - base_write_off_amount: DF.Currency - campaign: DF.Link | None - cash_bank_account: DF.Link | None - change_amount: DF.Currency - commission_rate: DF.Float - company: DF.Link - company_address: DF.Link | None - company_address_display: DF.TextEditor | None - company_tax_id: DF.Data | None - 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 - coupon_code: DF.Link | None - currency: DF.Link - customer: DF.Link | None - customer_address: DF.Link | None - customer_group: DF.Link | None - customer_name: DF.SmallText | None - debit_to: DF.Link - disable_rounded_total: DF.Check - discount_amount: DF.Currency - dispatch_address: DF.TextEditor | None - dispatch_address_name: DF.Link | None - dont_create_loyalty_points: DF.Check - due_date: DF.Date | None - from_date: DF.Date | None - grand_total: DF.Currency - group_same_items: DF.Check - ignore_default_payment_terms_template: DF.Check - ignore_pricing_rule: DF.Check - in_words: DF.SmallText | None - incoterm: DF.Link | None - inter_company_invoice_reference: DF.Link | None - is_cash_or_non_trade_discount: DF.Check - is_consolidated: DF.Check - is_debit_note: DF.Check - is_discounted: DF.Check - is_internal_customer: DF.Check - is_opening: DF.Literal["No", "Yes"] - is_pos: DF.Check - is_return: DF.Check - items: DF.Table[SalesInvoiceItem] - language: DF.Link | None - letter_head: DF.Link | None - loyalty_amount: DF.Currency - loyalty_points: DF.Int - loyalty_program: DF.Link | None - loyalty_redemption_account: DF.Link | None - loyalty_redemption_cost_center: DF.Link | None - named_place: DF.Data | None - naming_series: DF.Literal["ACC-SINV-.YYYY.-", "ACC-SINV-RET-.YYYY.-"] - net_total: DF.Currency - only_include_allocated_payments: DF.Check - other_charges_calculation: DF.TextEditor | None - outstanding_amount: DF.Currency - packed_items: DF.Table[PackedItem] - paid_amount: DF.Currency - party_account_currency: DF.Link | None - payment_schedule: DF.Table[PaymentSchedule] - payment_terms_template: DF.Link | None - payments: DF.Table[SalesInvoicePayment] - plc_conversion_rate: DF.Float - po_date: DF.Date | None - po_no: DF.Data | None - pos_profile: DF.Link | None - posting_date: DF.Date - posting_time: DF.Time | None - price_list_currency: DF.Link - pricing_rules: DF.Table[PricingRuleDetail] - project: DF.Link | None - redeem_loyalty_points: DF.Check - remarks: DF.SmallText | None - represents_company: DF.Link | None - return_against: DF.Link | None - rounded_total: DF.Currency - rounding_adjustment: DF.Currency - sales_partner: DF.Link | None - sales_team: DF.Table[SalesTeam] - scan_barcode: DF.Data | None - select_print_heading: DF.Link | None - selling_price_list: DF.Link - set_posting_time: DF.Check - set_target_warehouse: DF.Link | None - set_warehouse: DF.Link | None - shipping_address: DF.TextEditor | None - shipping_address_name: DF.Link | None - shipping_rule: DF.Link | None - source: DF.Link | None - status: DF.Literal[ - "", - "Draft", - "Return", - "Credit Note Issued", - "Submitted", - "Paid", - "Partly Paid", - "Unpaid", - "Unpaid and Discounted", - "Partly Paid and Discounted", - "Overdue and Discounted", - "Overdue", - "Cancelled", - "Internal Transfer", - ] - subscription: DF.Link | None - tax_category: DF.Link | None - tax_id: DF.Data | None - taxes: DF.Table[SalesTaxesandCharges] - taxes_and_charges: DF.Link | None - tc_name: DF.Link | None - terms: DF.TextEditor | None - territory: DF.Link | None - timesheets: DF.Table[SalesInvoiceTimesheet] - title: DF.Data | None - to_date: DF.Date | None - total: DF.Currency - total_advance: DF.Currency - total_billing_amount: DF.Currency - total_billing_hours: DF.Float - total_commission: DF.Currency - total_net_weight: DF.Float - total_qty: DF.Float - total_taxes_and_charges: DF.Currency - unrealized_profit_loss_account: DF.Link | None - update_billed_amount_in_delivery_note: DF.Check - update_billed_amount_in_sales_order: DF.Check - update_outstanding_for_self: DF.Check - update_stock: DF.Check - use_company_roundoff_cost_center: DF.Check - write_off_account: DF.Link | None - write_off_amount: DF.Currency - write_off_cost_center: DF.Link | None - write_off_outstanding_amount_automatically: DF.Check - # end: auto-generated types - ->>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.status_updater = [ @@ -715,26 +531,6 @@ class SalesInvoice(SellingController): data.sales_invoice = sales_invoice def on_update_after_submit(self): -<<<<<<< HEAD - if hasattr(self, "repost_required"): - fields_to_check = [ - "additional_discount_account", - "cash_bank_account", - "account_for_change_amount", - "write_off_account", - "loyalty_redemption_account", - "unrealized_profit_loss_account", - ] - child_tables = { - "items": ("income_account", "expense_account", "discount_account"), - "taxes": ("account_head",), - } - self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) - if self.needs_repost: - self.validate_for_repost() - self.db_set("repost_required", self.needs_repost) - self.repost_accounting_entries() -======= fields_to_check = [ "additional_discount_account", "cash_bank_account", @@ -752,7 +548,6 @@ class SalesInvoice(SellingController): if self.needs_repost: self.validate_for_repost() self.repost_accounting_entries() ->>>>>>> 07fc952a43 (refactor: remove attribute check on 'repost_required') def set_paid_amount(self): paid_amount = 0.0 From 8e340bb7fdf42179e4a92f47b3764bbfb19dbe7b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 18:13:30 +0530 Subject: [PATCH 13/27] refactor: provision for monthly re-evaluation (cherry picked from commit ce2b9e0f1a69a652ed797453ba04d30e4857c0eb) # Conflicts: # erpnext/setup/doctype/company/company.json # erpnext/setup/doctype/company/company.py --- erpnext/setup/doctype/company/company.json | 6 +- erpnext/setup/doctype/company/company.py | 89 ++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 70a0872a2c4..7fd4643f233 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -698,7 +698,7 @@ "fieldname": "auto_err_frequency", "fieldtype": "Select", "label": "Frequency", - "options": "Daily\nWeekly" + "options": "Daily\nWeekly\nMonthly" }, { "default": "0", @@ -712,7 +712,11 @@ "image_field": "company_logo", "is_tree": 1, "links": [], +<<<<<<< HEAD "modified": "2024-05-27 17:32:49.057386", +======= + "modified": "2024-07-24 18:17:56.413971", +>>>>>>> ce2b9e0f1a (refactor: provision for monthly re-evaluation) "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 2477444dab6..7e63363849b 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -19,6 +19,95 @@ from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_ch class Company(NestedSet): +<<<<<<< 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 + + abbr: DF.Data + accumulated_depreciation_account: DF.Link | None + allow_account_creation_against_child_company: DF.Check + asset_received_but_not_billed: DF.Link | None + auto_err_frequency: DF.Literal["Daily", "Weekly", "Monthly"] + auto_exchange_rate_revaluation: DF.Check + book_advance_payments_in_separate_party_account: DF.Check + capital_work_in_progress_account: DF.Link | None + chart_of_accounts: DF.Literal[None] + company_description: DF.TextEditor | None + company_logo: DF.AttachImage | None + company_name: DF.Data + cost_center: DF.Link | None + country: DF.Link + create_chart_of_accounts_based_on: DF.Literal["", "Standard Template", "Existing Company"] + credit_limit: DF.Currency + date_of_commencement: DF.Date | None + date_of_establishment: DF.Date | None + date_of_incorporation: DF.Date | None + default_advance_paid_account: DF.Link | None + default_advance_received_account: DF.Link | None + default_bank_account: DF.Link | None + default_buying_terms: DF.Link | None + default_cash_account: DF.Link | None + default_currency: DF.Link + default_deferred_expense_account: DF.Link | None + default_deferred_revenue_account: DF.Link | None + default_discount_account: DF.Link | None + default_expense_account: DF.Link | None + default_finance_book: DF.Link | None + default_holiday_list: DF.Link | None + default_in_transit_warehouse: DF.Link | None + default_income_account: DF.Link | None + default_inventory_account: DF.Link | None + default_letter_head: DF.Link | None + default_operating_cost_account: DF.Link | None + default_payable_account: DF.Link | None + default_provisional_account: DF.Link | None + default_receivable_account: DF.Link | None + default_selling_terms: DF.Link | None + default_warehouse_for_sales_return: DF.Link | None + depreciation_cost_center: DF.Link | None + depreciation_expense_account: DF.Link | None + disposal_account: DF.Link | None + domain: DF.Data | None + email: DF.Data | None + enable_perpetual_inventory: DF.Check + enable_provisional_accounting_for_non_stock_items: DF.Check + exception_budget_approver_role: DF.Link | None + exchange_gain_loss_account: DF.Link | None + existing_company: DF.Link | None + fax: DF.Data | None + is_group: DF.Check + lft: DF.Int + monthly_sales_target: DF.Currency + old_parent: DF.Data | None + parent_company: DF.Link | None + payment_terms: DF.Link | None + phone_no: DF.Data | None + reconcile_on_advance_payment_date: DF.Check + registration_details: DF.Code | None + rgt: DF.Int + round_off_account: DF.Link | None + round_off_cost_center: DF.Link | None + sales_monthly_history: DF.SmallText | None + series_for_depreciation_entry: DF.Data | None + stock_adjustment_account: DF.Link | None + stock_received_but_not_billed: DF.Link | None + submit_err_jv: DF.Check + tax_id: DF.Data | None + total_monthly_sales: DF.Currency + transactions_annual_history: DF.Code | None + unrealized_exchange_gain_loss_account: DF.Link | None + unrealized_profit_loss_account: DF.Link | None + website: DF.Data | None + write_off_account: DF.Link | None + # end: auto-generated types + +>>>>>>> ce2b9e0f1a (refactor: provision for monthly re-evaluation) nsm_parent_field = "parent_company" def onload(self): From c1fd95ac6649cf9edf08f4f5701c9ab3834e9f18 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 18:16:20 +0530 Subject: [PATCH 14/27] refactor: hooks for monthly re-evaluation jobs (cherry picked from commit fc4e5f165c9628171189a1c080793507e21e0500) # Conflicts: # erpnext/hooks.py --- erpnext/accounts/utils.py | 12 ++++++++++++ erpnext/hooks.py | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 7e67085f5dd..0ae4db3673c 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1571,6 +1571,18 @@ def auto_create_exchange_rate_revaluation_weekly() -> None: create_err_and_its_journals(companies) +def auto_create_exchange_rate_revaluation_monthly() -> None: + """ + Executed by background job + """ + companies = frappe.db.get_all( + "Company", + filters={"auto_exchange_rate_revaluation": 1, "auto_err_frequency": "Montly"}, + fields=["name", "submit_err_jv"], + ) + create_err_and_its_journals(companies) + + def get_payment_ledger_entries(gl_entries, cancel=0): ple_map = [] if gl_entries: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 021cf4deb63..6d334050d80 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -462,7 +462,11 @@ scheduler_events = { ], "monthly_long": [ "erpnext.accounts.deferred_revenue.process_deferred_accounting", +<<<<<<< HEAD "erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual.process_loan_interest_accrual_for_demand_loans", +======= + "erpnext.accounts.utils.auto_create_exchange_rate_revaluation_monthly", +>>>>>>> fc4e5f165c (refactor: hooks for monthly re-evaluation jobs) ], } From 240118ee8bf90f862134c21159d38e07bb867910 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 18:47:30 +0530 Subject: [PATCH 15/27] chore: resolve conflict --- erpnext/hooks.py | 3 - erpnext/setup/doctype/company/company.json | 4 - erpnext/setup/doctype/company/company.py | 89 ---------------------- 3 files changed, 96 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 6d334050d80..ae6a15bfd8d 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -462,11 +462,8 @@ scheduler_events = { ], "monthly_long": [ "erpnext.accounts.deferred_revenue.process_deferred_accounting", -<<<<<<< HEAD "erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual.process_loan_interest_accrual_for_demand_loans", -======= "erpnext.accounts.utils.auto_create_exchange_rate_revaluation_monthly", ->>>>>>> fc4e5f165c (refactor: hooks for monthly re-evaluation jobs) ], } diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 7fd4643f233..fd121336827 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -712,11 +712,7 @@ "image_field": "company_logo", "is_tree": 1, "links": [], -<<<<<<< HEAD - "modified": "2024-05-27 17:32:49.057386", -======= "modified": "2024-07-24 18:17:56.413971", ->>>>>>> ce2b9e0f1a (refactor: provision for monthly re-evaluation) "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 7e63363849b..2477444dab6 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -19,95 +19,6 @@ from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_ch class Company(NestedSet): -<<<<<<< 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 - - abbr: DF.Data - accumulated_depreciation_account: DF.Link | None - allow_account_creation_against_child_company: DF.Check - asset_received_but_not_billed: DF.Link | None - auto_err_frequency: DF.Literal["Daily", "Weekly", "Monthly"] - auto_exchange_rate_revaluation: DF.Check - book_advance_payments_in_separate_party_account: DF.Check - capital_work_in_progress_account: DF.Link | None - chart_of_accounts: DF.Literal[None] - company_description: DF.TextEditor | None - company_logo: DF.AttachImage | None - company_name: DF.Data - cost_center: DF.Link | None - country: DF.Link - create_chart_of_accounts_based_on: DF.Literal["", "Standard Template", "Existing Company"] - credit_limit: DF.Currency - date_of_commencement: DF.Date | None - date_of_establishment: DF.Date | None - date_of_incorporation: DF.Date | None - default_advance_paid_account: DF.Link | None - default_advance_received_account: DF.Link | None - default_bank_account: DF.Link | None - default_buying_terms: DF.Link | None - default_cash_account: DF.Link | None - default_currency: DF.Link - default_deferred_expense_account: DF.Link | None - default_deferred_revenue_account: DF.Link | None - default_discount_account: DF.Link | None - default_expense_account: DF.Link | None - default_finance_book: DF.Link | None - default_holiday_list: DF.Link | None - default_in_transit_warehouse: DF.Link | None - default_income_account: DF.Link | None - default_inventory_account: DF.Link | None - default_letter_head: DF.Link | None - default_operating_cost_account: DF.Link | None - default_payable_account: DF.Link | None - default_provisional_account: DF.Link | None - default_receivable_account: DF.Link | None - default_selling_terms: DF.Link | None - default_warehouse_for_sales_return: DF.Link | None - depreciation_cost_center: DF.Link | None - depreciation_expense_account: DF.Link | None - disposal_account: DF.Link | None - domain: DF.Data | None - email: DF.Data | None - enable_perpetual_inventory: DF.Check - enable_provisional_accounting_for_non_stock_items: DF.Check - exception_budget_approver_role: DF.Link | None - exchange_gain_loss_account: DF.Link | None - existing_company: DF.Link | None - fax: DF.Data | None - is_group: DF.Check - lft: DF.Int - monthly_sales_target: DF.Currency - old_parent: DF.Data | None - parent_company: DF.Link | None - payment_terms: DF.Link | None - phone_no: DF.Data | None - reconcile_on_advance_payment_date: DF.Check - registration_details: DF.Code | None - rgt: DF.Int - round_off_account: DF.Link | None - round_off_cost_center: DF.Link | None - sales_monthly_history: DF.SmallText | None - series_for_depreciation_entry: DF.Data | None - stock_adjustment_account: DF.Link | None - stock_received_but_not_billed: DF.Link | None - submit_err_jv: DF.Check - tax_id: DF.Data | None - total_monthly_sales: DF.Currency - transactions_annual_history: DF.Code | None - unrealized_exchange_gain_loss_account: DF.Link | None - unrealized_profit_loss_account: DF.Link | None - website: DF.Data | None - write_off_account: DF.Link | None - # end: auto-generated types - ->>>>>>> ce2b9e0f1a (refactor: provision for monthly re-evaluation) nsm_parent_field = "parent_company" def onload(self): From 25b9127bae56521b08cc5cbcee3de3e8bac5fb68 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 25 Jul 2024 19:43:00 +0530 Subject: [PATCH 16/27] refactor: index on Purchase Invoice 'release_date' (cherry picked from commit 764dd12b10d66adfa99b2c351a5e6adb66899b8a) --- .../accounts/doctype/purchase_invoice/purchase_invoice.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 7568e3486e5..1a4d497b23b 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -360,7 +360,8 @@ "description": "Once set, this invoice will be on hold till the set date", "fieldname": "release_date", "fieldtype": "Date", - "label": "Release Date" + "label": "Release Date", + "search_index": 1 }, { "fieldname": "cb_17", @@ -1609,7 +1610,7 @@ "idx": 204, "is_submittable": 1, "links": [], - "modified": "2024-07-18 15:31:49.488566", + "modified": "2024-07-25 19:42:36.931278", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", From 97f2e88f4c7bf5fed2e678a2b4e8dd2a8789a407 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 23 Jul 2024 17:36:33 +0530 Subject: [PATCH 17/27] fix: parenttype in item wise purchase and sales register (cherry picked from commit 35981b8730a5ffe6c7cb977aa59332d4bd2069b1) --- .../item_wise_purchase_register.py | 6 ++++-- .../item_wise_sales_register/item_wise_sales_register.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py index c5d732ed697..f55fef068c1 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py @@ -312,8 +312,9 @@ def apply_conditions(query, pi, pii, filters): def get_items(filters, additional_table_columns): - pi = frappe.qb.DocType("Purchase Invoice") - pii = frappe.qb.DocType("Purchase Invoice Item") + doctype = "Purchase Invoice" + pi = frappe.qb.DocType(doctype) + pii = frappe.qb.DocType(f"{doctype} Item") Item = frappe.qb.DocType("Item") query = ( frappe.qb.from_(pi) @@ -350,6 +351,7 @@ def get_items(filters, additional_table_columns): pi.mode_of_payment, ) .where(pi.docstatus == 1) + .where(pii.parenttype == doctype) ) if filters.get("supplier"): diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py index cd50b118715..7bb73143c28 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py @@ -407,8 +407,9 @@ def apply_group_by_conditions(query, si, ii, filters): def get_items(filters, additional_query_columns, additional_conditions=None): - si = frappe.qb.DocType("Sales Invoice") - sii = frappe.qb.DocType("Sales Invoice Item") + doctype = "Sales Invoice" + si = frappe.qb.DocType(doctype) + sii = frappe.qb.DocType(f"{doctype} Item") item = frappe.qb.DocType("Item") query = ( @@ -456,6 +457,7 @@ def get_items(filters, additional_query_columns, additional_conditions=None): sii.qty, ) .where(si.docstatus == 1) + .where(sii.parenttype == doctype) ) if additional_query_columns: From e7432fc60d4b5b82363212ae003cb7d2d4e8f294 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 25 Jul 2024 17:26:52 +0530 Subject: [PATCH 18/27] fix: consider payment entries for checking if tds is deducted (cherry picked from commit 40b59de4cde27da0e056032bffe82ac3e4f9e4d5) --- .../purchase_invoice/purchase_invoice.py | 6 ++--- .../tax_withholding_category.py | 22 ++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index d571ccc28a0..698744b6151 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1498,6 +1498,9 @@ class PurchaseInvoice(BuyingController): self.db_set("release_date", None) def set_tax_withholding(self): + self.set("advance_tax", []) + self.set("tax_withheld_vouchers", []) + if not self.apply_tds: return @@ -1539,8 +1542,6 @@ class PurchaseInvoice(BuyingController): self.remove(d) ## Add pending vouchers on which tax was withheld - self.set("tax_withheld_vouchers", []) - for voucher_no, voucher_details in voucher_wise_amount.items(): self.append( "tax_withheld_vouchers", @@ -1555,7 +1556,6 @@ class PurchaseInvoice(BuyingController): self.calculate_taxes_and_totals() def allocate_advance_tds(self, tax_withholding_details, advance_taxes): - self.set("advance_tax", []) for tax in advance_taxes: allocated_amount = 0 pending_amount = flt(tax.tax_amount - tax.allocated_amount) 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 d8b2079e5ac..c26c7568924 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -236,6 +236,11 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N vouchers, voucher_wise_amount = get_invoice_vouchers( parties, tax_details, inv.company, party_type=party_type ) + + payment_entry_vouchers = get_payment_entry_vouchers( + parties, tax_details, inv.company, party_type=party_type + ) + advance_vouchers = get_advance_vouchers( parties, company=inv.company, @@ -243,7 +248,8 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N to_date=tax_details.to_date, party_type=party_type, ) - taxable_vouchers = vouchers + advance_vouchers + + taxable_vouchers = vouchers + advance_vouchers + payment_entry_vouchers tax_deducted_on_advances = 0 if inv.doctype == "Purchase Invoice": @@ -355,6 +361,20 @@ def get_invoice_vouchers(parties, tax_details, company, party_type="Supplier"): return vouchers, voucher_wise_amount +def get_payment_entry_vouchers(parties, tax_details, company, party_type="Supplier"): + payment_entry_filters = { + "party_type": party_type, + "party": ("in", parties), + "docstatus": 1, + "apply_tax_withholding_amount": 1, + "posting_date": ["between", (tax_details.from_date, tax_details.to_date)], + "tax_withholding_category": tax_details.get("tax_withholding_category"), + "company": company, + } + + return frappe.db.get_all("Payment Entry", filters=payment_entry_filters, pluck="name") + + def get_advance_vouchers(parties, company=None, from_date=None, to_date=None, party_type="Supplier"): """ Use Payment Ledger to fetch unallocated Advance Payments From 0e2abbd08e0dd180a3024355e44e3553982c0284 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 26 Jul 2024 08:00:13 +0530 Subject: [PATCH 19/27] fix: incorrect cost_center on AR/AP report (cherry picked from commit 3e19041fa3ede2e151cd137c8e94bb49c6efe621) --- .../accounts/report/accounts_receivable/accounts_receivable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index f17cab8d112..11177a10772 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -139,6 +139,7 @@ class ReceivablePayableReport: paid_in_account_currency=0.0, credit_note_in_account_currency=0.0, outstanding_in_account_currency=0.0, + cost_center=ple.cost_center, ) self.get_invoices(ple) @@ -253,7 +254,7 @@ class ReceivablePayableReport: row.paid -= amount row.paid_in_account_currency -= amount_in_account_currency - if ple.cost_center: + if not row.cost_center and ple.cost_center: row.cost_center = str(ple.cost_center) def update_sub_total_row(self, row, party): From bb66126dfa962b2caa78c2ce37bb16c844f1320b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 26 Jul 2024 18:16:40 +0530 Subject: [PATCH 20/27] test: invoice cost center reported in AR/AP report (cherry picked from commit 9a0894fd65720443adc86c05d09c6fee279f4a03) --- .../test_accounts_receivable.py | 43 ++++++++++++++++++- 1 file changed, 41 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 5e2adc42d84..c4baa4e4842 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -53,11 +53,13 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): si = si.submit() return si - def create_payment_entry(self, docname): + def create_payment_entry(self, docname, do_not_submit=False): pe = get_payment_entry("Sales Invoice", docname, bank_account=self.cash, party_amount=40) pe.paid_from = self.debit_to pe.insert() - pe.submit() + if not do_not_submit: + pe.submit() + return pe def create_credit_note(self, docname, do_not_submit=False): credit_note = create_sales_invoice( @@ -984,3 +986,40 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): expected_data_after_payment, [row.invoice_grand_total, row.invoiced, row.paid, row.outstanding], ) + + def test_cost_center_on_report_output(self): + filters = { + "company": self.company, + "report_date": today(), + "range1": 30, + "range2": 60, + "range3": 90, + "range4": 120, + } + + # check invoice grand total and invoiced column's value for 3 payment terms + si = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True) + si.cost_center = self.cost_center + si.save().submit() + + new_cc = frappe.get_doc( + { + "doctype": "Cost Center", + "cost_center_name": "East Wing", + "parent_cost_center": self.company + " - " + self.company_abbr, + "company": self.company, + } + ) + new_cc.save() + + # check invoice grand total, invoiced, paid and outstanding column's value after payment + pe = self.create_payment_entry(si.name, do_not_submit=True) + pe.cost_center = new_cc.name + pe.save().submit() + report = execute(filters) + + expected_data_after_payment = [si.name, si.cost_center, 60] + + self.assertEqual(len(report[1]), 1) + row = report[1][0] + self.assertEqual(expected_data_after_payment, [row.voucher_no, row.cost_center, row.outstanding]) From 7259c0fe301a3f882120ebcad3fb20207c6e1e70 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 30 Jul 2024 11:53:47 +0530 Subject: [PATCH 21/27] chore: button name should reflect what it creates (cherry picked from commit 0b6e7f83cd6bb83638f58b82d10a3d289973c453) --- erpnext/accounts/doctype/payment_order/payment_order.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_order/payment_order.js b/erpnext/accounts/doctype/payment_order/payment_order.js index a041f290639..0180d5550d4 100644 --- a/erpnext/accounts/doctype/payment_order/payment_order.js +++ b/erpnext/accounts/doctype/payment_order/payment_order.js @@ -36,7 +36,7 @@ frappe.ui.form.on("Payment Order", { // payment Entry if (frm.doc.docstatus === 1 && frm.doc.payment_order_type === "Payment Request") { - frm.add_custom_button(__("Create Payment Entries"), function () { + frm.add_custom_button(__("Create Journal Entries"), function () { frm.trigger("make_payment_records"); }); } From 0256c64634d25d86217e48e0820c9dbc431c8fd3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:25:01 +0530 Subject: [PATCH 22/27] fix: builtins.KeyError: ('ABC', 'Store - CP') (backport #42505) (#42508) fix: builtins.KeyError: ('ABC', 'Store - CP') (#42505) (cherry picked from commit 25dac1f18e5ae3436484830c56ea479c7208abc1) Co-authored-by: rohitwaghchaure --- erpnext/stock/stock_ledger.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 71f4ca00707..42918f56a23 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -209,7 +209,9 @@ def repost_future_sle( ) affected_transactions.update(obj.affected_transactions) - distinct_item_warehouses[(args[i].get("item_code"), args[i].get("warehouse"))].reposting_status = True + key = (args[i].get("item_code"), args[i].get("warehouse")) + if distinct_item_warehouses.get(key): + distinct_item_warehouses[key].reposting_status = True if obj.new_items_found: for _item_wh, data in distinct_item_warehouses.items(): From f42f1bb35fa445c87206db9ce19df0e6dfde98b0 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:25:23 +0530 Subject: [PATCH 23/27] fix: performance issue for the report Purchase Order Analysis report (backport #42503) (#42506) * fix: performance issue for the report Purchase Order Analysis report (#42503) (cherry picked from commit cb522f8f22df6688438994d0d2c47f32984aebd6) # Conflicts: # erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure --- .../purchase_order_analysis/purchase_order_analysis.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py index b23c3f50b9a..da1c70d3179 100644 --- a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py +++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py @@ -43,9 +43,10 @@ def get_data(filters): query = ( frappe.qb.from_(po) - .from_(po_item) + .inner_join(po_item) + .on(po_item.parent == po.name) .left_join(pi_item) - .on(pi_item.po_detail == po_item.name) + .on((pi_item.po_detail == po_item.name) & (pi_item.docstatus == 1)) .select( po.transaction_date.as_("date"), po_item.schedule_date.as_("required_date"), From 8e8d0c7bd08d99d65e2f6b7e8d012131682ad8dd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:25:51 +0530 Subject: [PATCH 24/27] fix: keep status as In Progress for RIV for Timeout Error (backport #42274) (#42504) * fix: keep status as In Progress for RIV for Timeout Error (#42274) (cherry picked from commit 10280d6140837ffe2fcebb70a57311780c160e25) # Conflicts: # erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure --- .../repost_item_valuation.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index 60a7707228d..c9572d12b64 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -237,9 +237,23 @@ def repost(doc): doc.log_error("Unable to repost item valuation") message = frappe.message_log.pop() if frappe.message_log else "" + + status = "Failed" + # If failed because of timeout, set status to In Progress + if traceback and "timeout" in traceback.lower(): + status = "In Progress" + if traceback: message += "
" + "Traceback:
" + traceback - frappe.db.set_value(doc.doctype, doc.name, "error_log", message) + + frappe.db.set_value( + doc.doctype, + doc.name, + { + "error_log": message, + "status": status, + }, + ) outgoing_email_account = frappe.get_cached_value( "Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name" @@ -247,7 +261,6 @@ def repost(doc): if outgoing_email_account and not isinstance(e, RecoverableErrors): notify_error_to_stock_managers(doc, message) - doc.set_status("Failed") finally: if not frappe.flags.in_test: frappe.db.commit() From 3ba6f4006346560c88523aa14c1a7fdfcec5f437 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:52:45 +0530 Subject: [PATCH 25/27] fix: price_list_currency not found error (backport #42534) (#42538) fix: price_list_currency not found error (#42534) (cherry picked from commit 23fed831a078055d66b78ef1531ada329bc052d6) Co-authored-by: rohitwaghchaure --- erpnext/public/js/controllers/transaction.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 6828dc9c745..bdff0db266c 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1645,6 +1645,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe apply_price_list(item, reset_plc_conversion) { // We need to reset plc_conversion_rate sometimes because the call to // `erpnext.stock.get_item_details.apply_price_list` is sensitive to its value + + + if (this.frm.doc.doctype === "Material Request") { + return; + } + if (!reset_plc_conversion) { this.frm.set_value("plc_conversion_rate", ""); } From 04419844055452485022f58f5ccce6f23bc91037 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:53:31 +0530 Subject: [PATCH 26/27] fix: warehouse filter in Product Bundle Balance (backport #42532) (#42536) fix: warehouse filter in Product Bundle Balance (#42532) (cherry picked from commit 0ecfa709d8324e15d2f45a68b9506e7520c4d1e5) Co-authored-by: rohitwaghchaure --- .../product_bundle_balance/product_bundle_balance.js | 8 ++++++++ .../product_bundle_balance/product_bundle_balance.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js index 5cef5c70341..f8779c64e2d 100644 --- a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js +++ b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js @@ -3,6 +3,14 @@ frappe.query_reports["Product Bundle Balance"] = { filters: [ + { + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, + }, { fieldname: "date", label: __("Date"), diff --git a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py index dd79e7fcaf5..10f8650b525 100644 --- a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py +++ b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py @@ -224,6 +224,9 @@ def get_stock_ledger_entries(filters, items): .where((sle2.name.isnull()) & (sle.docstatus < 2) & (sle.item_code.isin(items))) ) + if filters.get("company"): + query = query.where(sle.company == filters.get("company")) + if date := filters.get("date"): query = query.where(sle.posting_date <= date) else: @@ -237,7 +240,7 @@ def get_stock_ledger_entries(filters, items): if warehouse_details: wh = frappe.qb.DocType("Warehouse") query = query.where( - ExistsCriterion( + sle.warehouse.isin( frappe.qb.from_(wh) .select(wh.name) .where((wh.lft >= warehouse_details.lft) & (wh.rgt <= warehouse_details.rgt)) From 53034c332b929a3e40759c9fc9bae82b8365aa57 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:01:24 +0530 Subject: [PATCH 27/27] fix: dynamic condition in the pricing rule not working (backport #42467) (#42543) fix: dynamic condition in the pricing rule not working (#42467) (cherry picked from commit 0e817f42ef96632df164fac6e5b2949a0d18e9f5) Co-authored-by: rohitwaghchaure --- erpnext/public/js/controllers/transaction.js | 2 +- erpnext/stock/get_item_details.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index bdff0db266c..d4b978b6e7e 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1666,7 +1666,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.in_apply_price_list = true; return this.frm.call({ method: "erpnext.stock.get_item_details.apply_price_list", - args: { args: args }, + args: { args: args, doc: me.frm.doc }, callback: function(r) { if (!r.exc) { frappe.run_serially([ diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 364a681cff4..45b251f6630 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -1297,7 +1297,7 @@ def get_batch_qty(batch_no, warehouse, item_code): @frappe.whitelist() -def apply_price_list(args, as_doc=False): +def apply_price_list(args, as_doc=False, doc=None): """Apply pricelist on a document-like dict object and return as {'parent': dict, 'children': list} @@ -1336,7 +1336,7 @@ def apply_price_list(args, as_doc=False): for item in item_list: args_copy = frappe._dict(args.copy()) args_copy.update(item) - item_details = apply_price_list_on_item(args_copy) + item_details = apply_price_list_on_item(args_copy, doc=doc) children.append(item_details) if as_doc: @@ -1354,10 +1354,10 @@ def apply_price_list(args, as_doc=False): return {"parent": parent, "children": children} -def apply_price_list_on_item(args): +def apply_price_list_on_item(args, doc=None): item_doc = frappe.db.get_value("Item", args.item_code, ["name", "variant_of"], as_dict=1) item_details = get_price_list_rate(args, item_doc) - item_details.update(get_pricing_rule_for_item(args)) + item_details.update(get_pricing_rule_for_item(args, doc=doc)) return item_details