Fixed a logical error in itemwise_report_with_payment_method

This commit is contained in:
Srinivas-Saravanan 2024-10-29 16:10:27 +05:30
parent f36d3fbd1e
commit f30d6db2b7
2 changed files with 8 additions and 4 deletions

View File

@ -618,12 +618,16 @@ public function itemwise_report_data_with_payment_method($f_date = null, $t_date
COUNT(invoiceitems.product) AS item_count,
SUM(invoiceitems.quantity * invoiceitems.unit_price) AS total_cost,
invoice.payment_method,
DATE_FORMAT(books.publication_date, "%d-%m-%Y") AS book_publication_date');
DATE_FORMAT(invoice.invoice_date, "%d-%m-%Y") AS invoice_date');
$builder->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left');
$builder->join('books', 'books.book_id = invoiceitems.product', 'left');
$builder->where('invoice.isactive', 1);
$builder->where('invoice.invoice_type', 1);
$builder->where('books.isactive', 1);
if ($f_date !== null && $t_date !== null) {
$builder->where('invoice_date >=', $f_date)
->where('invoice_date <=', $t_date);
}
$builder->groupBy(['books.publishers_code', 'books.title', 'invoice.payment_method']);
$query = $builder->get();
@ -656,7 +660,7 @@ public function itemwise_report_data_with_payment_method($f_date = null, $t_date
'book_name' => $row['book_name'],
'item_count' => $row['item_count'],
'total_cost' => $row['total_cost'],
'book_publication_date' => $row['book_publication_date'],
'invoice_date' => $row['invoice_date'],
];
}

View File

@ -36,7 +36,7 @@
<th><b>Item Count</b></th>
<th><b>Total Cost</b></th>
<th><b>Payment method</b></th>
<th><b>Published Date</b></th>
<th><b>Invoice Date</b></th>
</tr>
</thead>
<tbody>
@ -50,7 +50,7 @@
<td><?= $book->item_count ?></td>
<td><?= number_format($book->total_cost, 2) ?></td>
<td><?= $row->payment_method ?></td>
<td><?= $book->book_publication_date ?></td>
<td><?= $book->invoice_date ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>