frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
22.01k stars 7.38k forks source link

Handling Unallocated Amounts and Exchange Discrepancies in Multi-Currency Payment Entries #43844

Open melhembitar opened 1 month ago

melhembitar commented 1 month ago

Information about bug

Process Overview in Bullet Points: Multi-Currency Setup:

CAD is the base currency, and payments can be made from foreign currency bank accounts. Payment Preparation:

When creating a payment entry from a foreign currency bank account, the system calculates the amount based on historical exchange rates, sourced from online platforms.

Unallocated Amount: The calculated amount difference (between the base currency and foreign currency) is placed in the Write-Off section as "Unallocated Amount" in the supplier's currency. This represents the discrepancy between the actual payment amount and the amount registered by the system. Adjusting Unallocated Amount:

User Action Required: The user must adjust this "Unallocated Amount" to match the exact amount received by the supplier. Risk: If the user skips this adjustment, the payment may be saved incorrectly, resulting in a discrepancy on the third-party account. Exchange Gain/Loss:

Once the unallocated amount is adjusted, the "Set Exchange Gain/Loss" button becomes active. The user can then specify an FX Gain/Loss account, which ensures the accounting entry reflects the actual currency exchange difference.

Diagram: Multi-Currency Payment Entry Flow. point 4 if not done it ll cause the problem in question

Start | v

  1. Initiate Payment Entry
    • Select Bank with Foreign Currency | v
  2. System Calculates Amount
    • Uses Historical Exchange Rate | v
  3. Register Unallocated Amount
    • Difference shown in Write-Off Section | v
  4. User Adjusts Unallocated Amount
    • Match exact amount received by supplier
    • Avoids discrepancies in supplier account | v
  5. Set Exchange Gain/Loss
    • Activate "Set Exchange Gain/Loss"
    • Enter FX Gain/Loss Account | v End: Entry Reflects Accurate Foreign Exchange

photo_2024-10-24_17-05-45

Module

accounts

Version

ERPNext: v15.39.2 (HEAD) - Frappe Framework: v15.45.0 (HEAD)

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No response

sagarvora commented 2 weeks ago

Proposed Solution

The logic to calculate unallocated_amount is incorrect. It needs following corrections:

The following additional changes are proposed to do above properly:


Another approach that is possible is to not add exchange gain / loss in the Deductions table and create separate fields for that. But that will be more breaking.