forked from frappe/erpnext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78ad50e
commit beebfb3
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |