Guys I got the following code to identify between USA and MEXICO company. But I am getting an error message, the problem is cause because the instance but I do not know how to fix it.
This is the error message I am getting:
"There is no curency exchange rate within the filter". Filters: Currency Code:1, Starting Date: 07/02/04
Here is the code
.
END ELSE BEGIN //MEXICO COMPANY STARTING
USItem.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USCurrencyExchRate.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USItem.GET(Item."No.");
//Code to use Vendor Cost from US Company
IF USItem."Use Secondary Vendor" THEN BEGIN
VendorCost := USItem."Sec. Vendor Cost";
VendorCurr := USItem."Sec. Vendor Currency";
END ELSE BEGIN
VendorCost := USItem."Vendor Cost";
VendorCurr := USItem."Vendor Currency";
END;
//Code to change any currency to dollars
IF VendorCurr = 'USD' THEN
UnitCost := VendorCost
ELSE BEGIN
CurrencyFactor := USCurrencyExchRate.ExchangeRate(WORKDATE,VendorCurr);
UnitCost :=
ROUND(USCurrencyExchRate.ExchangeAmtFCYToLCY(WORKDATE,VendorCurr,VendorCost,CurrencyFactor));
END;
P.S. I am using Exchange Rate from the US company because we do not use those on Mexico.
0
Comments
I believe that your problem is that CHANGECOMPANY has not been called on the 'CurrencyExchangeRate2[CacheNo]' record, so it is looking for records in the Mexico company. There are none, therefore the error message.
This is the difficulty with cross-company stuff -- it is a lot more complex than we wish it would be.
To solve your problem, you have to add a function to the Currency Exchange Rate record that you can call before using the 'ExchangeRate' function. This function should take the new company name, and store it in a global text variable. Then you must modify the 'FindCurrency' function so that it calls CHANGECOMPANY on 'CurrencyExchangeRate2[CacheNo]', if a new company name exists in the global text variable.
Use with care... Test extensively... Be afraid, be very afraid...
You know something then I will considered synch vendor cost from US company to Mexico and if the vendor has any kind of currency different from USD. I will change those to USD
Paco