Change_Invoice_calc_decimal_calculate : ps
This commit is contained in:
parent
94cc3690e1
commit
a2e1a3d380
@ -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 {
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -219,59 +219,66 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="offset-md-7 col-md-5 card">
|
||||
<div class="offset-md-6 col-md-6 card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="number" class="form-control" id="subtotal" name="sub_total" readonly value="<?= isset($invoice_details['subtotal']) ? (float)$invoice_details['subtotal'] : 0 ?>" min="0" step="0.01">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="number" class="form-control" id="subtotal" name="sub_total" value="<?= isset($invoice_details['subtotal']) ? (float)$invoice_details['subtotal'] : 0 ?>" readonly>
|
||||
</div>
|
||||
<div class="form-group" style="display: none;">
|
||||
<label for="invoicetax">Tax Amount</label>
|
||||
<input type="hidden" class="form-control" id="invoicetax" name="invoice_tax" value="<?= isset($invoice_details['tax']) ? (float)$invoice_details['tax'] : 0 ?>" readonly>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? (float)$invoice_details['discount'] : 0 ?>" min="0" step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="invoicetax">Tax Amount</label>
|
||||
<input type="number" class="form-control" id="invoicetax" name="invoice_tax" readonly value="<?= isset($invoice_details['tax']) ? (float)$invoice_details['tax'] : 0 ?>" min="0" step="0.01">
|
||||
</div>
|
||||
<?php
|
||||
// Check if it's a subscription invoice
|
||||
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
||||
<div class="form-row">
|
||||
<?php
|
||||
// Check if it's a subscription invoice
|
||||
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
||||
|
||||
// Conditionally set the "hidden" attribute for the fields
|
||||
// Conditionally set the "hidden" attribute for the fields
|
||||
|
||||
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
||||
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
||||
|
||||
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
?>
|
||||
<div class="form-group">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
<label for="shippingChargesLabel">Charge Name </label>
|
||||
<input type="text" class="form-control" id="shippingChargesLabel" name="shippingChargesLabel" placeholder="Shipping Charges Label" value="<?= isset($invoice_details['shipping_label']) ? $invoice_details['shipping_label'] : 'Shipping Charge' ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> >
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||
?>
|
||||
<div class="form-group col-md-6">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
<label for="shippingChargesLabel">Charge Name </label>
|
||||
<input type="text" class="form-control" id="shippingChargesLabel" name="shippingChargesLabel" placeholder="Shipping Charges Label" value="<?= isset($invoice_details['shipping_label']) ? $invoice_details['shipping_label'] : 'Shipping Charge' ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> >
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<span style="<?= $shippingChargesStyle ?>">
|
||||
<label for="shippingCharges">Charge Amount </label>
|
||||
<input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? (float)$invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> min="0" step="0.01">
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? (float)$invoice_details['discount'] : 0 ?>" min="0" step="0.01">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="exacttotal">Total</label>
|
||||
<input type="number" class="form-control" id="exacttotal" name="exact_total_amount" value="<?= isset($invoice_details['total_amount']) ? (float)$invoice_details['exact_total_amount'] : 0 ?>" readonly>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="grandtotal">Total (Round-off)</label>
|
||||
<input type="number" class="form-control" id="grandtotal" name="grand_total" value="<?= isset($invoice_details['total_amount']) ? (int)$invoice_details['total_amount'] : 0 ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="grandtotal">Total</label>
|
||||
<input type="number" class="form-control" id="grandtotal" name="grand_total" readonly value="<?= isset($invoice_details['total_amount']) ? (float)$invoice_details['total_amount'] : 0 ?>" min="0" step="0.01">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="balanceAmount">Balance Amount</label>
|
||||
<input type="number" class="form-control" id="balanceAmount" name="balanceAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? (float)$invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly min="0" step="0.01">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="paidAmount">Paid Amount</label>
|
||||
<input type="number" class="form-control" id="paidAmount" name="paidAmount" value="<?= (isset($invoice_details['status']) && (float)$invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="balanceAmount">Balance Amount</label>
|
||||
<input type="number" class="form-control" id="balanceAmount" name="balanceAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? (float)$invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="paidAmount">Paid Amount</label>
|
||||
<input type="number" class="form-control" id="paidAmount" name="paidAmount" value="<?= (isset($invoice_details['status']) && (float)$invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -17,9 +17,6 @@
|
||||
#printPdfButton .ri-printer-line {
|
||||
font-size: 8px;
|
||||
}
|
||||
.dotted-underline {
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
.modal-lg, .modal-xl {
|
||||
max-width: 678px;
|
||||
}
|
||||
|
||||
@ -259,6 +259,9 @@ p {
|
||||
<tr>
|
||||
<td colspan="5" align="right">Subtotal : ₹<?= number_format($value->subtotal, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" align="right">Discount : <?= $value->discount ? "(-)".number_format($value->discount, 2, '.', ','): number_format(0, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
|
||||
<!-- -->
|
||||
<?php if ($value->shipping_label != '') : ?>
|
||||
@ -266,6 +269,15 @@ p {
|
||||
<td colspan="5" align="right"><?= $value->shipping_label?> : ₹<?= number_format($value->shipping_charge, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
|
||||
<?php
|
||||
$sign = ($value->total_amount >= $value->exact_total_amount) ? '+' : '-';
|
||||
$difference = abs($value->exact_total_amount - $value->total_amount);
|
||||
?>
|
||||
|
||||
<td colspan="5" align="right"> Rounding : <?= $sign.number_format($difference, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" align="right">Total : ₹<?= number_format($value->total_amount, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
.modal-lg, .modal-xl {
|
||||
max-width: 678px;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.dotted-underline {
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
</style>
|
||||
<!-- /* CSS for modal content */
|
||||
#pdfPreviewModal .modal-body {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user