From f30d6db2b76946bac8bc1d32d57bdc3878d6fd72 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 29 Oct 2024 16:10:27 +0530 Subject: [PATCH] Fixed a logical error in itemwise_report_with_payment_method --- app/Models/InvoiceModel.php | 8 ++++++-- app/Views/itemwise_report_with_payment_method.php | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index a80d001a..cb88c6a7 100755 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -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'], ]; } diff --git a/app/Views/itemwise_report_with_payment_method.php b/app/Views/itemwise_report_with_payment_method.php index 758fe2b4..11bee68f 100644 --- a/app/Views/itemwise_report_with_payment_method.php +++ b/app/Views/itemwise_report_with_payment_method.php @@ -36,7 +36,7 @@ Item Count Total Cost Payment method - Published Date + Invoice Date @@ -50,7 +50,7 @@ item_count ?> total_cost, 2) ?> payment_method ?> - book_publication_date ?> + invoice_date ?>