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 @@