Switching/Converting default Currency to Foreign Currency

Yes it is in the latest refresh.

Busy day at the restaurant yesterday so did not have a chance to try this yet.

When I look at it again today, I don’t think this update is going to solve the Cost/Profit issue.

And this part …

No please @emre, that is the issue. I want to be able specify product cost in Foreign HNL Currency. If the Supplier sells products that are priced in HNL, and they invoice in HNL, using a price in default (USD) will not work, because the XR changes daily. For example…

For the Supplier “Cerveceria”, they price and invoice in HNL. The price for a case of Barena (beer) is HNL 452. This rarely changes (maybe 1 or 2 times per year). So if I convert that price today @23 it would be USD 19.65. Next week, the XR changes to 23.5 and now I need to convert HNL 452 again, so it becomes USD 19.23. That is exactly what I want to avoid.

The product price is still HNL 452. I need a way to denote that the pricing for these types of Suppliers/Products (of which there are many) is in HNL Currency, hence why I go back to the idea that there needs to be a Currency Parameter in the Inventory Item configuration.

Busy day at the restaurant yesterday so did not have a chance to try this yet.

When I look at it again today, I don’t think this update is going to solve the Cost/Profit issue.

And this part …

No please @emre, that is the issue. I want to be able specify product cost in Foreign HNL Currency. If the Supplier sells products that are priced in HNL, and they invoice in HNL, using a price in default (USD) will not work, because the XR changes daily. For example…

For the Supplier “Cerveceria”, they price and invoice in HNL. The price for a case of Barena (beer) is HNL 452. This rarely changes (maybe 1 or 2 times per year). So if I convert that price today @23 it would be USD 19.65. Next week, the XR changes to 23.5 and now I need to convert HNL 452 again, so it becomes USD 19.23. That is exactly what I want to avoid.

The product price is still HNL 452. I need a way to denote that the pricing for these types of Suppliers/Products (of which there are many) is in HNL Currency, hence why I go back to the idea that there needs to be a Currency Parameter in the Inventory Item configuration.

Uh OK. I’ll take a look then.

Thanks for that.

@emre, maybe we don’t need that.

This is really a Cost/Profit-Loss calculation issue, and when using the Warehouses Screen, the Cost calculation is unaware of the Exchange Rate, or at least it is not taking it into account.

Let’s look at it from a different angle.

I make a purchase:

This is how it registers in the Accounts … perfect …

Cash HNL Account:

Supplier Account:


In the DB, the Account Transactions are correct, just the way they should be:


But the Inventory Transaction shown below is not correct.

I think I can fix that ^ in the PHP Inventory system, and my problem will be solved!

With a fix in PHP, it would look like this:


However, for someone who uses the Warehouses Screen for purchases, I think you will need to do something to correct this. It might only be a matter of checking the Supplier Entity Account Currency setting, and then apply a conversion to the Cost Calculation.

Latest refresh shows this …

Inventory Transaction looks good:

Cost calculation is fine, because the Inventory Transaction is good:


However, the Account Transaction is NOT good, so we still have a problem. @emre, please read my previous post - it might be a better way to achieve the same “result” ?

OK I hardcoded exchange rate as 1 somewhere. It will work fine on next update.

1 Like

@emre, with latest refresh, everything is working perfectly now via Warehouses Screen. PHP Inventory System updated to use proper values as well. DB records for Inventory and Accounts are all correct using either method.

Awesome.

Time to do one last Conversion Test, and if all goes well (ie. if I find no more problems), it will be time to run it on Production! It has been a long time coming, but I am glad I didn’t run it sooner on Prod before I discovered all the potential issues.

I spoke too soon. When using Warehouses Screen, the RED values in Account Transactions do not look correct to me:

Those values only seem to affect the Account Tx values …

But the Accounts themselves have accurate values …

I’m curious :slight_smile:

  1. What do you mean by PHP and Warehouses?
  2. What is drawer Supplier Tx USD? Inventory transactions (should) only credit supplier accounts. Payouts is something else.

PHP means Inventory Purchase was executed via my PHP Inventory System.

Warehouses means Inventory Purchase was executed via Warehouses Screen.

Drawer Supplier Tx USD [Cerveceria] is the Name given to the Transaction inside the PHP code during an Inventory Purchase. It is based on the Transaction Type Name and the Account Name.

Whereas Supplier Transaction Cash USD is the Name assigned to the Transaction when we use the Warehouses Screen during an Inventory Purchase, as in the Name of the Account Document Type.

Well, an Inventory Transaction Debits the Supplier Account, and Credits the Account used for Payment. It does not matter which system is used, this is always true.

However, when using the Warehouses Screen, the values in [Transactions] are using incorrect ExchangeRate, and the values in [AccountTransactionValues] are using incorrect Exchange. This is only evident in the DB records, and on the screen for Accounts > Transactions when you look at the detail of the Doc. That said, the actual amounts transferred between Accounts (ie. Cash USD to Supplier HNL) are correct.

The PHP System uses the “correct” values for ExchangeRate and Exchange, so when you look at the Doc Details in Accounts > Transactions we see the correct value being used based on the Source Account (Cash USD). The Warehouses method, IMO, uses the wrong values, so the Doc Details show HNL value even when the Source Account is actually USD.

That ^ is what I am trying to demonstrate in my previous post. Though it may be rather moot, because the actual Account values are correct, so the Account Balances are not affected in a negative way.

There still might be bugs on exchange rates as I’m coding without being fully aware of what I’m doing however you should think about that. Inventory transaction (generally an invoice or delivery sheet) used to add items to inventory. At that time you may pay or may not pay the invoice. That’s why it should just credit the supplier account and debit another account like receivables (maybe payables or Account Payable).

1 Like

@QMcKay I uploaded another update to website. Can you check that?

There is no change to the values/exchange. The USD values are still incorrect when executing Inventory Purchase via Warehouses Screen.

That’s fine, I’m not too concerned about it, though it could confuse some people. The important thing is that the Account Debits/Credits and Balance on the Account Screens are all CORRECT, no matter what the Transactions Screen or the DB shows.

If you want to continue trying to fix it, I will be happy to test. But at this point I think all the real bugs have been fixed sufficiently, and I am going to do one more test run on the conversion and then get it into Prod. I think it is finally ready.

Thank you for all the work on this @emre!

That is a very good point. In fact, that happens quite often. We might not pay the Invoice, but we do enter the Inventory Items that we received. We often do this and once a few Invoices are collected, we pay them all at once. So I agree, I should revisit this at some time, and implement as you say:

@QMcKay the problem I’m having is I have no idea which SambaPOS action exactly creates these numbers.

Can you demonstrate a single transaction on SambaPOS and tell me the exact amounts you expect to see? So I can make that transaction on my side and compare it with your’s.

I expect to see the same values as those shown outlined in Green, which are created by the PHP Inventory System.

This is how I do the Purchase via Warehouses Screen in SambaPOS, which generates the values outlined in Red…


And this is the way it is done via PHP Inventory - it manually inserts Inventory Docs/Transactions and Account Docs/Transactions using SQL and converts values when applicable.

I created 4 warehouse transactions on your setup. All of them are same product and amount.

1 HNL transaction for HNL account
1 USD transaction for HNL account
1 HNL transaction for USD account
1 USD Transaction for USD account

This is what I have

How you do that transactions?

I don’t have Drawer USD on my backup. How it is configured?

This is what I have.

It is easier (quicker) for me to show using Expense Payouts, and the values are all correct.

Business License is an HNL Account. Accountant is a USD Account.

This is how it looks in DB. Notice the Exchange values shown in Green. The gist of it is that Debit and Credit are always in Default Currency, and the Exchange is derived via the Account Currency.

So when I pay to an HNL Account (Business License) from a USD Account (Cash USD), the Exchange for the HNL Account (Target) is converted (because it is Foreign Currency).

And when I pay to a USD Account (Accountant) from an HNL Account (Cash HNL), the Exchange for the HNL Account (Source) is converted (because it is Foreign Currency).

When I pay to an HNL Account (Business License) from an HNL Account (Cash HNL), the Exchange for both the Source and the Target are converted. (because they are both Foreign Currency).

When I pay to a USD Account (Accountant) from a USD Account (Cash USD), the Exchange for both the Source and the Target are NOT converted (because they are both Default Currency).