diff --git a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py index 2dc1eb3dc1b06833c514be522dc87573afc8d45e..7155fe5f8707a9b780217ff0275d77f3c066be16 100644 --- a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation.py @@ -149,7 +149,9 @@ class BankReconciliation: { "payment_document": document.get("doctype"), "payment_entry": document.get("name"), - "allocated_amount": abs(document.get("unreconciled_amount")), + "allocated_amount": min( + max(abs(bank_transaction.unallocated_amount), 0), abs(document.get("unreconciled_amount")) + ), "party": document.get(PARTY_FIELD.get(document.get("doctype"))), "date": getdate(date_value), }, diff --git a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation_page/BankReconciliationActions.vue b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation_page/BankReconciliationActions.vue index 92ce5177b06efae841978e8922be8538a7b5c666..8d3f8f80f4d1565e4b128e2da39042fb645a7f75 100644 --- a/erpnext/accounts/page/bank_reconciliation/bank_reconciliation_page/BankReconciliationActions.vue +++ b/erpnext/accounts/page/bank_reconciliation/bank_reconciliation_page/BankReconciliationActions.vue @@ -61,9 +61,9 @@ const is_reconciliation_disabled = computed(() => { return get_transactions_amount() == 0 || get_documents_amount() == 0; }) -const is_pos = computed(() => { +const is_pos = () => { return props.selected_documents.filter(f => (f.is_pos == 1 || f.is_paid == 1)); -}) +} const transactions_formatted_amount = computed(() => { return format_currency(get_transactions_amount(), get_currency()) @@ -77,14 +77,16 @@ function reconcile_entries() { if (is_reconciliation_disabled.value || btn_clicked.value) { return; } - btn_clicked.value = true; + if ((props.selected_transactions.length == 1 && props.selected_documents.length >= 1) || (props.selected_transactions.length >= 1 && props.selected_documents.length == 1)) { - if (["Sales Invoice", "Purchase Invoice", "Expense Claim"].includes(props.selected_documents[0]["doctype"]) && !is_pos.length) { + if (["Sales Invoice", "Purchase Invoice", "Expense Claim"].includes(props.selected_documents[0]["doctype"]) && !is_pos().length) { frappe.confirm(__("This action will create a new payment entry. Do you confirm ?"), () => { + btn_clicked.value = true; call_reconciliation() }); } else { + btn_clicked.value = true; call_reconciliation() } } else { @@ -97,7 +99,7 @@ function call_reconciliation() { frappe.xcall('erpnext.accounts.page.bank_reconciliation.bank_reconciliation.reconcile', { bank_transactions: props.selected_transactions, - documents: !is_pos.length ? props.selected_documents : is_pos + documents: !is_pos().length ? props.selected_documents : is_pos() } ).then(() => { emit('resetList') diff --git a/erpnext/accounts/page/bank_reconciliation/bank_transaction_match.py b/erpnext/accounts/page/bank_reconciliation/bank_transaction_match.py index 800441ad55ebd1c032936c4707979c25ab7edd60..f5cc1dbbc0152272e996b538c8e744bee989449c 100644 --- a/erpnext/accounts/page/bank_reconciliation/bank_transaction_match.py +++ b/erpnext/accounts/page/bank_reconciliation/bank_transaction_match.py @@ -216,7 +216,8 @@ class BankTransactionMatch: dict( x, **{ - "amount": x.get("total_amount_reimbursed", 0) - x.get("total_sanctioned_amount", 0), + "amount": x.get("unreconciled_amount") + or (x.get("total_amount_reimbursed", 0) - x.get("total_sanctioned_amount", 0)), "party": x.get(party_field), "reference_date": x.get(date_field), "reference_string": f'{x.get("name")}: {x.get(reference_field)}',