Hi guys, I need help achieving a certain task, I have a system which creates credit accounts for clients, this information is displayed in a view called credit_details , what I want is for this information to stop displaying once the customer has paid all of their credit but without deleting the credit information from the credit_info and credit_invoice tables, that information is vital for some accounting calculations, how can achieve this task?
def credit_details():
session.details=db.Client_Details(request.args(0, cast=int))
resCompany=db(db.resident_company).select()
db.credit_info.customer.default=
session.details.id form=SQLFORM(db.credit_info)
if form.process().accepted:
response.flash=T('Payment Made')
return locals()
def credit_calculations():
customer=db(db.credit_info.customer==
session.details.id).select()
payment=db(db.credit_info.customer==
session.details.id).select(db.credit_info.amount_paid.sum().with_alias('payment_total'))
total_amount=db(db.credit_invoice.customer==
session.details.id).select(db.credit_invoice.Amount.sum().with_alias('total'))
return locals()
<table>
<th>AMOUNT PAID</th>
<th>ATTENDED BY</th>
<th>DATE & TIME</th>
{{for customer in customer:}}
<tr>
<td style="font-weight: bold;">{{=MoneyFormat(customer.amount_paid)}}</td>
<td style="font-weight: bold;">{{=customer.attended_by.first_name}} {{=customer.attended_by.last_name}}</td>
<td style="font-weight: bold;">{{=customer.paid_on}}</td>
</tr>
{{pass}}
<tr>
{{for total_amount in total_amount:
if total_amount.total is None:
total_amount.total=0
}}
<td style="font-weight: bold; color: red; font-size: 20px;">THIS CLIENT HAS NO CREDIT!!!</td>
</tr>
{{pass}}
<tr>
<td style="font-weight: bold; border: solid 2px red; border-radius: 10px; padding: 5px;">CREDIT DUE: {{=MoneyFormat(total_amount.total)}}</td>
{{for payment in payment:}}
{{if payment.payment_total is None:}}
{{payment.payment_total=0}}
<td style="font-weight: bold; border: solid 2px green; border-radius: 10px; padding: 5px;">CREDIT BALANCE AFTER PAYMENTS: {{=MoneyFormat(total_amount.total-payment.payment_total)}}</td>
<td style="font-weight: bold; border: solid 2px green; border-radius: 10px; padding: 5px;">TOTAL AMOUNT PAID THUS FAR: {{=MoneyFormat(payment.payment_total)}}</td>
<td style="font-weight: bold; color: red;">No Payment Made Yet!</td>
{{else:}}
<td style="font-weight: bold;border: solid 2px green; border-radius: 10px; padding: 5px;">CREDIT BALANCE AFTER PAYMENTS: {{=MoneyFormat(total_amount.total-payment.payment_total)}}</td>
<td style="font-weight: bold; border: solid 2px green; border-radius: 10px; padding: 5px;">TOTAL AMOUNT PAID THUS FAR: {{=MoneyFormat(payment.payment_total)}}</td>
{{pass}}
{{pass}}
{{pass}}
{{pass}}
</tr>
</table>
<script>
$('document').ready(function(){
$(".delete").click(function(){
return confirm('Are you sure you want to clear this CLIENT?!');
});
});
</script>
<div id="delete"><a class="delete" href="{{=URL('delete_credit_client', args=
session.details.id)}}">Clear Client From Credit</a></div>