[Fix] added account for missing change amount account in the sales invoice

This commit is contained in:
Rohit Waghchaure 2016-09-29 12:54:24 +05:30
parent f1ad32059f
commit 4b24683c27
2 changed files with 20 additions and 0 deletions

View File

@ -308,6 +308,7 @@ erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher
erpnext.patches.v7_0.set_material_request_type_in_item
erpnext.patches.v7_0.rename_examination_to_assessment
erpnext.patches.v7_0.set_portal_settings
erpnext.patches.v7_0.update_change_amount_account
erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.repost_gle_for_pos_sales_return

View File

@ -0,0 +1,19 @@
from __future__ import unicode_literals
import frappe
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
def execute():
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
for company in frappe.db.sql("""select company from `tabSales Invoice`
where change_amount <> 0 and account_for_change_amount is null group by company""", as_list = 1):
cash_account = get_default_bank_cash_account(company[0], 'Cash').get('account')
if not cash_account:
bank_account = get_default_bank_cash_account(company[0], 'Bank').get('account')
cash_account = bank_account
if cash_account:
frappe.db.sql("""update `tabSales Invoice`
set account_for_change_amount = %(cash_account)s where change_amount <> 0
and company = %(company)s and account_for_change_amount is null""",
{'cash_account': cash_account, 'company': company[0]})