What "TMS Edits" to use for money calculations ?

Hi

I am getting rounding issues in my calculations and need some advice on:

1. Best practices.
2. What are the best "TMS Edits" and their settings/values to use for money calculations.

e.g.  for generating consistent results on invoices and any totals.

I am using BCD variable types with 2 decimal places in the database itself.

Kind regards


Kamran

  1. I'm not sure what kind of calculations you do on what data types? Is this double? real? int? something else?

    2. Do you need an editor with an attached calculator? Did you check TAdvMoneyEdit

HI Bruno

1 . Types of calculation: BCD with 2 decimal places

eg.   datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_AMT_EXC_VAT').AsBCD:=datafrm.tbTranDetail.FieldByName('TD_TRAN_PRODUCT_SELLING_PRICE_EXC_VAT').AsBCD * datafrm.tbTranDetail.FieldByName('TD_TRAN_QTY').AsInteger;
  datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_AMT_INC_VAT').AsBCD:=datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_AMT_EXC_VAT').AsBCD * (100 + datafrm.tbTranDetail.FieldByName('TD_TRAN_VAT_PERCENT').AsBCD) / 100.00;
  datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_VAT').AsBCD:=datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_AMT_INC_VAT').AsBCD - datafrm.tbTranDetail.FieldByName('TD_TRAN_LINE_TOTAL_AMT_EXC_VAT').AsBCD;

2. Which TMS Edit is most compatible with the above code. (calculator not required)

3. Where can I find  the documentation regarding use and various parameters for the TMS Edits components?

4. I need to know what component to use for best compatibility with above coding.
 e.g TAdvEditBtn ( which has edit type of: TFloat / TMoney - whats the difference in usage)

Thanks

Kamran

I would recommend TAdvEdit or TAdvEditBtn (if you need a button within the edit control) with the edit type set to either etFloat or etMoney. You can set the nr. of decimals thats should be displayed with AdvEdit.Precision.
The difference between etFloat & etMoney is that in etMoney mode it will show also thousandseparators.