fix minus addorder.js and void and other origami
This commit is contained in:
@@ -855,12 +855,12 @@ $(function() {
|
|||||||
|
|
||||||
$('#'+minus).on("click", function(){
|
$('#'+minus).on("click", function(){
|
||||||
|
|
||||||
var count = parseInt($('#'+id).val());
|
// var count = parseInt($('#'+id).val());
|
||||||
var countEl = document.getElementById(id);
|
// var countEl = document.getElementById(id);
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
count--;
|
count--;
|
||||||
countEl.value = count;
|
$('#'+id).val(count);
|
||||||
|
|
||||||
if (id=="count") {
|
if (id=="count") {
|
||||||
price = $("#unit_price").text();
|
price = $("#unit_price").text();
|
||||||
|
|||||||
@@ -8,12 +8,19 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
sale = Sale.find_by_sale_id(sale_id)
|
sale = Sale.find_by_sale_id(sale_id)
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
# if(sale.sale_status == "completed")
|
if(sale.sale_status == "completed")
|
||||||
if sale.shift_sale_id != nil
|
if sale.shift_sale_id != nil
|
||||||
shift = ShiftSale.find(sale.shift_sale_id)
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
shift.calculate(sale_id, "void")
|
shift.calculate(sale_id, "void")
|
||||||
end
|
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.payment_status = 'void'
|
||||||
sale.sale_status = 'void'
|
sale.sale_status = 'void'
|
||||||
@@ -95,4 +102,8 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def void_before_pay
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -174,7 +174,7 @@ class SalePayment < ApplicationRecord
|
|||||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||||
|
|
||||||
sale_items.each do|item|
|
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
|
end
|
||||||
|
|
||||||
self.payment_method = "foc"
|
self.payment_method = "foc"
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ShiftSale < ApplicationRecord
|
|||||||
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
||||||
self.credit_sales = self.credit_sales.to_i + credit.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.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.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
||||||
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
||||||
self.total_receipt = self.total_receipt + 1
|
self.total_receipt = self.total_receipt + 1
|
||||||
|
|||||||
@@ -263,13 +263,14 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
#end total amount by Account
|
#end total amount by Account
|
||||||
|
|
||||||
y_position = cursor
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
# y_position = cursor
|
||||||
text "Total Sale :", :size => self.item_font_size, :align => :right
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
end
|
# text "Total Sale :", :size => self.item_font_size, :align => :right
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
# end
|
||||||
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
end
|
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|||||||
@@ -359,95 +359,94 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
// Disable click event cash to prevent
|
// Disable click event cash to prevent
|
||||||
$(".payment .cash-color").off('click');
|
$(".payment .cash-color").off('click');
|
||||||
|
|
||||||
$('#credit_payment').click(function() {
|
$('#credit_payment').click(function() {
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
|
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
|
||||||
return false;
|
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';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#void').on('click',function () {
|
$('#card_payment').click(function() {
|
||||||
swal({
|
localStorage.setItem("cash",$('#cash').text() );
|
||||||
title: "Information!",
|
var sale_id = $('#sale_id').text();
|
||||||
text: 'Are you sure want to Void !',
|
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
|
||||||
}, function () {
|
return false;
|
||||||
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/';
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
$('#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(){
|
function update_balance(){
|
||||||
var cash = $('#cash').text();
|
var cash = $('#cash').text();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace :clear do
|
|||||||
SaleOrder.delete_all
|
SaleOrder.delete_all
|
||||||
SaleItem.delete_all
|
SaleItem.delete_all
|
||||||
Sale.delete_all
|
Sale.delete_all
|
||||||
|
SaleTax.delete_all
|
||||||
SaleAudit.delete_all
|
SaleAudit.delete_all
|
||||||
SalePayment.delete_all
|
SalePayment.delete_all
|
||||||
ShiftSale.delete_all
|
ShiftSale.delete_all
|
||||||
|
|||||||
Reference in New Issue
Block a user