check js func: and card balance amount for Paymal payment

This commit is contained in:
phyusin
2018-10-04 16:31:19 +06:30
parent 497458371b
commit b4aa1c600f
11 changed files with 181 additions and 88 deletions

View File

@@ -257,6 +257,10 @@ For TaxProfiles On/Off
For Add Kitchen Role For Add Kitchen Role
1) settings/lookups => {type:employee_roles, name:Kitchen, value:kitchen} 1) settings/lookups => {type:employee_roles, name:Kitchen, value:kitchen}
For Food Court Settings On/Off
** '0' means can not use food court and '1' means can use food court **
=> settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' }
* ToDo list * ToDo list
1. Migration 1. Migration

View File

@@ -91,7 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
@@ -234,6 +234,9 @@ class Origami::PaymentsController < BaseOrigamiController
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id}) card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end end
end end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -243,7 +246,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(sale_items) other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
@@ -524,6 +527,10 @@ class Origami::PaymentsController < BaseOrigamiController
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id}) card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end end
end end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -533,7 +540,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
result = { result = {
:status => true, :status => true,
@@ -619,7 +626,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil)
result = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,

View File

@@ -126,7 +126,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -107,7 +107,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Bill Receipt Print #Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no) def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no) pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
else else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end end
end end
end end

View File

@@ -119,8 +119,36 @@ class SaleAudit < ApplicationRecord
end end
private def self.getCardBalanceAmount(sale_id)
def generate_custom_id card_balance_amount = 0
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") sale_audits = SaleAudit.where("sale_id='#{sale_id}' AND action='PAYMAL'")
if !sale_audits.nil?
sale_audits.each do |sale_audit|
if sale_audit.remark.split('}')[0]
if self.valid_json('['+ sale_audit.remark.split('}')[0] + '}]')
remark = JSON.parse(('['+ sale_audit.remark.split('}')[0] + '}]'))
if remark[0]
if remark[0]["status"]
card_balance_amount = remark[0]["card_balance_amount"]
end
end
end
end
end
end
return card_balance_amount
end end
def self.valid_json(json)
JSON.parse(json)
return true
rescue JSON::ParserError => e
return false
end
private
def generate_custom_id
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
end
end end

View File

@@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -72,7 +72,12 @@ class ReceiptBillA5Pdf < Prawn::Document
card_sale_data(card_data) card_sale_data(card_data)
end end
#end card sale trans data #end card sale trans data
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end end
@@ -707,6 +712,23 @@ class ReceiptBillA5Pdf < Prawn::Document
end end
end end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
end
end
#check ReceiptBillAltName included #check ReceiptBillAltName included
def show_alt_name def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -3,7 +3,7 @@ class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -73,6 +73,11 @@ class ReceiptBillPdf < Prawn::Document
card_sale_data(card_data) card_sale_data(card_data)
end end
#end card sale trans data #end card sale trans data
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
@@ -509,9 +514,9 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Total Balance", :size => self.item_font_size,:align => :left text "Total Balance", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end end
end end
end end
@@ -707,6 +712,23 @@ class ReceiptBillPdf < Prawn::Document
end end
end end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
end
end
#check ReceiptBillAltName included #check ReceiptBillAltName included
def show_alt_name def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -201,47 +201,52 @@
} }
}); });
$("#dinga_payment").click(function(){ $("#dinga_payment").on('click', function(){
valid_amount = $("#valid_amount").val(); valid_amount = $("#valid_amount").val();
sale_id = $("#valid_amount").attr('data-value'); sale_id = $("#valid_amount").attr('data-value');
membership_id = $("#valid_amount").attr('data-member-value'); membership_id = $("#valid_amount").attr('data-member-value');
payment_amount = parseFloat($("#used_amount").text()); payment_amount = parseFloat($("#used_amount").text());
if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){ if(payment_amount > 0){
if(payment_amount<=0 ){ if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){
swal ( "Oops" , "Please type valid amount!" , "warning" ); if(payment_amount<=0 ){
}else if(valid_amount< payment_amount){ swal ( "Oops" , "Please type valid amount!" , "warning" );
swal ( "Oops" , "Insufficient Amount!" , "warning" ); }else if(valid_amount< payment_amount){
}else{ swal ( "Oops" , "Insufficient Amount!" , "warning" );
if(payment_amount <= "<%= @payment_prices %>"){ }else{
$(this).off("click"); if(payment_amount <= "<%= @payment_prices %>"){
$.ajax({ $(this).off("click");
type: "POST", $.ajax({
url: "<%=origami_payment_dinga_path%>", type: "POST",
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0}, url: "<%=origami_payment_dinga_path%>",
success: function(result){ data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
if(result.status == true){ success: function(result){
swal({ if(result.status == true){
title: "Information!", swal({
text: result.message, title: "Information!",
html: true, text: result.message,
closeOnConfirm: false, html: true,
closeOnCancel: false, closeOnConfirm: false,
allowOutsideClick: false closeOnCancel: false,
}, function () { allowOutsideClick: false
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment" }, function () {
}); window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"
});
}else{ }else{
swal ( "Information" , result.message); swal ( "Information" , result.message);
}
} }
} })
}) }else {
}else { swal ( "Oops" , "Payment Amount is over!" , "warning" );
swal ( "Oops" , "Payment Amount is over!" , "warning" ); }
} }
}else{
$("#is_paymemberModal").show();
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false});
} }
}else{ }else{
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false}); swal ( "Oops" , "Amount should be greater than 0!" , "warning" );
} }
}); });
@@ -273,7 +278,7 @@
console.log(data) console.log(data)
if (data.status == true) { if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount)); $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -350,7 +355,7 @@
success: function(data) { success: function(data) {
if (data.status == true) { if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount)); $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",

View File

@@ -197,47 +197,52 @@
} }
}); });
$("#paymal_payment").click(function(){ $("#paymal_payment").on('click',function(){
valid_amount = $("#valid_amount").val(); valid_amount = $("#valid_amount").val();
sale_id = $("#valid_amount").attr('data-value'); sale_id = $("#valid_amount").attr('data-value');
membership_id = $("#valid_amount").attr('data-member-value'); membership_id = $("#valid_amount").attr('data-member-value');
payment_amount = parseFloat($("#used_amount").text()); payment_amount = parseFloat($("#used_amount").text());
if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){ if(payment_amount > 0){
if(payment_amount<=0 ){ if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){
swal ( "Oops" , "Please type valid amount!" , "warning" ); if(payment_amount<=0 ){
}else if(valid_amount< payment_amount){ swal ( "Oops" , "Please type valid amount!" , "warning" );
swal ( "Oops" , "Insufficient Amount!" , "warning" ); }else if(valid_amount< payment_amount){
}else{ swal ( "Oops" , "Insufficient Amount!" , "warning" );
if(payment_amount <= "<%= @payment_prices %>"){ }else{
$(this).off("click"); if(payment_amount <= "<%= @payment_prices %>"){
$.ajax({ $(this).off("click");
type: "POST", $.ajax({
url: "<%=origami_payment_paymal_path%>", type: "POST",
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0}, url: "<%=origami_payment_paymal_path%>",
success: function(result){ data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
if(result.status == true){ success: function(result){
swal({ if(result.status == true){
title: "Information!", swal({
text: result.message, title: "Information!",
html: true, text: result.message,
closeOnConfirm: false, html: true,
closeOnCancel: false, closeOnConfirm: false,
allowOutsideClick: false closeOnCancel: false,
}, function () { allowOutsideClick: false
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment" }, function () {
}); window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"
});
}else{ }else{
swal ( "Information" , result.message); swal ( "Information" , result.message);
}
} }
} })
}) }else {
}else { swal ( "Oops" , "Payment Amount is over!" , "warning" );
swal ( "Oops" , "Payment Amount is over!" , "warning" ); }
} }
}else{
$("#is_paymemberModal").show();
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false});
} }
}else{ }else{
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false}); swal ( "Oops" , "Amount should be greater than 0!" , "warning" );
} }
}); });
@@ -268,7 +273,7 @@
success: function(data) { success: function(data) {
if (data.status == true) { if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount)); $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -344,7 +349,7 @@
success: function(data) { success: function(data) {
if (data.status == true) { if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount)); $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",