From a2e1a3d380d208c18c94ca1c4c69aa7bd17b87f2 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 1 Apr 2024 18:49:30 +0530 Subject: [PATCH] Change_Invoice_calc_decimal_calculate : ps --- app/Controllers/Invoice.php | 5 +- app/Models/InvoiceModel.php | 3 +- app/Views/invoice_form.php | 102 ++++++++++++++++------------- app/Views/invoice_list.php | 3 - app/Views/invoice_pdf_template.php | 12 ++++ app/Views/offline_invoice_list.php | 5 -- 6 files changed, 75 insertions(+), 55 deletions(-) diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 6bf7e94d..aea543f5 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -239,7 +239,8 @@ class Invoice extends BaseController 'subtotal' => (float)$this->request->getPost('sub_total'), 'tax' => (float)$this->request->getPost('invoice_tax'), 'discount' => (float)$this->request->getPost('discount'), - 'total_amount' => (float)$this->request->getPost('grand_total'), + 'exact_total_amount' => (float)$this->request->getPost('exact_total_amount'), + 'total_amount' => (int)$this->request->getPost('grand_total'), 'shipping_charge' => ((int)$invoiceType === 1) ? (float)$this->request->getPost('shippingCharges') : NULL, 'shipping_label' => ((int)$invoiceType === 1) ? $this->request->getPost('shippingChargesLabel') : NULL, 'order_number' => $this->request->getPost('order_number'), @@ -251,6 +252,7 @@ class Invoice extends BaseController 'status' => $invoice_status, 'isactive' => 1 ]; + ## Based on the invoice ID, we designated Insert or Update on Details... if (empty($invoice_id)) { $data['created_by'] = (int)get_logged_user_id(); @@ -268,6 +270,7 @@ class Invoice extends BaseController } else { $data['updated_by'] = (int)get_logged_user_id(); if ($model->update($invoice_id, $data)) { + // echo $model->getLastQuery();die; session()->setFlashdata('success', $msg_flag_name.'has been updated successfully.'); $this->logger->info($msg_flag_name.": has been updated successfully. Updated ID = " . $invoice_id); } else { diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 1b76c423..4f4b4009 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -8,7 +8,7 @@ class InvoiceModel extends Model protected $table = 'invoice'; protected $primaryKey = 'invoice_id'; // protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id']; -protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','shipping_label','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status','payment_note']; +protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','shipping_label','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status','payment_note','exact_total_amount']; public function saveInvoiceItemDetails($data){ $i = 0; @@ -137,6 +137,7 @@ public function getJoinedData($where, $orderby = []) // $query->orderBy('invoice_id', 'DESC'); // } $query->orderBy('I.invoice_date', 'DESC'); + $query->orderBy('I.invoice_id', 'DESC'); $query->groupBy('I.invoice_id'); $resultArray = $query->get()->getResultArray(); diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index a66e9434..f4783b23 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -219,59 +219,66 @@
-
+

Calculation

-
- - +
+
+ + +
+ +
+ + +
-
- - -
- + -
- - - > - -
-
- + $shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : ''; + ?> +
+ + + > + +
+
+ min="0" step="0.01"> - + +
- - - -
- - +
+
+ + +
+
+ + +
-
- - -
- -
- - -
- -
- - +
+
+ + +
+
+ + +
@@ -732,8 +739,10 @@ cell1.innerHTML=html; var discountElement = parseFloat(overallDiscount.toFixed(2)); $("#discount").val(discountElement); - var totalElement = parseFloat(total.toFixed(2)); + var totalElement = Math.round(total); + $("#exacttotal").val(parseFloat(total.toFixed(2))); $("#grandtotal").val(totalElement); + var status = document.getElementById('status').value; // $("#balanceAmount").val(totalElement); @@ -788,7 +797,10 @@ cell1.innerHTML=html; // Update the grand total in the UI var grandTotalElement = parseFloat(grandTotal.toFixed(2)); - document.getElementById("grandtotal").value = grandTotalElement; + document.getElementById("exacttotal").value = grandTotalElement; + document.getElementById("grandtotal").value = Math.round(grandTotalElement); + + } diff --git a/app/Views/invoice_list.php b/app/Views/invoice_list.php index cb6ee294..9d7db0ee 100644 --- a/app/Views/invoice_list.php +++ b/app/Views/invoice_list.php @@ -17,9 +17,6 @@ #printPdfButton .ri-printer-line { font-size: 8px; } - .dotted-underline { - text-decoration: underline dotted; - } .modal-lg, .modal-xl { max-width: 678px; } diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php index 2691ed9b..771a0e84 100644 --- a/app/Views/invoice_pdf_template.php +++ b/app/Views/invoice_pdf_template.php @@ -259,6 +259,9 @@ p { Subtotal :   ₹subtotal, 2, '.', ',') ?> + + Discount :   discount ? "(-)".number_format($value->discount, 2, '.', ','): number_format(0, 2, '.', ',') ?> + shipping_label != '') : ?> @@ -266,6 +269,15 @@ p { shipping_label?> :   ₹shipping_charge, 2, '.', ',') ?> + + + total_amount >= $value->exact_total_amount) ? '+' : '-'; + $difference = abs($value->exact_total_amount - $value->total_amount); + ?> + + Rounding :    + Total :   ₹total_amount, 2, '.', ',') ?> diff --git a/app/Views/offline_invoice_list.php b/app/Views/offline_invoice_list.php index 0d924505..c0375966 100644 --- a/app/Views/offline_invoice_list.php +++ b/app/Views/offline_invoice_list.php @@ -19,11 +19,6 @@ .modal-lg, .modal-xl { max-width: 678px; } - -