开发者

Including tax in total sale price

开发者 https://www.devze.com 2023-01-03 19:29 出处:网络
INFORMIX-SQL 7.3 Perform Screen: Suppose I have a customer who wants to pay a $100 (7% tax included), what logic can I use

INFORMIX-SQL 7.3 Perform Screen:

Suppose I have a customer who wants to pay a $100 (7% tax included), what logic can I use so that when the cashier clerk enters $100 in the tax included sale amount, it will calculate the sale price and tax so that it adds up to $100.

I have the following 3 field tags in my Perform screen:

sprice = transaction.sale_price;
stax   = transaction.sale_tax;
s开发者_如何学Gototal = transaction.sale_total;

after editadd of transaction.sale_price
   ?...what goes here...?


If your problem is the formula then sprice = stotal * 100 / (100 + stax).

For example

$12345 * 100 / (100 + 7) = $11537.38

and adding 7% to $11537.38 gives you $12345.

Note of course that it may be impossible to find an exact amount of pennies that after adding a tax will give you a prescribed total.


To calculate disaggregated cost:

sprice = stotal / (1 + .07)

stax = sprice * .07

Finally round both figures. Depending on the rounding algorithm you may need to apply a penny offset if the resulting rounding operation is off by a cent so that all figures add up.


Basic algebra arithmetic:
93% = 93 per centum which is Latin for 93/100 = 0.93

Total receipt = p
Sale price + Tax = p
Sale price = 0.93p
Tax = 0.07p

4gl form:

sprice = transaction.sale_price,TYPE MONEY(7,2);
stax   = transaction.sale_tax,TYPE MONEY(7,2);
stotal = transaction.sale_total,TYPE MONEY(7,2);
.....

INPUT ....
AFTER FIELD stotal
  IF transaction.sale_total is NULL THEN
    ERROR "Please enter total sale amount"
  ELSE
    LET transaction.sale_tax = 0.07 * transaction.sale_total
    LET transaction.sale_price = 0.93 * transaction.sale_total
  ENDIF
0

精彩评论

暂无评论...
验证码 换一张
取 消