fix: patch to fill Debtor/Creditor Number

This commit is contained in:
barredterra 2021-04-08 16:57:55 +02:00
parent ed36fb2073
commit c6e13ac218
2 changed files with 32 additions and 0 deletions

View File

@ -765,3 +765,4 @@ execute:frappe.db.set_value('System Settings', None, 'app_name', 'ERPNext')
erpnext.patches.v13_0.rename_discharge_date_in_ip_record
erpnext.patches.v12_0.purchase_receipt_status
erpnext.patches.v13_0.germany_make_custom_fields
erpnext.patches.v13_0.germany_fill_debtor_creditor_number

View File

@ -0,0 +1,31 @@
# Copyright (c) 2019, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.regional.germany.setup import make_custom_fields
def execute():
"""Move account number into the new custom field debtor_creditor_number.
German companies used to use a dedicated payable/receivable account for
every party to mimick party accounts in the external accounting software
"DATEV". This is no longer necessary. The reference ID for DATEV will be
stored in a new custom field "debtor_creditor_number".
"""
company_list = frappe.get_all('Company', filters={'country': 'Germany'})
for company in company_list:
party_account_list = frappe.get_all('Party Account', filters={'company': company.name}, fields=['name', 'account', 'debtor_creditor_number'])
for party_account in party_account_list:
if (not party_account.account) or party_account.debtor_creditor_number:
# account empty or debtor_creditor_number already filled
continue
account_number = frappe.db.get_value('Account', party_account.account, 'account_number')
if not account_number:
continue
frappe.db.set_value('Party Account', party_account.name, 'debtor_creditor_number', account_number)
frappe.db.set_value('Party Account', party_account.name, 'account', '')