关于c#:计算出纳计划中的销售税


Calculating sales tax in cashier program

为什么增值税不计入小计和合计?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    //Value from xQuantity
    double quantity = Convert.ToDouble(xQuantity.Text);

    //Value from xUnitPrice
    double unitPrice = Convert.ToDouble(xUnitPrice.Text);

    //Value from xSubTotal and xTotalPrice
    double SubTotal = quantity * unitPrice;
    xSubTotalTextBox.Text = Convert.ToString(subTotal);

    double Tax = subTotal * 1.06 + subTotal;
    xSubTotalTextBox.Text = Convert.ToString(subTotal);
    xTotalPrice.Text = Convert.ToString(totalPrice);

    //Calculate subtotal and totalprice
    subTotal = Convert.ToDouble(xQuantity.Text) * Convert.ToDouble(xUnitPrice.Text);
    xSubTotalTextBox.Text = subTotal.ToString();
    xTotalPrice.Text = (subTotal * Tax).ToString();        
}

private void xBalance_Click(object sender, EventArgs e)
{
    xRetTextBox.Visible = true;
    xReturn.Visible = true;

    double totalPrice = Convert.ToDouble(xTotalPrice.Text);
    double receive = Convert.ToDouble(xRecvTextBox.Text);
    double subTotal = totalPrice - receive;
    xRetTextBox.Text = Convert.ToString(totalPrice);

    if (totalPrice < .01) xRetTextBox.BackColor = Color.Green;
    else xRetTextBox.BackColor = Color.Red;
}


因为这一行:

1
 double Tax = subTotal * 1.06 + subTotal;

应该是错的。税款不能是subTotal*1.06+subTotal

也许你的意思是:

1
2
3
double totalPrice = subTotal * (1.06/100) + subTotal ;
xSubTotalTextBox.Text = Convert.ToString(subTotal);
xTotalPrice.Text = Convert.ToString(totalPrice);


实际税额为0.06*小计(假设为6%)。合计(含税)1.06*小计。