mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 15:00:27 +00:00
Merge pull request #44022 from frappe/mergify/bp/version-15-hotfix/pr-43273
fix: improved the conditions for determining voucher subtypes (backport #43273)
This commit is contained in:
@@ -4005,6 +4005,25 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
si.submit()
|
si.submit()
|
||||||
self.assertEqual(si.remarks, f"Against Customer Order Test PO dated {format_date(nowdate())}")
|
self.assertEqual(si.remarks, f"Against Customer Order Test PO dated {format_date(nowdate())}")
|
||||||
|
|
||||||
|
def test_gl_voucher_subtype(self):
|
||||||
|
si = create_sales_invoice()
|
||||||
|
gl_entries = frappe.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
|
||||||
|
pluck="voucher_subtype",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(all([x == "Sales Invoice" for x in gl_entries]))
|
||||||
|
|
||||||
|
si = create_sales_invoice(is_return=1, qty=-1)
|
||||||
|
gl_entries = frappe.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
|
||||||
|
pluck="voucher_subtype",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(all([x == "Credit Note" for x in gl_entries]))
|
||||||
|
|
||||||
|
|
||||||
def set_advance_flag(company, flag, default_account):
|
def set_advance_flag(company, flag, default_account):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
|
|||||||
@@ -1096,9 +1096,11 @@ class AccountsController(TransactionBase):
|
|||||||
return "Purchase Return"
|
return "Purchase Return"
|
||||||
elif self.doctype == "Delivery Note" and self.is_return:
|
elif self.doctype == "Delivery Note" and self.is_return:
|
||||||
return "Sales Return"
|
return "Sales Return"
|
||||||
elif (self.doctype == "Sales Invoice" and self.is_return) or self.doctype == "Purchase Invoice":
|
elif self.doctype == "Sales Invoice" and self.is_return:
|
||||||
return "Credit Note"
|
return "Credit Note"
|
||||||
elif (self.doctype == "Purchase Invoice" and self.is_return) or self.doctype == "Sales Invoice":
|
elif self.doctype == "Sales Invoice" and self.is_debit_note:
|
||||||
|
return "Debit Note"
|
||||||
|
elif self.doctype == "Purchase Invoice" and self.is_return:
|
||||||
return "Debit Note"
|
return "Debit Note"
|
||||||
|
|
||||||
return self.doctype
|
return self.doctype
|
||||||
|
|||||||
@@ -381,3 +381,4 @@ erpnext.patches.v15_0.set_standard_stock_entry_type
|
|||||||
erpnext.patches.v15_0.link_purchase_item_to_asset_doc
|
erpnext.patches.v15_0.link_purchase_item_to_asset_doc
|
||||||
erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter
|
erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter
|
||||||
erpnext.patches.v15_0.update_task_assignee_email_field_in_asset_maintenance_log
|
erpnext.patches.v15_0.update_task_assignee_email_field_in_asset_maintenance_log
|
||||||
|
erpnext.patches.v15_0.update_sub_voucher_type_in_gl_entries
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
update_purchase_invoices()
|
||||||
|
update_sales_invoices()
|
||||||
|
update_sales_debit_notes()
|
||||||
|
|
||||||
|
|
||||||
|
def update_purchase_invoices():
|
||||||
|
invoices = frappe.get_all(
|
||||||
|
"Purchase Invoice",
|
||||||
|
filters={"docstatus": 1, "is_return": 0},
|
||||||
|
pluck="name",
|
||||||
|
)
|
||||||
|
|
||||||
|
if not invoices:
|
||||||
|
return
|
||||||
|
|
||||||
|
update_gl_entry(doctype="Purchase Invoice", invoices=invoices, value="Purchase Invoice")
|
||||||
|
|
||||||
|
|
||||||
|
def update_sales_invoices():
|
||||||
|
invoices = frappe.get_all(
|
||||||
|
"Sales Invoice",
|
||||||
|
filters={"docstatus": 1, "is_return": 0, "is_debit_note": 0},
|
||||||
|
pluck="name",
|
||||||
|
)
|
||||||
|
if not invoices:
|
||||||
|
return
|
||||||
|
|
||||||
|
update_gl_entry(doctype="Sales Invoice", invoices=invoices, value="Sales Invoice")
|
||||||
|
|
||||||
|
|
||||||
|
def update_sales_debit_notes():
|
||||||
|
invoices = frappe.get_all(
|
||||||
|
"Sales Invoice",
|
||||||
|
filters={"docstatus": 1, "is_debit_note": 1},
|
||||||
|
pluck="name",
|
||||||
|
)
|
||||||
|
|
||||||
|
if not invoices:
|
||||||
|
return
|
||||||
|
|
||||||
|
update_gl_entry(doctype="Sales Invoice", invoices=invoices, value="Debit Note")
|
||||||
|
|
||||||
|
|
||||||
|
def update_gl_entry(doctype, invoices, value):
|
||||||
|
gl_entry = frappe.qb.DocType("GL Entry")
|
||||||
|
(
|
||||||
|
frappe.qb.update(gl_entry)
|
||||||
|
.set("voucher_subtype", value)
|
||||||
|
.where(gl_entry.voucher_subtype.isnotnull())
|
||||||
|
.where(gl_entry.voucher_no.isin(invoices))
|
||||||
|
.where(gl_entry.voucher_type == doctype)
|
||||||
|
.run()
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user