fix: cannot reconcile bank transactions against internal transfer payment entries (#26932)
* fix: Only set Clearance Date for Payment Entries of type Internal Transfer if both Transactions have been reconciled * fix: Reset clearance_date for intra-company Payment Entries that have only been reconciled with one Bank Transaction * fix: indentation and args Co-authored-by: Saqib <nextchamp.saqib@gmail.com> Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
parent
87308465d8
commit
842ceb1301
@ -55,6 +55,11 @@ class BankTransaction(StatusUpdater):
|
|||||||
self.clear_sales_invoice(payment_entry, for_cancel=for_cancel)
|
self.clear_sales_invoice(payment_entry, for_cancel=for_cancel)
|
||||||
|
|
||||||
def clear_simple_entry(self, payment_entry, for_cancel=False):
|
def clear_simple_entry(self, payment_entry, for_cancel=False):
|
||||||
|
if payment_entry.payment_document == "Payment Entry":
|
||||||
|
if frappe.db.get_value("Payment Entry", payment_entry.payment_entry, "payment_type") == "Internal Transfer":
|
||||||
|
if len(get_reconciled_bank_transactions(payment_entry)) < 2:
|
||||||
|
return
|
||||||
|
|
||||||
clearance_date = self.date if not for_cancel else None
|
clearance_date = self.date if not for_cancel else None
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
payment_entry.payment_document, payment_entry.payment_entry,
|
payment_entry.payment_document, payment_entry.payment_entry,
|
||||||
@ -70,6 +75,17 @@ class BankTransaction(StatusUpdater):
|
|||||||
),
|
),
|
||||||
"clearance_date", clearance_date)
|
"clearance_date", clearance_date)
|
||||||
|
|
||||||
|
def get_reconciled_bank_transactions(payment_entry):
|
||||||
|
reconciled_bank_transactions = frappe.get_all(
|
||||||
|
'Bank Transaction Payments',
|
||||||
|
filters = {
|
||||||
|
'payment_entry': payment_entry.payment_entry
|
||||||
|
},
|
||||||
|
fields = ['parent']
|
||||||
|
)
|
||||||
|
|
||||||
|
return reconciled_bank_transactions
|
||||||
|
|
||||||
def get_total_allocated_amount(payment_entry):
|
def get_total_allocated_amount(payment_entry):
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -295,5 +295,6 @@ erpnext.patches.v13_0.update_tds_check_field #3
|
|||||||
erpnext.patches.v13_0.add_custom_field_for_south_africa #2
|
erpnext.patches.v13_0.add_custom_field_for_south_africa #2
|
||||||
erpnext.patches.v13_0.update_recipient_email_digest
|
erpnext.patches.v13_0.update_recipient_email_digest
|
||||||
erpnext.patches.v13_0.shopify_deprecation_warning
|
erpnext.patches.v13_0.shopify_deprecation_warning
|
||||||
|
erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries
|
||||||
erpnext.patches.v13_0.einvoicing_deprecation_warning
|
erpnext.patches.v13_0.einvoicing_deprecation_warning
|
||||||
erpnext.patches.v14_0.delete_einvoicing_doctypes
|
erpnext.patches.v14_0.delete_einvoicing_doctypes
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) 2019, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
Reset Clearance Date for Payment Entries of type Internal Transfer that have only been reconciled with one Bank Transaction.
|
||||||
|
This will allow the Payment Entries to be reconciled with the second Bank Transaction using the Bank Reconciliation Tool.
|
||||||
|
"""
|
||||||
|
|
||||||
|
intra_company_pe = get_intra_company_payment_entries_with_clearance_dates()
|
||||||
|
reconciled_bank_transactions = get_reconciled_bank_transactions(intra_company_pe)
|
||||||
|
|
||||||
|
for payment_entry in reconciled_bank_transactions:
|
||||||
|
if len(reconciled_bank_transactions[payment_entry]) == 1:
|
||||||
|
frappe.db.set_value('Payment Entry', payment_entry, 'clearance_date', None)
|
||||||
|
|
||||||
|
def get_intra_company_payment_entries_with_clearance_dates():
|
||||||
|
return frappe.get_all(
|
||||||
|
'Payment Entry',
|
||||||
|
filters = {
|
||||||
|
'payment_type': 'Internal Transfer',
|
||||||
|
'clearance_date': ["not in", None]
|
||||||
|
},
|
||||||
|
pluck = 'name'
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_reconciled_bank_transactions(intra_company_pe):
|
||||||
|
"""Returns dictionary where each key:value pair is Payment Entry : List of Bank Transactions reconciled with Payment Entry"""
|
||||||
|
|
||||||
|
reconciled_bank_transactions = {}
|
||||||
|
|
||||||
|
for payment_entry in intra_company_pe:
|
||||||
|
reconciled_bank_transactions[payment_entry] = frappe.get_all(
|
||||||
|
'Bank Transaction Payments',
|
||||||
|
filters = {
|
||||||
|
'payment_entry': payment_entry
|
||||||
|
},
|
||||||
|
pluck='parent'
|
||||||
|
)
|
||||||
|
|
||||||
|
return reconciled_bank_transactions
|
Loading…
x
Reference in New Issue
Block a user