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_from = mapping_row.paid_from
txn_paid_to = mapping_row.paid_to txn_paid_to = mapping_row.paid_to
txn_doc_type = mapping_row.document_type or "Payment Entry" txn_doc_type = mapping_row.document_type or "Payment Entry"
txn_multi_currency = bool(mapping_row.multi_currency)
else: else:
txn_paid_from = paid_from txn_paid_from = paid_from
txn_paid_to = paid_to txn_paid_to = paid_to
txn_doc_type = document_type 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"): if result.get("success"):
created_docs += 1 created_docs += 1
if result.get("reconciled"): if result.get("reconciled"):
@ -251,14 +253,14 @@ def _find_mapping_for_txn(txn, transaction_mappings, purpose_text_cache):
return None 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.""" """Create a Payment Entry or Journal Entry and reconcile it with the bank transaction."""
bank_transaction_name = txn.get("bank_transaction_name") bank_transaction_name = txn.get("bank_transaction_name")
try: try:
bank_txn = frappe.get_doc("Bank Transaction", bank_transaction_name) bank_txn = frappe.get_doc("Bank Transaction", bank_transaction_name)
if document_type == "Journal Entry": 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: else:
result = _create_payment_entry_for_brt(txn, paid_from, paid_to, bank_txn) 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)} 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.""" """Create and submit a Journal Entry for a BRT transaction."""
try: try:
amount = abs(float(txn.get("amount") or 0)) 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_no = ref_no
je.cheque_date = posting_date je.cheque_date = posting_date
je.user_remark = bank_txn.description or txn.get("purpose") or "" 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 # Pay: paid_from credit, paid_to debit
# Receive: paid_from debit, paid_to credit # Receive: paid_from debit, paid_to credit