Here, I have developed the enterprise software in python. I have a database and in that I have bill_details
table and paid_details
table. The bill_details
table will have amount to be paid
,date
and name
. In paid_details
table has name
and paid amount
and this is the scenario.
If the user want to know how much the payment dues
are there then I should print the due amount
.
For eg.
bill_details
name amt_pending date
xyz 100 20-09-2020
xyz 50 21-09-2020
xyz 200 22-09-2020
xyz 20 23-09-2020
In paid details table paid_details
name paid_amt date
xyz 100 21-09-2020
xyz 50 22-09-2020
and these are my tables. I need output like this
xyz
22-09-2020 200
23-09-2020 20
I need to tally the pending amount with the paid amount and display the pending amount. How can I achieve this? I have tried it with list but that worked but I can't map those dates with the pending amount. Please help me with this.
I have added the code that I have tried
date = [1,2,3,4,5,6,7,8,9,10]
pending = [10,100,5,6]
paid = [10,100,5]
c = pending.copy()
# clen=len(c)
for i in range(len(paid)):
print(paid[i],pending[i],i)
# alen = len(a)
if(paid[i]-pending[i]==0):
c.remove(paid[i])
else:
c[i] = pending[i] - paid[i]
# print(a[-1]-b[i])
print(pending)
try this:
fields = ['Name', 'amt_pending', 'date', 'paid_amt']
rows = [ ['xyz', 100, '20-09-2020', 100],
['xyz', 50, '21-09-2020', 50],
['xyz', 200, '22-09-2020', 0]]
for i in rows:
if i[1] == i[3]:
print('no pending remaining')
else:
a = i[1] - i[3]
print("pending amount is: " + str(a) + ' on ' + str(i[2]))