2010-06-13 79 views
1

INFORMIX-SQL 7.3執行屏幕:包括總售價稅

假設我有誰願意支付顧客$ 100(含7%的稅),我可以用什麼邏輯 這樣當出納文員在含稅銷售金額中輸入100美元,則將 計算銷售價格和稅額,使其加起來爲100美元。

我有以下3個字段標識在我執行的屏幕:

sprice = transaction.sale_price; 
stax = transaction.sale_tax; 
stotal = transaction.sale_total; 

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

回答

2

如果你的問題是公式然後sprice = STOTAL * 100 /(100 + STAX)。

例如

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

並加入7%至$ 11537.38給你$ 12345

當然要注意,可能無法找到確切數額的便士,加稅後會給你一個規定的總額。

0

要計算分類成本:

sprice = STOTAL /(1 + 0.07)

STAX = sprice * 0.07

最後一輪兩個圖。根據四捨五入算法,如果生成的四捨五入操作關閉一分,則可能需要應用一分錢偏移,以便所有數字相加。

0

基本代數運算:
93%= 93百分之五這是拉丁語爲93/100 = 0.93

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

4GL形式:

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