22july
This commit is contained in:
@ -47,7 +47,7 @@
|
||||
<!--COL START-->
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<?php fillComboWithValue("itemcategories_id", "Category", "itemcategories_id", "tbl_itemcategories", "title", "itemcategory_id", isset($item) ? $item->itemcategories_id : ''); ?>
|
||||
<?php fillComboWithValue("itemcategories_id", "Group", "itemcategories_id", "tbl_itemcategories", "title", "itemcategory_id", isset($item) ? $item->itemcategories_id : ''); ?>
|
||||
</div>
|
||||
</div>
|
||||
<!--COL END-->
|
||||
@ -121,7 +121,7 @@
|
||||
<th width="25%"><?php myLang('Name'); ?></th>
|
||||
<th width="10%"><?php myLang('Code'); ?></th>
|
||||
<th width="10%"><?php myLang('Units'); ?></th>
|
||||
<th width="10%"><?php myLang('Category'); ?></th>
|
||||
<th width="10%"><?php myLang('Group'); ?></th>
|
||||
<th width="10%" class="text-right"><?php myLang('Qty'); ?></th>
|
||||
<th width="10%" class="text-right"><?php myLang('Rate'); ?></th>
|
||||
<th width="10%" class="text-right"><?php myLang('Total'); ?></th>
|
||||
|
@ -324,11 +324,14 @@
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var counter = $('.purchase-detail').length;
|
||||
// Clone purchase detail div
|
||||
var purchaseDetailClone = $(".purchase-detail").clone().show();
|
||||
// Add Purchase Detail
|
||||
$(document).on("click", ".addPurchaseDetail", function() {
|
||||
counter+=1;
|
||||
var newPurchaseDetail = purchaseDetailClone.clone();
|
||||
newPurchaseDetail.find('.bbsn').text(counter);
|
||||
$(".purchase-details-section").append(newPurchaseDetail);
|
||||
});
|
||||
|
||||
@ -361,6 +364,7 @@
|
||||
// Remove Purchase Detail
|
||||
$(document).on("click", ".remove-purchase-detail", function() {
|
||||
$(this).closest(".purchase-detail").remove();
|
||||
updateSerialNumbers();
|
||||
calculateTotals();
|
||||
});
|
||||
// Calculate totals on change of rate or quantity
|
||||
@ -374,6 +378,17 @@
|
||||
calculateTotals();
|
||||
});
|
||||
|
||||
$(document).on("change", "input[name=discount]", function() {
|
||||
calculateRowTotal($(this).closest(".purchase-detail"));
|
||||
calculateTotals('amount');
|
||||
});
|
||||
|
||||
function updateSerialNumbers(){
|
||||
$('.purchase-detail').each(function(index){
|
||||
$(this).find('.bbsn').text(index + 1);
|
||||
})
|
||||
counter = $('.purchase-detail').length;
|
||||
}
|
||||
// Calculate row total
|
||||
function calculateRowTotal(row) {
|
||||
var quantity = parseFloat(row.find("input[name^='quantity']").val()) || 0;
|
||||
@ -382,20 +397,32 @@
|
||||
row.find("input[name^='total']").val(total.toFixed(2));
|
||||
}
|
||||
// Calculate totals
|
||||
function calculateTotals() {
|
||||
function calculateTotals(type='') {
|
||||
var subtotal = 0;
|
||||
$(".purchase-detail").each(function() {
|
||||
var total = parseFloat($(this).find("input[name^='total']").val()) || 0;
|
||||
subtotal += total;
|
||||
});
|
||||
var discountpercent = parseFloat($("input[name=discountpercentage]").val());
|
||||
var discountamount = subtotal * (discountpercent/100);
|
||||
|
||||
if(type=='amount'){
|
||||
alert("amount");
|
||||
discountamount = parseFloat($("input[name='discount']").val());
|
||||
discountpercent = (discountamount * 100) / subtotal;
|
||||
alert(discountamount);
|
||||
$("#discountpercentage").val(discountpercent.toFixed(2));
|
||||
}else{
|
||||
discountpercent = parseFloat($("input[name='discountpercentage']").val());
|
||||
discountamount = subtotal * (discountpercent/100);
|
||||
$("#discount").val(discountamount.toFixed(2));
|
||||
}
|
||||
// var discountpercent = parseFloat($("input[name=discountpercentage]").val());
|
||||
// var discountamount = subtotal * (discountpercent/100);
|
||||
var taxable = subtotal - discountamount;
|
||||
var tax = taxable * 0.13;
|
||||
var grandTotal = taxable + tax;
|
||||
|
||||
$("#subtotal").val(subtotal.toFixed(2));
|
||||
$("#discount").val(discountamount.toFixed(2));
|
||||
// $("#discount").val(discountamount.toFixed(2));
|
||||
$("#taxable").val(taxable.toFixed(2));
|
||||
$("#tax").val(tax.toFixed(2));
|
||||
$("#grand_total").val(grandTotal.toFixed(2));
|
||||
|
@ -45,7 +45,7 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>S.No.</th>
|
||||
<th width=50%>Items <span class="text-danger">*</span></th>
|
||||
<th class="text-center" width=5%>Qty <span class="text-danger">*</span></th>
|
||||
<th class="text-center" width=5%>Units</th>
|
||||
@ -56,7 +56,7 @@
|
||||
</thead>
|
||||
<tbody id="salesDetails">
|
||||
<tr class="sales-detail-duplicator">
|
||||
|
||||
<td class="text-center bbsn">1</td>
|
||||
<td> <select name="item_id[]" class="form-control select_item" required>
|
||||
<option value="">Select Item</option>
|
||||
<?php foreach ($items as $item) : ?>
|
||||
@ -78,7 +78,7 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3" rowspan="5">In words: </td>
|
||||
<td colspan="4" rowspan="5">In words: </td>
|
||||
<td class="text-right "><b>Total Amount</b></td>
|
||||
<td class="text-right"><b>
|
||||
<input type="text" class="form-control" name="subtotal" id="subtotal">
|
||||
@ -89,7 +89,7 @@
|
||||
<td class="text-right">
|
||||
<input class="form-control1" type="text" name="discountpercentage" id="discountpercentage" value="0" width="2%"> <b>% Discount</b>
|
||||
</td>
|
||||
<td class="text-right"><b> <input type="text" class="form-control" id="discount"></b></td>
|
||||
<td class="text-right"><b> <input type="text" class="form-control" name="discount" id="discount"></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -142,6 +142,7 @@
|
||||
$(document).on("click", ".remove-sales-detail", function() {
|
||||
if ($("#salesDetails tr").length > 1) {
|
||||
$(this).closest("tr").remove();
|
||||
updateSerialNumbers();
|
||||
calculateTotals();
|
||||
}
|
||||
|
||||
@ -156,6 +157,18 @@
|
||||
calculateTotals();
|
||||
});
|
||||
|
||||
$(document).on("change", "input[name=discount]", function() {
|
||||
calculateLineTotal($(this).closest("tr"));
|
||||
calculateTotals('amount');
|
||||
});
|
||||
|
||||
function updateSerialNumbers(){
|
||||
$('.purchase-detail').each(function(index){
|
||||
$(this).find('.bbsn').text(index + 1);
|
||||
})
|
||||
counter = $('.purchase-detail').length;
|
||||
}
|
||||
|
||||
function calculateLineTotal(row) {
|
||||
var quantity = parseFloat(row.find('input[name^="qty"]').val());
|
||||
var rate = parseFloat(row.find('input[name^="rate"]').val());
|
||||
@ -167,9 +180,12 @@
|
||||
|
||||
}
|
||||
$(document).ready(function() {
|
||||
var counter = $('.sales-detail-duplicator').length;
|
||||
var currentRow = $(".sales-detail-duplicator").clone().show();
|
||||
$(document).on("click", ".add-row", function() {
|
||||
counter+=1;
|
||||
var newRow = currentRow.clone();
|
||||
newRow.find('.bbsn').text(counter);
|
||||
$("#salesDetails").append(newRow);
|
||||
// newRow.find('.select2').select2();
|
||||
// calculateTotals();
|
||||
@ -213,7 +229,7 @@
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function calculateTotals() {
|
||||
function calculateTotals(type='') {
|
||||
var subtotal = 0;
|
||||
$(".sales-detail-duplicator").each(function() {
|
||||
var lineTotal = parseFloat($(this).find("input[name^='ltotal']").val());
|
||||
@ -221,14 +237,25 @@
|
||||
subtotal += lineTotal;
|
||||
}
|
||||
});
|
||||
var discountamount = 0;
|
||||
var discountpercent = 0;
|
||||
if(type=='amount'){
|
||||
alert("amount");
|
||||
discountamount = parseFloat($("input[name='discount']").val());
|
||||
discountpercent = (discountamount * 100) / subtotal;
|
||||
alert(discountamount);
|
||||
$("#discountpercentage").val(discountpercent.toFixed(2));
|
||||
}else{
|
||||
discountpercent = parseFloat($("input[name='discountpercentage']").val());
|
||||
discountamount = subtotal * (discountpercent/100);
|
||||
$("#discount").val(discountamount.toFixed(2));
|
||||
}
|
||||
|
||||
var discountpercent = parseFloat($("input[name=discountpercentage]").val());
|
||||
var discountamount = subtotal * (discountpercent/100);
|
||||
var taxable = subtotal - discountamount;
|
||||
var tax = taxable * 0.13;
|
||||
var grandTotal = taxable + tax;
|
||||
$('#subtotal').val(subtotal.toFixed(2));
|
||||
$("#discount").val(discountamount.toFixed(2));
|
||||
|
||||
$("#taxable").val(taxable.toFixed(2));
|
||||
$('#tax').val(tax.toFixed(2));
|
||||
$('#grandtotal').val(grandTotal.toFixed(2));
|
||||
|
Reference in New Issue
Block a user