fix: map only overdue payments

This commit is contained in:
barredterra 2021-12-29 00:09:52 +01:00 committed by marination
parent 88f67e4786
commit ccefe96665

View File

@ -622,9 +622,7 @@ class SalesInvoice(SellingController):
return return
if not self.account_for_change_amount: if not self.account_for_change_amount:
self.account_for_change_amount = frappe.get_cached_value( self.account_for_change_amount = frappe.get_cached_value('Company', self.company, 'default_cash_account')
"Company", self.company, "default_cash_account"
)
from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details
@ -1909,17 +1907,17 @@ def get_bank_cash_account(mode_of_payment, company):
@frappe.whitelist() @frappe.whitelist()
def make_maintenance_schedule(source_name, target_doc=None): def make_maintenance_schedule(source_name, target_doc=None):
doclist = get_mapped_doc( doclist = get_mapped_doc("Sales Invoice", source_name, {
"Sales Invoice", "Sales Invoice": {
source_name, "doctype": "Maintenance Schedule",
{ "validation": {
"Sales Invoice": {"doctype": "Maintenance Schedule", "validation": {"docstatus": ["=", 1]}}, "docstatus": ["=", 1]
"Sales Invoice Item": { }
"doctype": "Maintenance Schedule Item",
},
}, },
target_doc, "Sales Invoice Item": {
) "doctype": "Maintenance Schedule Item",
},
}, target_doc)
return doclist return doclist
@ -2555,7 +2553,7 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False):
"name": "payment_schedule", "name": "payment_schedule",
"parent": "sales_invoice" "parent": "sales_invoice"
}, },
"condition": lambda doc: doc.outstanding > 0 "condition": lambda doc: doc.outstanding > 0 and getdate(doc.due_date) < getdate(),
} }
}, },
postprocess=postprocess_dunning, postprocess=postprocess_dunning,