zenityx commited on
Commit
4e8182e
·
verified ·
1 Parent(s): 94edb92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
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
- - **ราคาก่อน VAT (Base Price)**
11
- - **ราคาสินค้ารวม VAT (Invoice Price)** โดยใช้ VAT 7% คือ
12
- *Invoice Price = Base Price × 1.07*
13
- - **ยอดสุทธิที่ได้รับ (Net Amount)** หลังหัก ณ ที่จ่าย 3% คือ
14
- *Net Amount = Invoice Price × 0.97*
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
- invoice_price = base_price * 1.07
34
- net_amount = invoice_price * 0.97
 
 
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"**ราคาสินค้ารวม VAT (Invoice Price):** {invoice_price:,.2f} บาท")
 
 
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} บาท")