patch: invalid gain loss gl entry
This commit is contained in:
parent
78ad50efc2
commit
beebfb323a
@ -309,3 +309,4 @@ erpnext.patches.v13_0.update_dates_in_tax_withholding_category
|
|||||||
erpnext.patches.v14_0.update_opportunity_currency_fields
|
erpnext.patches.v14_0.update_opportunity_currency_fields
|
||||||
erpnext.patches.v13_0.gst_fields_for_pos_invoice
|
erpnext.patches.v13_0.gst_fields_for_pos_invoice
|
||||||
erpnext.patches.v13_0.create_accounting_dimensions_in_pos_doctypes
|
erpnext.patches.v13_0.create_accounting_dimensions_in_pos_doctypes
|
||||||
|
erpnext.patches.v13_0.modify_invalid_gain_loss_gl_entries
|
40
erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
Normal file
40
erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
purchase_invoices = frappe.db.sql("""
|
||||||
|
select
|
||||||
|
parenttype as type, parent as name
|
||||||
|
from
|
||||||
|
`tabPurchase Invoice Advance`
|
||||||
|
where
|
||||||
|
ref_exchange_rate = 1
|
||||||
|
and docstatus = 1
|
||||||
|
and ifnull(exchange_gain_loss, '') != ''
|
||||||
|
group by
|
||||||
|
parent
|
||||||
|
""", as_dict=1)
|
||||||
|
|
||||||
|
sales_invoices = frappe.db.sql("""
|
||||||
|
select
|
||||||
|
parenttype as type, parent as name
|
||||||
|
from
|
||||||
|
`tabSales Invoice Advance`
|
||||||
|
where
|
||||||
|
ref_exchange_rate = 1
|
||||||
|
and docstatus = 1
|
||||||
|
and ifnull(exchange_gain_loss, '') != ''
|
||||||
|
group by
|
||||||
|
parent
|
||||||
|
""", as_dict=1)
|
||||||
|
|
||||||
|
for invoice in purchase_invoices + sales_invoices:
|
||||||
|
doc = frappe.get_doc(invoice.type, invoice.name)
|
||||||
|
doc.docstatus = 2
|
||||||
|
doc.make_gl_entries()
|
||||||
|
for advance in doc.advances:
|
||||||
|
advance.db_set('exchange_gain_loss', 0, False)
|
||||||
|
doc.docstatus = 1
|
||||||
|
doc.make_gl_entries()
|
Loading…
Reference in New Issue
Block a user