fixed bug with multicurrency

This commit is contained in:
Ali 2026-03-13 18:26:43 +04:00
parent fc34e5104b
commit c563f494c3
1 changed files with 8 additions and 4 deletions

View File

@ -151,12 +151,14 @@ def create_purpose_mappings(transactions, paid_from=None, paid_to=None, document
txn_paid_from = mapping_row.paid_from
txn_paid_to = mapping_row.paid_to
txn_doc_type = mapping_row.document_type or "Payment Entry"
txn_multi_currency = bool(mapping_row.multi_currency)
else:
txn_paid_from = paid_from
txn_paid_to = paid_to
txn_doc_type = document_type
txn_multi_currency = False
result = _create_and_reconcile_doc(txn, txn_paid_from, txn_paid_to, txn_doc_type)
result = _create_and_reconcile_doc(txn, txn_paid_from, txn_paid_to, txn_doc_type, txn_multi_currency)
if result.get("success"):
created_docs += 1
if result.get("reconciled"):
@ -251,14 +253,14 @@ def _find_mapping_for_txn(txn, transaction_mappings, purpose_text_cache):
return None
def _create_and_reconcile_doc(txn, paid_from, paid_to, document_type):
def _create_and_reconcile_doc(txn, paid_from, paid_to, document_type, multi_currency=False):
"""Create a Payment Entry or Journal Entry and reconcile it with the bank transaction."""
bank_transaction_name = txn.get("bank_transaction_name")
try:
bank_txn = frappe.get_doc("Bank Transaction", bank_transaction_name)
if document_type == "Journal Entry":
result = _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn)
result = _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn, multi_currency)
else:
result = _create_payment_entry_for_brt(txn, paid_from, paid_to, bank_txn)
@ -330,7 +332,7 @@ def _create_payment_entry_for_brt(txn, paid_from, paid_to, bank_txn):
return {"success": False, "error": str(e)}
def _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn):
def _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn, multi_currency=False):
"""Create and submit a Journal Entry for a BRT transaction."""
try:
amount = abs(float(txn.get("amount") or 0))
@ -351,6 +353,8 @@ def _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn):
je.cheque_no = ref_no
je.cheque_date = posting_date
je.user_remark = bank_txn.description or txn.get("purpose") or ""
if multi_currency:
je.multi_currency = 1
# Pay: paid_from credit, paid_to debit
# Receive: paid_from debit, paid_to credit