@php
$total_deduction = 0;
$curr_grand_amount = 0;
$prev_grand_amount = 0;
$grand_total_amount = 0;
$curr_work_portion_amount = 0;
$prev_work_portion_amount = 0;
if (!empty($ra_bill)) {
// Query to calculate previous work portion amount
$prev_work_portion = DB::table('tbl_emb_final_bills')
->select(DB::raw('sum(Amount) as TotalAmount'))
->where('ProjectIDRef', $row->ProjectID)
->where('IsTaxable', 'yes')
->where('BillNo', '<', $bill['BillNo'])
->first();
if (!empty($prev_work_portion)) {
$prev_work_portion_amount = $prev_work_portion->TotalAmount;
}
foreach ($ra_bill as $r) {
$prev_total_qty = 0;
$prev_total_amount = 0;
if ($r['IsTaxable'] == 'yes') {
$curr_work_portion_amount += $r['Amount'];
}
// Query to calculate previous bill amount and quantity
$prev_bill = DB::table('tbl_emb_final_bills')
->select(DB::raw('sum(Amount) as prev_total_amount, sum(Quantity) as prev_total_quantity'))
->where('ProjectIDRef', $row->ProjectID)
->where('DSRItemCodeRef', $r['DSRItemCodeRef'])
->where('BillNo', '<', $bill['BillNo'])
->first();
if (!empty($prev_bill->prev_total_quantity)) {
$prev_total_qty += $prev_bill->prev_total_quantity;
}
if (!empty($prev_bill->prev_total_amount)) {
$prev_total_amount += $prev_bill->prev_total_amount;
}
$upto_total_qty = number_format($prev_total_qty + $r['Quantity'], 2, '.', '');
$upto_total_amt = number_format($prev_total_amount + $r['Amount'], 2, '.', '');
$curr_grand_amount += $r['Amount'];
$prev_grand_amount += $prev_total_amount;
$grand_total_amount += ($r['Amount'] + $prev_total_amount);
}
}
@endphp
@include('bill.header')
{{ strtoupper('III Memorandum of Payments') }}
Part IV - Memorandum of Payments
1. Total value of work actually measured as part I, column 8 entry (A) |
{{ number_format($curr_work_portion_amount, 2) }} |
2. Total up-to-date advance payments for work not yet measured as per part I, column 3, entry (B) |
|
3. Total up-to-date advances on security for work not yet measured as per part II, column 8, entry (C) |
|
4. Total (item 1 + 2 + 3) |
|
5. Deduct-amount withheld: |
|
Figures of work Abstract |
|
Rs. |
|
|
(a) From previous Bill as per last Running Bill Account |
{{ number_format($prev_grand_amount, 2) }} |
|
|
(b) From this Bill |
{{ number_format($grand_total_amount, 2) }} |
|
|
6. Balance i.e up-to-date payments (item 4-5) |
{{ number_format($prev_grand_amount + $grand_total_amount, 2) }} |
|
|
7. Total amount of payments already made as per entry (K) of last Running Account Bill No. …………….. |
{{ number_format($grand_total_amount, 2) }} |
|
|
8. Payments now to be made as detailed below |
{{ number_format($grand_total_amount, 2) }} |
|
|
(a) { By recovery of amounts creditable to this work } (a) |
|
|
|
Total 5(b) + 5(a) G |
{{ number_format($prev_grand_amount + $grand_total_amount, 2) }} |
|
|
(b) By recovery of amounts creditable to other works or head of account. (b) |
|
|
|
(b) by cheque |
|
|
|
Total 8 {b}:- {H} |
|
|