Hi
The only thing that i did was to add the if statement like this
if (tmpBalances.TransOpenRecId)
tmpBalances.insert();
Then the system is not inserting empty records which was the root for our problem => the system tried to insert two records with the TransOpenRecId = 0.
If you comment out the code like you do then you will not get anything in the tmp table.
This is how the code looks like
// Assert that the exchange rate values passed in are not zero as they may be used in calculations as divisors
Debug::assert(_transExchRate != 0);
Debug::assert(_transToMstExchRate != 0);
Debug::assert(_transMstToDisplayMstExchRate != 0);
Debug::assert(_mstToDisplayExchRate != 0);
tmpBalances.TransCompany = _transCompany;
tmpBalances.TransOpenRecId = _transOpenRecId;
tmpBalances.TransAmount = _transAmount;
tmpBalances.EstimatedCashDiscAmount = _estimatedCashDiscAmount;
tmpBalances.TransCurrency = _transCurrency;
tmpBalances.TransDate = _transDate;
tmpBalances.TransExchRate = _transExchRate;
tmpBalances.TransToMstExchRate = _transToMstExchRate;
tmpBalances.TransMstToDisplayMstExchRate = _transMstToDisplayMstExchRate;
tmpBalances.MstToDisplayExchRate = _mstToDisplayExchRate;
tmpBalances = this.calculateBalances(tmpBalances);
if (tmpBalances.TransOpenRecId)
tmpBalances.insert();
Regards
Einar