fix minus addorder.js and void and other origami
This commit is contained in:
@@ -855,12 +855,12 @@ $(function() {
|
||||
|
||||
$('#'+minus).on("click", function(){
|
||||
|
||||
var count = parseInt($('#'+id).val());
|
||||
var countEl = document.getElementById(id);
|
||||
// var count = parseInt($('#'+id).val());
|
||||
// var countEl = document.getElementById(id);
|
||||
|
||||
if (count > 1) {
|
||||
count--;
|
||||
countEl.value = count;
|
||||
$('#'+id).val(count);
|
||||
|
||||
if (id=="count") {
|
||||
price = $("#unit_price").text();
|
||||
|
||||
@@ -8,12 +8,19 @@ class Origami::VoidController < BaseOrigamiController
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
# update count for shift sale
|
||||
# if(sale.sale_status == "completed")
|
||||
if(sale.sale_status == "completed")
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.calculate(sale_id, "void")
|
||||
end
|
||||
# end
|
||||
else
|
||||
# void before sale payment complete
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.total_void = shift.total_void + sale.grand_total
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
@@ -95,4 +102,8 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def void_before_pay
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -174,7 +174,7 @@ class SalePayment < ApplicationRecord
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty,item.item_instance_code, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
end
|
||||
|
||||
self.payment_method = "foc"
|
||||
|
||||
@@ -54,7 +54,7 @@ class ShiftSale < ApplicationRecord
|
||||
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
||||
self.credit_sales = self.credit_sales.to_i + credit.to_f
|
||||
self.other_sales = self.other_sales.to_i + other_sales.to_f
|
||||
self.nett_sales = self.nett_sales + (saleobj.total_amount.to_f - self.total_discounts) #self.grand_total.to_i - self.commercial_taxes
|
||||
self.nett_sales = self.nett_sales + (saleobj.total_amount.to_f - saleobj.total_discount) #self.grand_total.to_i - self.commercial_taxes
|
||||
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
||||
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
||||
self.total_receipt = self.total_receipt + 1
|
||||
|
||||
@@ -263,13 +263,14 @@ class CloseCashierPdf < Prawn::Document
|
||||
end
|
||||
#end total amount by Account
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Sale :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||
# y_position = cursor
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
# text "Total Sale :", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
|
||||
@@ -359,95 +359,94 @@
|
||||
});
|
||||
|
||||
$( document ).ready(function() {
|
||||
// Disable click event cash to prevent
|
||||
$(".payment .cash-color").off('click');
|
||||
// Disable click event cash to prevent
|
||||
$(".payment .cash-color").off('click');
|
||||
|
||||
$('#credit_payment').click(function() {
|
||||
var sale_id = $('#sale_id').text();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#card_payment').click(function() {
|
||||
localStorage.setItem("cash",$('#cash').text() );
|
||||
var sale_id = $('#sale_id').text();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#pay').click(function() {
|
||||
$('#pay').text("Processing, Please wait!")
|
||||
|
||||
$( "#loading_wrapper" ).show();
|
||||
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops" , "Insufficient Amount!" , "error" );
|
||||
$( "#loading_wrapper" ).hide();
|
||||
}else{
|
||||
var sale_id = $('#sale_id').text();
|
||||
var item_row = $('.is_card');
|
||||
if (item_row.length < 1) {
|
||||
calculate_member_discount(sale_id);
|
||||
}
|
||||
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_cash_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
async: false,
|
||||
success:function(result){
|
||||
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
}
|
||||
$( "#loading_wrapper" ).hide();
|
||||
if($('#balance').text() < 0){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Changed amount ' + $('#balance').text() * (-1),
|
||||
}, function () {
|
||||
window.location.href = '/origami';
|
||||
});
|
||||
}else{
|
||||
$('#pay').text("Pay");
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Thank You !',
|
||||
}, function () {
|
||||
window.location.href = '/origami';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#credit_payment').click(function() {
|
||||
var sale_id = $('#sale_id').text();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Are you sure want to Void !',
|
||||
}, function () {
|
||||
var sale_id = $('#sale_id').text();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
$('#card_payment').click(function() {
|
||||
localStorage.setItem("cash",$('#cash').text() );
|
||||
var sale_id = $('#sale_id').text();
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
$('#pay').click(function() {
|
||||
$('#pay').text("Processing, Please wait!")
|
||||
|
||||
$( "#loading_wrapper" ).show();
|
||||
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops" , "Insufficient Amount!" , "error" );
|
||||
$( "#loading_wrapper" ).hide();
|
||||
}else{
|
||||
var sale_id = $('#sale_id').text();
|
||||
var item_row = $('.is_card');
|
||||
if (item_row.length < 1) {
|
||||
calculate_member_discount(sale_id);
|
||||
}
|
||||
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_cash_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
async: false,
|
||||
success:function(result){
|
||||
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
}
|
||||
$( "#loading_wrapper" ).hide();
|
||||
if($('#balance').text() < 0){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Changed amount ' + $('#balance').text() * (-1),
|
||||
}, function () {
|
||||
window.location.href = '/origami';
|
||||
});
|
||||
}else{
|
||||
$('#pay').text("Pay");
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Thank You !',
|
||||
}, function () {
|
||||
window.location.href = '/origami';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: 'Are you sure want to Void !',
|
||||
}, function () {
|
||||
var sale_id = $('#sale_id').text();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function update_balance(){
|
||||
var cash = $('#cash').text();
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace :clear do
|
||||
SaleOrder.delete_all
|
||||
SaleItem.delete_all
|
||||
Sale.delete_all
|
||||
SaleTax.delete_all
|
||||
SaleAudit.delete_all
|
||||
SalePayment.delete_all
|
||||
ShiftSale.delete_all
|
||||
|
||||
Reference in New Issue
Block a user