frappe / hrms

Open Source HR and Payroll Software
https://frappe.io/hr
GNU General Public License v3.0
1.24k stars 650 forks source link

Submitting salary slips from payroll entry in different currency than base currency throwing error: Please enable 'Multicurrency' #4

Open Craftint opened 2 years ago

Craftint commented 2 years ago

Information about bug

The scenario is that there is a company located in UAE but base currency as USD. And they are paying employees in AED. All the payable accounts and salary component accounts are in AED. After creating salary slip from payroll entry, while submitting the salary slip, getting error saying: "Please check Multi Currency option to allow accounts with other currency"

image

So while saving journal entries on submitting salary slips via backend, the multicurrency is not getting checked.

As per the below code in payroll_entry.py, it is setting currency list to only account currencies in journal entry not the company currency. In this case all accounts are set in AED, currency list is [AED]

def get_amount_and_exchange_rate_for_journal_entry( self, account, amount, company_currency, currencies ): conversion_rate = 1 exchange_rate = self.exchange_rate account_currency = frappe.db.get_value("Account", account, "account_currency") if account_currency not in currencies: currencies.append(account_currency) if account_currency == company_currency: conversion_rate = self.exchange_rate exchange_rate = 1 amount = flt(amount) * flt(conversion_rate) return exchange_rate, amount

And due to which in make_accrual_jv_entry method, below condition is failing:

if len(currencies) > 1: multi_currency = 1

currecies should have been [AED,USD] to satisfy this condition.

Module

accounts, other

Version

ERPNext: v13.30.0 (HEAD) Frappe Framework: v13.29.2 (HEAD)

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

Added else block in erpnext/erpnext/payroll/doctype/payroll_entry/payroll_entry.py : 

def get_amount_and_exchange_rate_for_journal_entry(self, account, amount, company_currency, currencies):
        conversion_rate = 1
        exchange_rate = self.exchange_rate
        account_currency = frappe.db.get_value("Account", account, "account_currency")
        if account_currency not in currencies:
            currencies.append(account_currency)
        if account_currency == company_currency:
            conversion_rate = self.exchange_rate
            exchange_rate = 1
        else:
            if company_currency not in currencies:
                currencies.append(company_currency)
        amount = flt(amount) * flt(conversion_rate)
        return exchange_rate, amount

Please see if this can be done, or will it be fixed in next release
Craftint commented 2 years ago

Can anyone have a look into this

ruchamahabal commented 11 months ago

@Craftint in this case, the setup seems wrong:

In multicurrency payroll, the payroll payable account can be in the foreign currency (since that's the account you are making the payment with) but your salary component account heads should be in your base currency i.e. company currency because those accounts are used to manage your own P&L

Will add a validation in the core to make it clear