-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcashflow.py
316 lines (170 loc) · 9.1 KB
/
cashflow.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
from tkinter import *
from tkinter import ttk
import datetime
import cashflow_check
import inventory_purchase_database
import test3
import databaseinv
import checking
import construction_cost_database
import labor_allocation_database
import work_database
import interior_designing_labor_database
import reciept_database
import payment_database
import paymentposdb
date_and_time = datetime.date.today()
date1 = str(date_and_time)
import test3
import payment_database
import reciept_database
def searchentry(ent, b, btn, x, lbl):
fromdate = ent(b, placeholder_text="From Date",
width=10,)
fromdate.grid(row=3, column=0, columnspan=1, pady=2, padx=20, sticky="we")
todate = ent(b, placeholder_text="To Date",
width=10,)
todate.grid(row=4, column=0, columnspan=1, pady=2, padx=20, sticky="we")
format = lbl(b, text = "Date format: yyyy-mm-dd",
width=10,)
format.grid(row=5, column=0, columnspan=1, pady=2, padx=20, sticky="we")
todate.insert(0, date_and_time)
opening_Balance_entry = ent(b, placeholder_text="Opening Balance",
width=10,)
opening_Balance_entry.grid(row=6, column=0, columnspan=1, pady=2, padx=20, sticky="we")
data = []
def getestimate():
my_tree1.delete(*my_tree1.get_children())
# estimate, date1 = checking.estimatecollection(customer_name_entry.get())
# data.append(date1)
# data.append(estimate)
count = 0
if count == 0:
my_tree1.insert(parent="", index="end", iid=count, text="", values=(fromdate.get(), opening_Balance_entry.get()), tags=("evenrow",))
date1, reciept = cashflow_check.get_reciept(fromdate.get(), todate.get())
date2, payment = cashflow_check.get_payment(fromdate.get(), todate.get())
count = 1
for i in range(len(date1)):
my_tree1.insert(parent="", index="end", iid=count, text="", values=(date1[i], '', reciept[i]), tags=("evenrow",))
count += 1
for i in range(len(date2)):
my_tree1.insert(parent="", index="end", iid=count, text="", values=(date2[i], '', '', payment[i]), tags=("evenrow",))
count += 1
total_reciept = 0
total_payment = 0
for i in reciept:
total_reciept += i
for i in payment:
total_payment += i
closing_balance = (int(opening_Balance_entry.get()) + total_reciept) - total_payment
count = count + 1
my_tree1.insert(parent="", index="end", iid=count, text="", values=("Closing Balance", '', '', "", closing_balance), tags=("evenrow",))
# # else:
# # my_tree1.insert(parent="", index="end", iid=count, text="", values=(date1, estimate), tags=("oddrow",))
# # increment counter
# count = 1
# date2, reciept = checking.reciept_collection(customer_name_entry.get())
# for i in range(len(date2)):
# my_tree1.insert(parent="", index="end", iid=count, text="", values=(date2[i],'', reciept[i]), tags=("evenrow",))
# count += 1
# # print(date2)
# # print(reciept)
# date3, payment = checking.payment_collection(customer_name_entry.get())
# for i in range(len(date3)):
# my_tree1.insert(parent="", index="end", iid=count, text="", values=(date3[i],'','', payment[i]), tags=("evenrow",))
# count += 1
# date4, material_allocation = checking.material_allocation_collection(customer_name_entry.get())
# for i in range(len(date4)):
# my_tree1.insert(parent="", index="end", iid=count, text="", values=(date4[i],'','','', material_allocation[i]), tags=("evenrow",))
# count += 1
# total_reciept = 0
# for i in reciept:
# total_reciept += i
# balance = estimate - total_reciept
# count = count + 1
# if balance == 0:
# my_tree1.insert(parent="", index="end", iid=count, text="", values=('Balance due','','','', '', "Closed"), tags=("evenrow",))
# else:
# my_tree1.insert(parent="", index="end", iid=count, text="", values=('Balance due','','','', '', balance), tags=("evenrow",))
submit_button = btn(b,
text="Submit",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=getestimate
)
submit_button.grid(row=3, column=1, padx=10)
label1 = lbl(x, text="Cash Flow Statement")
label1.grid(column=0, row=0)
style = ttk.Style()
# pick a theme
style.theme_use('default')
# configure the treeview colors
style.configure("Treeview", background="lightblue", foreground="black", rowheight=25, fieldbackground="grey")
# change selected color
style.map("Treeview", background=[('selected', "green")])
# create a treeview
tree_frame1 = Frame(x)
tree_frame1.grid(padx=10, pady=10, row=1, column=0, rowspan=11)
# create scroll bar
tree_scroll1 = Scrollbar(tree_frame1)
tree_scroll1.pack(side=RIGHT, fill=Y)
# create the treeview
my_tree1 = ttk.Treeview(tree_frame1, yscrollcommand=tree_scroll1.set, selectmode="extended")
my_tree1.pack()
# configure the scroll bar
tree_scroll1.config(command=my_tree1.yview)
# define our columns
my_tree1['columns'] = ("date_and_time","opening_balance", "cash_inflow", "cash_outflow","closing_balance")
# format our columns
my_tree1.column("#0", width=0, stretch=NO)
my_tree1.column("date_and_time", anchor=W, width=150)
my_tree1.column("opening_balance", anchor=W, width=150)
my_tree1.column("cash_inflow", anchor=W, width=150)
my_tree1.column("cash_outflow", anchor=W, width=150)
my_tree1.column("closing_balance", anchor=W, width=150)
# create Headings
my_tree1.heading("#0", text="", anchor=W)
my_tree1.heading("date_and_time", text="Date", anchor=W)
my_tree1.heading("opening_balance", text="Opening Balance", anchor=W)
my_tree1.heading("cash_inflow", text="Cash Inflow", anchor=W)
my_tree1.heading("cash_outflow", text="Cash Outflow", anchor=W)
my_tree1.heading("closing_balance", text="Closing Balance", anchor=W)
# create striped row tags
# create striped row tags
# my_tree1.tag_configure('oddrow', background="white", foreground="darkgreen")
# my_tree1.tag_configure('evenrow', background="white", foreground="darkblue")
# class Autofill:
# lb15 = Listbox(b)
# lb15.grid(row=4, column=0, rowspan=3, padx=20, pady=5)
# def updatelb(self,data):
# self.lb15.delete(0, END)
# for item in data:
# self.lb15.insert(END, item)
# def fillout(self, e):
# li14 = test3.dbfetch()
# customer_name_entry.delete(0, END)
# # supplier_name_entry.insert(0, lb15.get(ANCHOR))
# for i in li14:
# if self.lb15.get(ANCHOR) in i:
# customer_name_entry.insert(0, i[2])
# self.lb15.delete(0, END)
# def check(self, e):
# li14 = test3.dbfetch()
# li15 = []
# for i in li14:
# li15.append(i[2])
# typed = customer_name_entry.get()
# if typed == '':
# data = li15
# else:
# data = []
# for item in li15:
# if typed.lower() in item.lower():
# data.append(item)
# self.updatelb(data)
# customer = Autofill()
# customer.lb15.bind("<<ListboxSelect>>", customer.fillout)
# customer_name_entry.bind("<KeyRelease>", customer.check)
# # # updatelb(li15)
# # lb15.bind("<<ListboxSelect>>", fillout)
# # supplier_name_entry.bind("<KeyRelease>", check)