-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVatCalculator1.3.4 - Copy.py
196 lines (176 loc) · 7.4 KB
/
VatCalculator1.3.4 - Copy.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import os
from art import *
#import curses
#function that calculate from total amount with vat
def calculate_vat(gross_amount):
vat = gross_amount / 1.15 * 0.15
return vat
#function that calculate vat from first amount
def calculate_net_amount(gross_amount):
net_amount = gross_amount *.15
return net_amount
def about_app():
print('The Vat is %15 for calculation base on Saudi Arabia.')
print('Version 1.3.2\nRelease on March 14 2023\n')
print(" Created by: ")
tprint('Basri')
print("Contact on Facebook\nBasri Dalanda\n")
def option_one():
os.system('cls' if os.name == 'nt' else 'clear')
print('You have Entered Option 1')
print("Calculating from Total Amount\n")
while True:
try:
gross_amount = float(input("Enter Total Amount with VAT: "))
break
except ValueError:
print('Invalid Input! Please Enter number only.\n')
except KeyboardInterrupt:
os.system('cls' if os.name == 'nt' else 'clear')
vat_calculator()
vat = calculate_vat(gross_amount)
net_amount = gross_amount - vat
print(f"First Amount: {net_amount:.2f}")
print(f"VAT Amount: {vat:.2f}\n")
def option_two():
os.system('cls' if os.name == 'nt' else 'clear')
print('You have Entered Option 2')
print("Checking Vat from First Amount\n")
while True:
try:
gross_amount = float(input("Enter First Amount: "))
break
except ValueError:
print('Invalid Input! Please Enter number only.\n')
except KeyboardInterrupt:
os.system('cls' if os.name == 'nt' else 'clear')
vat_calculator()
vat = calculate_net_amount(gross_amount)
net_amount = gross_amount + vat
print(f"VAT Amount: {vat:.2f}")
print(f"Total Amount with VAT: {net_amount:.2f}\n")
def multiple_input():
def calculate_net_and_vat(total_amount_with_vat):
vat = total_amount_with_vat * 15 / 115
net_amount = total_amount_with_vat - vat
return net_amount, vat
lst = []
while True:
try:
os.system('cls' if os.name == 'nt' else 'clear')
print("You have Entered Option 3.")
print("Calculating Multiple Invoice with single Payment.\n")
n = int(input("How many invoices do you want to enter? : "))
if n <= 0:
raise ValueError("Number of invoices must be positive.")
break
except ValueError:
print("Invalid input. Please enter a positive integer.")
except KeyboardInterrupt:
os.system('cls' if os.name == 'nt' else 'clear')
vat_calculator()
# Enter all invoices first
for i in range(n):
while True:
try:
total_amount_with_vat = float(input("Enter Total Amount with VAT: "))
if total_amount_with_vat <= 0:
raise ValueError("Amount must be positive.")
break
except ValueError:
print("Invalid input. Please enter a positive number.")
except KeyboardInterrupt:
os.system('cls' if os.name == 'nt' else 'clear')
multiple_input()
lst.append(total_amount_with_vat)
# Print the invoices, net amounts, and VAT amounts in a column format
os.system('cls' if os.name == 'nt' else 'clear')
print("{:<10} {:<20} {:<20} {:<20}".format("\nInvoice", "First Amount", "VAT Amount","Total Amount with VAT"))
for i in range(n):
gross_amount = lst[i]
net_amount, vat = calculate_net_and_vat(lst[i])
print("{:<10} {:<20.2f} {:<20.2f} {:<20.2f}".format(i+1, net_amount, vat,gross_amount))
# Calculate the sum of the numbers in the list
total = sum(lst)
print(f"\nTotal of All invoices with VAT: {total:.2f}")
while True:
try:
bank_amount = float(input("Enter Payment Amount: "))
break
except ValueError:
print('Invalid Input! Please Enter number only.\n')
except KeyboardInterrupt:
os.system('cls' if os.name == 'nt' else 'clear')
multiple_input()
dif = bank_amount - total
if total > bank_amount :
print(f"Amount Difference is: {dif:.2f}")
print("Bank Payment is less.\n")
elif total == bank_amount:
print("Bank Amount are Correct.\n")
else :
print(f"Amount Difference is: {dif:.2f}")
print("Bank Amount is more.\n") # this function is to calculate multiple invoice
def vat_calculator():
print(text2art('Vat Calculator',font="small"))
while True:
print("[1]: Calculate from Total Amount")
print("[2]: Calculate from First Amount")
print("[3]: Calculate Multiple Invoice")
print("[4]: About")
choice = input("\nEnter Option: ")
if choice == '1':
os.system('cls' if os.name == 'nt' else 'clear')
option_one()
while True:
choice = input("Enter to calculate again or type 'n' to exit: ")
#os.system('cls' if os.name == 'nt' else 'clear')
if choice.lower() == 'n':
break
elif choice != '':
print("Invalid choice! Press Enter to calculate again or type 'n' to exit...")
continue
else:
option_one()
#to calculate the vat from first amount
elif choice == '2':
os.system('cls' if os.name == 'nt' else 'clear')
option_two()
while True:
choice = input("Enter to calculate again or type 'n' to exit: ")
#os.system('cls' if os.name == 'nt' else 'clear')
if choice.lower() == 'n':
break
elif choice != '':
print("Invalid choice! Press Enter to calculate again or type 'n' to exit...")
continue
else:
option_two()
elif choice == '3':
os.system('cls' if os.name == 'nt' else 'clear')
multiple_input()
while True:
choice = input("Enter to calculate again or type 'n' to exit: ")
#os.system('cls' if os.name == 'nt' else 'clear')
if choice.lower() == 'n':
break
elif choice != '':
print("Invalid choice! Press Enter to calculate again or type 'n' to exit...")
continue
else:
multiple_input()
elif choice == '4':
os.system('cls' if os.name == 'nt' else 'clear')
about_app()
else:
os.system('cls' if os.name == 'nt' else 'clear')
print("Invalid Input...")
vat_calculator()
continue
choice = input("Press Enter to Continue...")
#jump here if the user press n, but the problem is about is not showing
os.system('cls' if os.name == 'nt' else 'clear')
vat_calculator()
if choice.lower() == 'n':
break #this is the main
vat_calculator()