Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
|
4 |
-
st.title("โปรแกรมคำนวณราคาสินค้า (รวม VAT 7% และหัก ณ ที่จ่าย 3%)")
|
5 |
|
6 |
st.markdown(
|
7 |
"""
|
8 |
-
|
9 |
-
|
10 |
-
-
|
11 |
-
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
คุณสามารถเลือกกรอกข้อมูลที่คุณทราบได้จาก 3 ตัวเลือก แล้วระบบจะคำนวณตัวเลขที่เหลือให้โดยอัตโนมัติ
|
17 |
"""
|
@@ -26,23 +25,31 @@ calc_option = st.radio(
|
|
26 |
# รับค่าจำนวนเงินจากผู้ใช้
|
27 |
amount = st.number_input("กรอกจำนวนเงิน:", min_value=0.0, format="%.2f")
|
28 |
|
29 |
-
# ตรวจสอบว่ามีการกรอกจำนวนเงินหรือไม่
|
30 |
if amount:
|
31 |
if calc_option == "ราคาก่อน VAT (Base Price)":
|
32 |
base_price = amount
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
elif calc_option == "ราคาสินค้ารวม VAT (Invoice Price)":
|
|
|
|
|
|
|
|
|
|
|
36 |
invoice_price = amount
|
37 |
-
base_price = invoice_price / 1.07
|
38 |
-
net_amount = invoice_price * 0.97
|
39 |
elif calc_option == "ยอดสุทธิที่ได้รับ (Net Amount)":
|
|
|
|
|
|
|
|
|
|
|
40 |
net_amount = amount
|
41 |
-
invoice_price = net_amount / 0.97
|
42 |
-
base_price = invoice_price / 1.07
|
43 |
|
44 |
-
# แสดงผลลัพธ์
|
45 |
st.subheader("ผลลัพธ์:")
|
46 |
st.write(f"**ราคาก่อน VAT (Base Price):** {base_price:,.2f} บาท")
|
47 |
-
st.write(f"
|
|
|
|
|
48 |
st.write(f"**ยอดสุทธิที่ได้รับ (Net Amount):** {net_amount:,.2f} บาท")
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
st.title("โปรแกรมคำนวณราคาสินค้า (VAT 7% และหัก ณ ที่จ่าย 3% จากเงินต้น)")
|
|
|
4 |
|
5 |
st.markdown(
|
6 |
"""
|
7 |
+
โปรแกรมนี้ช่วยคำนวณราคาสินค้าโดยใช้สูตร:
|
8 |
+
- **VAT 7%:** คำนวณจาก Base Price
|
9 |
+
- **หัก ณ ที่จ่าย 3%:** คำนวณจาก Base Price
|
10 |
+
- **ยอดสุทธิที่ได้รับ:** Base Price + VAT - Withholding Tax
|
11 |
+
|
12 |
+
ซึ่งสามารถเขียนเป็นสมการได้ว่า:
|
13 |
+
**Net Amount = Base Price × 1.04**
|
14 |
|
15 |
คุณสามารถเลือกกรอกข้อมูลที่คุณทราบได้จาก 3 ตัวเลือก แล้วระบบจะคำนวณตัวเลขที่เหลือให้โดยอัตโนมัติ
|
16 |
"""
|
|
|
25 |
# รับค่าจำนวนเงินจากผู้ใช้
|
26 |
amount = st.number_input("กรอกจำนวนเงิน:", min_value=0.0, format="%.2f")
|
27 |
|
|
|
28 |
if amount:
|
29 |
if calc_option == "ราคาก่อน VAT (Base Price)":
|
30 |
base_price = amount
|
31 |
+
vat = base_price * 0.07
|
32 |
+
withholding_tax = base_price * 0.03
|
33 |
+
invoice_price = base_price + vat
|
34 |
+
net_amount = base_price + vat - withholding_tax
|
35 |
elif calc_option == "ราคาสินค้ารวม VAT (Invoice Price)":
|
36 |
+
# จาก Invoice Price เราได้ว่า: Invoice Price = Base Price + VAT = Base Price * 1.07
|
37 |
+
base_price = amount / 1.07
|
38 |
+
vat = base_price * 0.07
|
39 |
+
withholding_tax = base_price * 0.03
|
40 |
+
net_amount = base_price + vat - withholding_tax
|
41 |
invoice_price = amount
|
|
|
|
|
42 |
elif calc_option == "ยอดสุทธิที่ได้รับ (Net Amount)":
|
43 |
+
# จาก Net Amount = Base Price × 1.04 => Base Price = Net Amount / 1.04
|
44 |
+
base_price = amount / 1.04
|
45 |
+
vat = base_price * 0.07
|
46 |
+
withholding_tax = base_price * 0.03
|
47 |
+
invoice_price = base_price + vat
|
48 |
net_amount = amount
|
|
|
|
|
49 |
|
|
|
50 |
st.subheader("ผลลัพธ์:")
|
51 |
st.write(f"**ราคาก่อน VAT (Base Price):** {base_price:,.2f} บาท")
|
52 |
+
st.write(f"**VAT (7%):** {vat:,.2f} บาท")
|
53 |
+
st.write(f"**ยอดสินค้ารวม VAT (Invoice Price):** {invoice_price:,.2f} บาท")
|
54 |
+
st.write(f"**หัก ณ ที่จ่าย (3% จาก Base Price):** {withholding_tax:,.2f} บาท")
|
55 |
st.write(f"**ยอดสุทธิที่ได้รับ (Net Amount):** {net_amount:,.2f} บาท")
|