Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into r-1804001-01

This commit is contained in:
Aung Myo
2018-04-19 10:18:45 +06:30
20 changed files with 127 additions and 62 deletions

View File

@@ -52,6 +52,7 @@ gem 'rubyzip', '= 1.0.0'
gem 'axlsx', '= 2.0.1'
gem 'axlsx_rails'
gem 'roo'
gem 'pdfjs_viewer-rails'
#Reporting gem
#gem 'compendium'
#gem "cancan"

View File

@@ -125,6 +125,7 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.1.0)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
@@ -168,6 +169,10 @@ GEM
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
pdf-core (0.7.0)
pdfjs_viewer-rails (0.2.0)
json (> 1.8.4)
rails (> 4.2.0)
sass-rails (~> 5.0)
pg (0.21.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
@@ -333,6 +338,7 @@ DEPENDENCIES
momentjs-rails
mysql2 (>= 0.3.18, < 0.5)
nested_form
pdfjs_viewer-rails
pg
prawn
prawn-table

Binary file not shown.

View File

@@ -1,7 +1,7 @@
class Api::ApiController < ActionController::API
include TokenVerification
before_action :lookup_domain
# before_action :lookup_domain
helper_method :current_token, :current_login_employee, :get_cashier
private

View File

@@ -13,12 +13,12 @@ module TokenVerification
authenticate_token || render_unauthorized
end
def authenticate_token
def authenticate_token
authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud")
from = request.subdomain.downcase + "." + request.domain.downcase
from = "local" #request.subdomain.downcase + "." + request.domain.downcase
aes = MyAesCrypt.new
return aes.checkKeyForAuth(from, token)
end

View File

@@ -169,6 +169,8 @@ class Origami::CustomersController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
end
@out = membership_data
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
end
end
end

View File

@@ -4,32 +4,32 @@ class Origami::DingaController < BaseOrigamiController
payment_method = params[:payment_method]
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no
@sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = @sale_data.receipt_no
@shop = Shop.first
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
# new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
# else
# new_total = sale_data.grand_total
# new_total = @sale_data.grand_total
# end
# @rounding_adj = new_total-sale_data.grand_total
@rounding_adj = sale_data.rounding_adjustment
# @rounding_adj = new_total-@sale_data.grand_total
@rounding_adj = @sale_data.rounding_adjustment
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
@sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "dinga"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@payment_prices = sale_data.grand_total - @payparcount -others
@payment_prices = @sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if @sale_data
if @sale_data.customer_id
customer_data= Customer.find_by_customer_id(@sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
@@ -73,6 +73,7 @@ def create
cash = params[:payment_amount]
sale_id = params[:sale_id]
transaction_ref = params[:transaction_ref]
account_no = params[:account_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop.first
@@ -85,7 +86,7 @@ def create
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga",transaction_ref)
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga",account_no)
if status == true
@out = true, "Success!"
else

View File

@@ -73,6 +73,8 @@ def create
cash = params[:payment_amount]
sale_id = params[:sale_id]
transaction_ref = params[:transaction_ref]
account_no = params[:account_no]
puts params.to_json
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop.first
@@ -86,7 +88,7 @@ def create
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal",transaction_ref)
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal",account_no)
if status == true
@out = true, "Success!"
else

View File

@@ -167,8 +167,9 @@ class Settings::MenusController < ApplicationController
# end
end
p.serialize("tmp/menus/" + menu.name + ".xlsx")
render :json => {status: true}
file_path = "public/menus/" + menu.name + ".xlsx"
p.serialize(file_path)
render :json => { status: true, path: file_path }
end
def import

View File

@@ -160,7 +160,7 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", account_id: account_id, is_sub_item: 0, is_available: 1, created_by: created_by)
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", is_sub_item: 0, is_available: 1, created_by: created_by)
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."
end

View File

@@ -197,13 +197,14 @@ class SalePayment < ApplicationRecord
def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
sale_data = Sale.find_by_sale_id(sale_id)
customer_data = Customer.find_by_customer_id(sale_data.customer_id)
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
sale_data = Sale.find_by_sale_id(sale_id)
if sale_data
others = 0
@@ -211,14 +212,27 @@ class SalePayment < ApplicationRecord
others = others + sale_payment.payment_amount
end
payment_prices = sale_data.grand_total - others
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => { membership_id:membership_id,
if membership_id.to_i <= 0
membership_id = customer_data.membership_id
params = { membership_id:membership_id,
amount:received_amount,
receipt_no:sale_data.receipt_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json,
auth_token:auth_token}.to_json
else
params = { account_no:membership_id,
amount:received_amount,
receipt_no:sale_data.receipt_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json
end
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
@@ -242,7 +256,7 @@ class SalePayment < ApplicationRecord
response =false;
end
Rails.logger.debug "Payment response"
Rails.logger.debug "Create Payment response"
Rails.logger.debug response.to_json
return response;
@@ -390,9 +404,13 @@ class SalePayment < ApplicationRecord
payment_status = false
#Next time - validate if the vochure number is valid - within
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
# customer_data = Customer.find_by_customer_id(self.sale.customer_id)
account_no = self.payment_reference
# if account_no.to_i <= 0
# account_no = customer_data.membership_id
# end
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
@@ -433,9 +451,16 @@ class SalePayment < ApplicationRecord
payment_status = false
#Next time - validate if the vochure number is valid - within
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
# customer_data = Customer.find_by_customer_id(self.sale.customer_id)
account_no = self.payment_reference
# if account_no == 0
# account_no = customer_data.customer_id
# end
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
remark = "#{membership_data} Dinga Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "

View File

@@ -46,6 +46,8 @@
</div>
</div>
</div>
<p class="hidden" name="sale_id" id="sale_id" ><%=@sale_id %></p>
<p class="hidden" name="receipt_no" id="receipt_no" ><%=@sale_data.receipt_no %></p>
<!-- <% if @payparcount > 0 %>
<p class="">Last time rebate amount is <%= @payparcount %></p>
<% end %>
@@ -203,7 +205,7 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_dinga_path%>",
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:""},
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
success: function(result){
if(result.status == true){
swal({
@@ -239,6 +241,7 @@
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").text() || 0;
var customer_mamber_card_no = 0;
$("#is_paymemberModal").hide();
@@ -247,7 +250,6 @@
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
@@ -255,6 +257,7 @@
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
console.log(data)
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount));
@@ -262,8 +265,9 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_dinga_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no :customer_mamber_card_no},
success: function(result){
console.log(result)
if(result.status == true){
swal({
title: "Information!",
@@ -273,7 +277,7 @@
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}else{
@@ -291,14 +295,14 @@
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
});
}
}
});
}
},100);
},100);
});
// Read NFC card no from java
@@ -321,9 +325,10 @@
var customer_name = '';
var membership_id = '';
var membership_type = '';
var receipt_no = $("#receipt_no").text() || 0;
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/send_account" ,
@@ -337,8 +342,9 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){
if(result.status == true){
swal({
title: "Information!",

View File

@@ -290,7 +290,7 @@
</div>
<p id="ref_no" class="hidden"></p>
<p id="callback_url" class="hidden"></p>
<p id="order_id"></p>
<p id="order_id" class="hidden"></p>
<p id="status" class="hidden"></p>
<script type="text/javascript">
jQuery(function(){

View File

@@ -14,6 +14,8 @@
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<input type="hidden" name="receipt_no" id="receipt_no" value="<%= @receipt_no%>">
<p class="hidden" name="sale_id" id="sale_id" ><%=@sale_id %></p>
<p class="hidden" name="membership_id" id="membership_id" ><%=@membership_id %></p>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="">You can pay up to </label>
@@ -204,7 +206,7 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:""},
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
success: function(result){
if(result.status == true){
swal({
@@ -237,6 +239,7 @@
var cardNo = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#used_amount").text());
@@ -246,8 +249,10 @@
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/send_account" ,
@@ -261,7 +266,7 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
@@ -296,8 +301,10 @@
}
});
}else{
swal("Opp","Please Check Member","warning")
}
},100);
},100);
});
// Read NFC card no from java
@@ -321,6 +328,7 @@
var payment_amount = parseFloat($("#used_amount").text());
setTimeout(function(){
code=getQRCode();
alert(code)
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
@@ -335,8 +343,9 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){
alert(result)
if(result.status == true){
swal({
title: "Information!",

View File

@@ -168,15 +168,15 @@
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id=""><%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id=""><%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<% end %>
</div>
<div class="card-block">
@@ -269,12 +269,11 @@
<div class="col-md-4" id="paymalcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- DINGA -->
<div class="row <%= @dingacount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">DINGA</div>
<% if @paymalcount != 0.0 %>
<% if @dingacount != 0.0 %>
<div class="col-md-4 master is_card" id="dingacount"><%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="dingacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
@@ -633,6 +632,8 @@ var customer_name = "<%= @customer.name %>";
if (credit <= 0) {
calculate_member_discount(sale_id);
}
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
@@ -653,13 +654,14 @@ var customer_name = "<%= @customer.name %>";
var msg = '';
}
$("#loading_wrapper" ).hide();
$("#loading_wrapper" ).hide();
//PDF lightbox data
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", result.filename.substring(6));
$("#receipt_pdf").attr("src", pdfPath);
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
$("#changed_amount").text("");

View File

@@ -115,7 +115,8 @@
url: "/settings/menus/" + menu_id + "/export",
success: function(result){
if(result.status){
swal("Success", "Export Success...", "success");
location.href = result.path.substring(6);
// swal("Success", "Export Success...", "success");
}
}
});

View File

@@ -6,6 +6,8 @@ scope "(:locale)", locale: /en|mm/ do
root 'home#index'
mount Sidekiq::Web => '/kiq'
mount PdfjsViewer::Rails::Engine => "/pdfjs", as: 'pdfjs'
# Action Cable Creation
# if ENV["SERVER_MODE"] != "cloud"
mount ActionCable.server => "/cable"

View File

@@ -3,8 +3,15 @@
{
"lookup": "local",
"value": {
"key": "999d675168d813d5e1c7",
"iv": "999d675168d813d5e1c7"
"key": "999d675168d813d5e1c7",
"iv": "999d675168d813d5e1c7"
}
},
{
"lookup": "demo10.pos-myanmar.com",
"value": {
"key": "634W2ioj6QA88vafKamHBRu5aKX/BLIPdTWuuXGFBsA=\n",
"iv": "QqpO/h7o60dYTbNETRbZ4g==\n"
}
}
]

BIN
public/menus/Main Menu.xlsx Normal file

Binary file not shown.

Binary file not shown.