diff --git a/app/models/customer.rb b/app/models/customer.rb index 4db65146..d69220f3 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -18,36 +18,39 @@ class Customer < ApplicationRecord paginates_per 50 def self.get_member_account(customer) - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + membership = MembershipSetting.active.find_by_membership_type("paypar_url") + memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account") merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s # urltest =self.url_exist?(url) + if !membership.nil? && !memberaction.nil? + begin + response = HTTParty.get(url, :body => { + membership_id: customer.membership_id, + merchant_uid:merchant_uid, + type: "summary", + auth_token:auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, + :timeout => 10) + rescue HTTParty::Error + response = {status: false, message: "Server Error"} + + rescue Net::OpenTimeout + response = { status: false , message: "Server Time out"} - begin - response = HTTParty.get(url, :body => { - membership_id: customer.membership_id, - merchant_uid:merchant_uid, - type: "summary", - auth_token:auth_token - }.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=3' - }, - :timeout => 10) - rescue HTTParty::Error - response = {status: false, message: "Server Error"} - - rescue Net::OpenTimeout - response = { status: false , message: "Server Time out"} + rescue OpenURI::HTTPError + response = { status: false, message: "Can't connect server"} - rescue OpenURI::HTTPError - response = { status: false, message: "Can't connect server"} - - rescue SocketError - response = { status: false, message: "Can't connect server"} + rescue SocketError + response = { status: false, message: "Can't connect server"} + end + else + response = {status: false, message: "There is no membership setting."} end Rails.logger.debug "--------Get Member Account response -------" Rails.logger.debug response.to_json diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index c69e3626..c44220b1 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -180,10 +180,10 @@ class SaleItem < ApplicationRecord def self.get_all_sale_items(sale_id) sale_items = SaleItem.select("sale_id,product_code,item_instance_code, product_name,product_alt_name,account_id,status,remark, - (CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status = 'foc') OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty, + (CASE WHEN (qty > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty, unit_price, taxable_price, - (CASE WHEN (price > 0 AND remark IS NULL) OR (qty < 0 AND status = 'foc') OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price, + (CASE WHEN (price > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price, is_taxable") .where("sale_id = ?",sale_id) .order("product_name asc") diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index f093b6bc..fd446131 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -66,7 +66,7 @@ class OrderSummaryPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left end move_down 5 diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index cde5e3d0..29d93ca7 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -721,7 +721,6 @@ $(document).ready(function(){ var sale_id = $('#sale_id').text(); window.location.replace('/origami/sale/'+sale_id+'/cashier/payment'); } - /* replace url type*/ /* start check first bill or not*/ var member_id = $('#membership_id').text(); @@ -1125,6 +1124,8 @@ $(document).ready(function(){ <% else %> $('#balance').text(parseFloat(result)); <% end %> + + show_hide_btn($('#balance').text()); } function customer_display_view(data,status) { @@ -1831,4 +1832,15 @@ $(document).ready(function(){ } },100); }); + + function show_hide_btn(balance) { + // show discount when balance is greater than 0 + // if(parseFloat(balance) > 0){ + // $("#discount").show(); + // $("#edit").show(); + // }else{ + // $("#discount").hide(); + // $("#edit").hide(); + // } + }