merge with master

This commit is contained in:
Yan
2018-01-09 16:40:45 +06:30
91 changed files with 2666 additions and 744 deletions

31
Capfile Normal file
View File

@@ -0,0 +1,31 @@
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require "capistrano/rvm"
require "capistrano/rbenv"
# require "capistrano/chruby"
require "capistrano/bundler"
require "capistrano/rails"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
# require "capistrano/passenger"
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }

16
Gemfile
View File

@@ -1,5 +1,5 @@
source 'https://rubygems.org'
ruby '2.4.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
@@ -43,7 +43,7 @@ gem 'carrierwave', '~> 1.0'
gem 'mini_magick'
#Report and Printing gems
gem 'cups', '~> 0.0.7'
gem 'cups'
gem 'prawn'
gem 'prawn-table'
gem 'spreadsheet'
@@ -89,10 +89,10 @@ gem 'cancancan', '~> 1.10'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
#group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
# gem 'byebug', platform: :mri
#end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
@@ -103,6 +103,10 @@ group :development do
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'rspec-rails', '~> 3.5'
gem 'schema_to_scaffold'
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rbenv', github: "capistrano/rbenv"
end
group :test do
@@ -122,4 +126,4 @@ gem 'momentjs-rails' # for date-range selector
# gem 'bootstrap-datepicker-rails' # date picker
# gem 'jquery-datetimepicker-rails'
# gem 'select2-rails' # for multi-select and auto-complete select box
gem "chartkick" #chart lib
gem "chartkick" #chart lib

View File

@@ -1,3 +1,11 @@
GIT
remote: https://github.com/capistrano/rbenv.git
revision: c029e4128e4a8f25adda35795f5729bd4f62e51f
specs:
capistrano-rbenv (2.1.3)
capistrano (~> 3.1)
sshkit (~> 1.3)
GEM
remote: https://rubygems.org/
specs:
@@ -39,12 +47,24 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
aescrypt (1.0.0)
airbrussh (1.3.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (8.0.0)
bcrypt (3.1.11)
bindex (0.5.0)
builder (3.2.3)
byebug (9.1.0)
cancancan (1.17.0)
capistrano (3.10.1)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.3.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.3.1)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
carrierwave (1.2.1)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
@@ -61,7 +81,7 @@ GEM
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
crass (1.0.2)
cups (0.0.7)
cups (0.1.10)
database_cleaner (1.6.2)
diff-lcs (1.3)
erubi (1.7.0)
@@ -128,6 +148,9 @@ GEM
multi_xml (0.6.0)
mysql2 (0.4.9)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
@@ -228,6 +251,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.15.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
tether-rails (1.4.0)
rails (>= 3.1)
thor (0.20.0)
@@ -260,12 +286,15 @@ PLATFORMS
DEPENDENCIES
aescrypt
bcrypt (~> 3.1.7)
byebug
cancancan (~> 1.10)
capistrano
capistrano-bundler
capistrano-rails
capistrano-rbenv!
carrierwave (~> 1.0)
chartkick
coffee-rails (~> 4.2)
cups (~> 0.0.7)
cups
database_cleaner
factory_girl_rails (~> 4.0)
faker
@@ -306,5 +335,8 @@ DEPENDENCIES
web-console (>= 3.3.0)
whenever
RUBY VERSION
ruby 2.4.1p111
BUNDLED WITH
1.16.0
1.16.1

View File

@@ -31,7 +31,23 @@ ruby 2.4.1p111
Campaign Id => {"campaign_type_id": 1}
java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
Person and Extra Time
category_code = SPL... //for menu categories
Extra Time
instance_code = Extim30, Extim60 //for morning menu
instance_code = Extie30, Extie60 //for evening menu
Order Item & Order Summary Slim
*** change OrderItemPdf to OrderItemSlimPdf and OrderSummaryPdf to OrderSummarySlimPdf
1) settings/print_settings
2) app/controllers/oqs/edit_controller.rb
3) app/controllers/oqs/print_controller.rb
4) app/models/order_queue_station.rb
5) app/models/printer/order_queue_printer.rb
6) app/models/printer/receipt_printer.rb
* ToDo list

View File

@@ -61,7 +61,7 @@ $(document).on('turbolinks:load', function() {
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
var options = "";
}else{
var options = data.options;
var options = data[field]["options"];
}
var date = new Date(data[field]["created_at"]);
@@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() {
+'<span class="order-qty"> [x'+ data[field]["qty"] +'] </span>'
+'</p>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '

View File

@@ -206,6 +206,7 @@ $(function() {
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
value = item_sets[field]["instances"];
$(value).each(function(i){
$.ajax({
type: "GET",
@@ -241,6 +242,11 @@ $(function() {
});
}
$('.set-item').attr('data-code',instances[0]['code']);
$('.set-item').attr('data-name',instances[0]['name']);
$('.set-item').attr('data-price',instances[0]['price']);
$('.set-item').attr('data-options','[]');
$('#set_change_qty').val(1);
$('#set_item_instances').text(instances);
$('#set_name').text(data.attr('data-name'));
@@ -313,6 +319,8 @@ $(function() {
item_name = $('#set_name').text();
min_qty = $(this).data('min-qty');
default_instance = $('.set-item');
var items = $('.selected-instance');
if (items.length >= min_qty) {
@@ -342,6 +350,29 @@ $(function() {
$(".summary-items tbody").append(row);
rowCount = rowCount + 1;
});
var rowCount = $('.summary-items tbody tr').length+1;
option_arr = []
code = $('.set-item').attr('data-code');
name = $('.set-item').attr('data-name');
price = $('.set-item').attr('data-price');
option = $('.set-item').attr('data-options');
total = qty * price ;
option_arr.push(option);
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option_arr+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
+'</td>'
+'</tr>';
$(".summary-items tbody").append(row);
calculate_sub_total();
$(".sx_item_set_detailModal").css({ 'display': "none" });
}else{
@@ -526,7 +557,7 @@ $(function() {
}
});
if (active) {
$(this).revoveClass('selected-option');
$(this).removeClass('selected-option');
}else{
$(this).addClass('selected-option');
}

View File

@@ -5,10 +5,12 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
disconnected: function() {},
received: function(data) {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
received: function(data) {
if($('.table_'+data.table.id).hasClass('green')){
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
}
$('.new_text_'+data.table.id).removeClass('hide');
}
});

View File

@@ -6,21 +6,21 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
disconnected: function() {},
received: function(data) {
$.each(data.table,function(key,value){
if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue');
$('.table_'+value.table_id).addClass('orange');
}
else if($('.table_'+value.table_id).hasClass('red')){
$('.table_'+value.table_id).removeClass('red');
$('.table_'+value.table_id).addClass('orange');
}
else {
$('.table_'+value.table_id).removeClass('green');
$('.table_'+value.table_id).addClass('orange');
}
$('.new_text_'+value.table_id).removeClass('hide');
});
$.each(data.table,function(key,value){
if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue');
$('.table_'+value.table_id).addClass('orange');
}
else if($('.table_'+value.table_id).hasClass('red')){
$('.table_'+value.table_id).removeClass('red');
$('.table_'+value.table_id).addClass('orange');
}
else {
$('.table_'+value.table_id).removeClass('green');
$('.table_'+value.table_id).addClass('orange');
}
$('.new_text_'+value.table_id).removeClass('hide');
});
}
});

View File

@@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
var options = "";
}else{
var options = items.options;
var options = items[field]["options"];
}
//for count
test = document.getElementsByClassName("oqs_count");
@@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
+'</p>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '

View File

@@ -143,3 +143,55 @@ $(document).on('turbolinks:load', function() {
return false;
});
});
/* start check first bill or not funs: */
function checkReceiptNoInFirstBillData(receipt_no,payment) {
// localStorage.removeItem('receipt_lists');
var status = false;
if((receipt_no!=undefined) && (receipt_no!="")){
if(localStorage.hasOwnProperty("receipt_lists")===true){
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
if (payment) {
var json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
}else{
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
}
if((arr_data.length) > (json_data.length)){
status = true;
}
}
}
if (payment) {
return json_data[0]["payment"];
}else{
return status;
}
}
function createReceiptNoInFirstBillData(receipt_no,payment) {
var arr_data = [];
var json_data = [];
if(localStorage.hasOwnProperty("receipt_lists") === true){
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
if (payment) {
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
jdata.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
}
}
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
arr_data.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
}
}
function deleteReceiptNoInFirstBillData(receipt_no) {
if(localStorage.hasOwnProperty("receipt_lists") ===true ){
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
}
}
/* end check first bill or not funs: */

View File

@@ -6,6 +6,13 @@ class Api::CallWaitersController < ActionController::API
@time = params[:time]
@table = DiningFacility.find(@table_id)
CallWaiterJob.perform_later(@table,@time)
# get printer info
@shop = Shop::ShopDetail
unique_code = "CallWaiterPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_call_waiter(print_settings,@table,@time,@shop)
end

View File

@@ -11,7 +11,19 @@ class Api::CheckInProcessController < Api::ApiController
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time }
extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
alert_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
alert_time_min = (lookup_checkout_time[0][1]).to_i
else
alert_time_min = 15
end
end
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
else
render :json => { :status => false, :error_message => "No current booking!" }
end

View File

@@ -49,7 +49,25 @@ class Api::OrdersController < Api::ApiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
#for extratime
is_extra_time = false
extra_time = ''
params[:order_items].each { |i|
if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30'
is_extra_time = true
if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30'
t = Time.now
time = 30*60*i["quantity"].to_i
extra_time = Time.at(time)
else
t = Time.now
time = 60*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
}
#end extra time
# begin
@order = Order.new
@order.source = params[:order_source]
@@ -61,6 +79,9 @@ class Api::OrdersController < Api::ApiController
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if !params["booking_id"].nil?
# check booking id is already completed.

View File

@@ -36,21 +36,25 @@ class ApplicationController < ActionController::Base
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
else
# check for license file
if check_license
current_license(ENV["SX_PROVISION_URL"])
end
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
end
end
def current_license(url)
def current_license(url)
@license = License.new(url)
if (@license.detail_with_local_file() == true)
puts "RUN SAY BYAR"
flag = @license.detail_with_local_file()
if (flag == 0)
flash[:notice] = 'Expired or No License!'
elsif (flag == 2)
flash[:notice] = 'Expiring! Please, License extend...'
else
return nil
puts "RUN SAY BYAR"
end
end
@@ -107,9 +111,8 @@ class ApplicationController < ActionController::Base
def check_license
if License.check_license_file
return true
else
redirect_to activate_path
end
return false
end
end

View File

@@ -1,4 +1,5 @@
class BaseController < ActionController::Base
layout "installation"
protect_from_forgery with: :exception
end

View File

@@ -37,6 +37,8 @@ class Crm::CustomersController < BaseCrmController
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@membership_types = Lookup.collection_of("member_group_type")
@taxes = TaxProfile.all.order("order_by asc")
@filter = filter

View File

@@ -3,7 +3,8 @@ class HomeController < ApplicationController
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
def index
@employees = Employee.all_emp_except_waiter.order("name asc")
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.order("name asc")
@login_form = LoginForm.new()
render "layouts/login_dashboard", layout: false
end
@@ -45,7 +46,7 @@ class HomeController < ApplicationController
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "supervisor"
elsif @employee.role == "supervisor" || @employee.role == "waiter"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
elsif @employee.role == "account"

View File

@@ -1,6 +1,6 @@
class InstallController < BaseController
skip_before_action :verify_authenticity_token
before_action :check_license
# before_action :check_license
def index
end
@@ -17,20 +17,20 @@ class InstallController < BaseController
db_schema = params[:db_schema]
db_user = params[:db_user]
db_password = params[:db_password]
phrase = license_key
phrase = license_key
# Check Exists IV
if flag == "<%= ENV['AES_IV'] %>"
# Export for Key
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_key(phrase)
else
aes_key = ENV["AES_KEY"]
aes_iv = ENV["AES_IV"]
end
# if flag == "<%= ENV['AES_IV'] %>"
# # Export for Key
# aes = MyAesCrypt.new
# aes_key, aes_iv = aes.export_key(phrase)
# else
# aes_key = ENV["AES_KEY"]
# aes_iv = ENV["AES_IV"]
# end
@license = License.new(ENV["SX_PROVISION_URL"])
response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password)
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
if response[:status]
redirect_to root_url, notice: response["message"]
else
@@ -38,7 +38,7 @@ class InstallController < BaseController
end
end
def check_license
def check_license
if License.check_license_file
redirect_to root_url
end

View File

@@ -62,9 +62,21 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
puts params[:order_items]
is_extra_time = false
extra_time = ''
items_arr = []
JSON.parse(params[:order_items]).each { |i|
if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30'
is_extra_time = true
if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30'
time = 30*60*i["quantity"].to_i
extra_time = Time.at(time)
else
time = 60*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items_arr.push(items)
}
@@ -80,36 +92,34 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if !params["booking_id"].nil?
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if booking
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking)
# puts "WWwwWWWWWWww"
# puts sale_status
if sale_status
return return_json_status_with_code(400, "bill requested")
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if booking
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking)
if sale_status
return return_json_status_with_code(400, "bill requested")
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
else
sale_status = check_order_with_table(params[:table_id])
if sale_status
return return_json_status_with_code(400, "bill requested")
end
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
else
sale_status = check_order_with_table(params[:table_id])
# puts "OOOOOOOOO"
# puts sale_status
if sale_status
return return_json_status_with_code(400, "bill requested")
end
end
end #booking exists
end #booking exists
else
sale_status = check_order_with_table(params[:table_id])
# puts "MMMMMMMM"
# puts sale_status
if sale_status
# return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")

View File

@@ -75,7 +75,8 @@ class Origami::CustomersController < BaseOrigamiController
# if flash["errors"]
# @crm_customer.valid?
# end
@membership_types = Lookup.collection_of("member_group_type")
respond_to do |format|
# format.html { render :template => "crm/customers/index" }
format.html { render action: "index"}

View File

@@ -157,7 +157,11 @@ class Origami::DiscountsController < BaseOrigamiController
is_card = params[:is_card]
sub_total = params[:sub_total]
sale = Sale.find(sale_id)
if is_card == 'true'
is_card = true
else is_card.to_s == 'false'
is_card = false
end
# Check for Card Payment
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
@@ -178,9 +182,7 @@ class Origami::DiscountsController < BaseOrigamiController
end
end
end
generic_customer_id = sale.customer.membership_id
account_no = sale.customer.paypar_account_no
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
@@ -188,12 +190,13 @@ class Origami::DiscountsController < BaseOrigamiController
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
account_no = sale.customer.paypar_account_no rescue nil
# Check for items for Paypar Cloud
if acc_prices.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: nil,
:body => { account_no: account_no,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
@@ -220,8 +223,8 @@ class Origami::DiscountsController < BaseOrigamiController
else
response = {"status": false, "message": "You have no selected discount item" }
end
puts "discountttttttttttt"
puts response.to_json
Rails.logger.debug "-------------- Member Discount Osaka ---------"
Rails.logger.debug response.to_json
# Re-calc All Amount in Sale
if response["status"] == true
discount_amount = response["discount_earned"]

View File

@@ -22,6 +22,10 @@ class Origami::HomeController < BaseOrigamiController
@status_sale = ""
@sale_array = Array.new
@shop = Shop::ShopDetail
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new

View File

@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
@payment_method_setting = PaymentMethodSetting.all
@rebate = MembershipSetting.find_by_rebate(1)
@sale_data = Sale.find_by_sale_id(@sale_id)
# @sale_id = params[:sale_id]
# sale_data = Sale.find_by_sale_id(@sale_id)

View File

@@ -22,6 +22,7 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Print for First Bill to Customer
<<<<<<< HEAD
# unique_code = "ReceiptBillPdf"
# #shop detail
# shop_details = Shop::ShopDetail
@@ -45,6 +46,48 @@ class Origami::PaymentsController < BaseOrigamiController
# printer = Printer::ReceiptPrinter.new(print_settings)
# 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_details, "Frt")
=======
unique_code = "ReceiptBillPdf"
#shop detail
shop_details = Shop::ShopDetail
# customer= Customer.where('customer_id=' +.customer_id)
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if shop_details.is_rounding_adj
a = sale_data.grand_total % 25 # Modulus
b = sale_data.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total-sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
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_details, "Frt",current_balance)
>>>>>>> master
end
def create
@@ -58,9 +101,15 @@ class Origami::PaymentsController < BaseOrigamiController
# rounding adjustment
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
@@ -234,6 +283,12 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
end
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "foc")
@@ -280,14 +335,15 @@ class Origami::PaymentsController < BaseOrigamiController
@shop = Shop.find_by_id(1)
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
else
new_total = saleObj.grand_total
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
end

View File

@@ -19,6 +19,10 @@ class Origami::RoomsController < BaseOrigamiController
@status_sale = ""
@sale_array = Array.new
@shop = Shop::ShopDetail
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@room.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new

View File

@@ -15,9 +15,14 @@ class Origami::SalesController < BaseOrigamiController
dining = params[:dining_id]
sale_id = params[:sale_id]
table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.each do |booking|
# if !booking.checkout_at.nil?
# existing_booking.update_attributes(checkout_at: checkout_at)
# end
if booking.sale_id.nil?
booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved'
order = Order.find(booking_order.order_id)
order.status = 'billed'
@@ -36,7 +41,7 @@ class Origami::SalesController < BaseOrigamiController
order.save
booking.save
end
existing_booking = Booking.find_by_sale_id(sale_id)
booking_order = BookingOrder.where('booking_id=?',booking)
booking_order.each do |bo|
bo.booking_id = existing_booking.booking_id

View File

@@ -6,7 +6,11 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0)
end
# update count for shift sale
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
@@ -21,7 +25,7 @@ class Origami::VoidController < BaseOrigamiController
shift.save
end
end
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
@@ -38,12 +42,14 @@ class Origami::VoidController < BaseOrigamiController
table_avaliable = true
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.sale.sale_status == 'new'
table_avaliable = false
if !booking.sale.nil?
if booking.sale.sale_status == 'new'
table_avaliable = false
end
end
end
if table_avaliable == true
if table_avaliable
table.status = 'available'
table.save
end

View File

@@ -19,7 +19,8 @@ class Reports::CommissionController < BaseReportController
@from = from_date
@to = to_date
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls

View File

@@ -21,7 +21,8 @@ authorize_resource :class => false
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -8,6 +8,8 @@ class Reports::DailysaleController < BaseReportController
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls

View File

@@ -23,7 +23,8 @@ class Reports::PaymentMethodController < BaseReportController
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -23,7 +23,8 @@ authorize_resource :class => false
@tax_profiles = TaxProfile.order('order_by asc')
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -25,7 +25,7 @@ class Reports::SaleitemController < BaseReportController
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
@@ -34,6 +34,9 @@ class Reports::SaleitemController < BaseReportController
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if shift.present?
shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@@ -64,6 +67,9 @@ class Reports::SaleitemController < BaseReportController
date_arr.push(str)
end
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
out = {:status => 'ok', :message => date_arr}
respond_to do |format|

View File

@@ -17,7 +17,8 @@ class Reports::ShiftsaleController < BaseReportController
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = @shift
end
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls

View File

@@ -16,7 +16,8 @@ class Reports::StockCheckController < BaseReportController
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
@from = from_date
@to = to_date
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls

View File

@@ -20,7 +20,8 @@ authorize_resource :class => false
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")

View File

@@ -0,0 +1,35 @@
class SymControlController < BaseController
skip_before_action :verify_authenticity_token
def run
sym_path = "/home/yan/symmetric/"
check_sym_proc_str = `#{"service SymmetricDS status"}`
# Check Sym Installed
# if sym_install_status[1] == "false"
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
# end
if check_sym_proc_str.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
# Create Sym Table
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym
render :text => "<h1>Success!</h1>"
end
else
render :text => "<h1>Sym Sql file not found!</h1>"
end
end
else
render :text => "<h1>Sym not running!</h1>"
end
end
end

View File

@@ -58,6 +58,7 @@ class Ability
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :member_discount, :discount
can :first_bill, :payment
can :show, :payment

View File

@@ -146,8 +146,8 @@ class Customer < ApplicationRecord
if sale.customer.membership_id
response = self.rebat(Sale.find(sale.sale_id))
#record an payment in sale-audit
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} "
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, "CronJob")
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} "
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
if response["status"] == true
status = sale.update_attributes(rebate_status: "true")
@@ -157,66 +157,137 @@ class Customer < ApplicationRecord
end
def self.rebat(sObj)
rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items)
rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
if generic_customer_id.present?
paypar = sObj.sale_payments
paypar = sObj.sale_payments
payparcost = 0
credit = 0
credit = 0
paypar.each do |pp|
if pp.payment_method == "paypar"
payparcost = payparcost + pp.payment_amount
elsif pp.payment_method == "creditnote"
end
if pp.payment_method == "creditnote"
credit = 1
end
end
# overall_dis = SaleItem.get_overall_discount(sObj.id)
overall_dis = sObj.total_discount
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
overall_dis = sObj.total_discount
if credit != 1
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,
total_sale_transaction_amount: sObj.grand_total,
merchant_uid:merchant_uid,
total_amount: total_amount,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
auth_token:auth_token}.to_json,
:headers => {
response = HTTParty.get(url,
:body => {
member_group_id:sObj.customer.membership_type,
merchant_uid:merchant_uid,
campaign_type_id: campaign_type_id,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
}, :timeout => 10)
'Accept' => 'application/json; version=2'
}, :timeout => 10)
rescue Net::OpenTimeout
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
redeem_amount = payparcost + overall_dis
total_percentage = 0
type_arr = []
Rails.logger.debug "Get Member Campaign"
Rails.logger.debug response.to_json
# Check for present response fields
if response["membership_campaign_data"].present?
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
end
end
return response
Rails.logger.debug "--------Update Rebate response -------"
Rails.logger.debug response.to_json
rebate_arr =[]
campaign_method.each do |a|
data = {:type => a[:type], :amount => a[:amount]}
type_arr.each do |si|
if si[:type] == a[:type]
if credit == 1
data[:amount] = 0
else
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
end
end
end
rebate_arr.push(data)
end
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => {
generic_customer_id:generic_customer_id ,
total_sale_transaction_amount: sObj.grand_total,
merchant_uid:merchant_uid,
total_amount: total_amount,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
campaign_method: rebate_arr.to_json,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
}, :timeout => 10)
rescue Net::OpenTimeout
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
Rails.logger.debug "Rebage Response"
Rails.logger.debug response.to_json
return response
end
end
else
response = { "status": "no_member", "message": "Not membership"}
end
end

View File

@@ -68,22 +68,54 @@ class License
end
# For Local System
def detail_with_local_file()
has_license = true # verify_license()
def detail_with_local_file()
renewal_date_str = read_license("renewable_date")
if check_expiring(renewal_date_str)
# return for all ok
return 1
else
has_license = verify_license()
if has_license
puts "VERIFIED"
if has_license
# return for expiring
return 2
else
return 0
end
end
# end
end
# License Activation
def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password)
@params = { query: { lookup_type: self.server_mode, iv_key: iv, license_key: license_key } }
def license_activate (shop, license_key, db_host, db_schema, db_user, db_password)
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_key(license_key)
@params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } }
response = self.class.get("/activate", @params)
@activate = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@activate["status"])
##Check from local redis - if available load local otherwise get from remote
cache_key = "shop:#{@activate["shop_name"]}"
cache_license = nil
##Get redis connection from connection pool
redis = Redis.new
cache_license = redis.get(cache_key)
Rails.logger.info "Cache key - " + cache_key.to_s
if cache_license.nil?
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
redis = Redis.new
redis.set(cache_key, Marshal.dump(cache))
end
Rails.logger.info "License - " + response.parsed_response.to_s
response = create_license_file(@activate)
if(response[:status])
sym_path = "/home/yan/symmetric/"
@@ -115,9 +147,23 @@ class License
return false
end
# Check Expired before 30 days
def check_expiring(renewal_date_str)
if !renewal_date_str.empty?
renewal_date = DateTime.parse(renewal_date_str)
renewal_date > Date.today.advance(:days => 30)
end
end
# Check License expired date from PROVISION SERVER
def check_expired(renewal_date_str)
def check_expired(renewal_date_str)
expired_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str)
if(renewal_date_str != expired_date_str)
update_license("renewable_date", renewal_date_str)
end
if (renewal_date < Date.today)
return true
else
@@ -131,16 +177,18 @@ class License
end
# read line by key for license file
def read_license(key)
decrypted_line = ""
def read_license(key_name)
decrypted_line = ""
key, iv = get_redis_key()
if File.exist?("config/license.yml")
File.open("config/license.yml").each do |line|
if line.include? (key)
decrypted_line_array = line.split(": ")
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE'])
if line.include? (key_name)
decrypted_line_array = line.split(": ")
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
end
end
end
return decrypted_line
end
@@ -158,183 +206,210 @@ class License
return decrypted_line
end
private
# Update license file for line
def update_license(content, new_content)
key, iv = get_redis_key()
def decode_str(str)
return Base64.decode64(str)
if !new_content.include? "=="
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
content_str = read_license_no_decrypt(content)
if File.exist?("config/license.yml")
file_str = File.read("config/license.yml")
new_file_str = file_str.gsub(content_str, encode_str(crypted_str))
# To write changes to the file, use:
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
# File.open("config/license.yml").each do |line|
# new_file_str = line.gsub(content, crypted_str)
# f.put
# end
end
end
private
def get_redis_key
iv = ""
key = ""
shop = read_license_no_decrypt("shop_name")
##Check from local redis - if available load local otherwise get from remote
cache_key = "shop:#{shop.chomp}"
cache_shop = nil
##Get redis connection from connection pool
redis = Redis.new
cache_shop = redis.get(cache_key)
if !cache_shop.nil?
@shop = Marshal.load(cache_shop)
key = @shop["key"]
iv = @shop["iv"]
end
return key, iv
end
def encode_str(str)
return Base64.encode64(str)
end
def decode_str(str)
return Base64.decode64(str)
end
# License File Creation
def create_license_file(response_data)
if File.exist?("config/license.yml")
delete_license_file
end
# License File Creation
def create_license_file(response_data)
if File.exist?("config/license.yml")
delete_license_file
end
begin
# Licese File Creation
File.open("config/license.yml", "w") do |f|
f.puts("iv_key: #{response_data['iv_key']}")
f.puts("shop_name: #{response_data['shop_name']}")
f.puts("email: #{response_data['email']}")
f.puts("telephone: #{response_data['telephone']}")
f.puts("fax: #{response_data['fax']}")
f.puts("address: #{response_data['address']}")
f.puts("dbhost: #{response_data['dbhost']}")
f.puts("dbschema: #{response_data['dbschema']}")
f.puts("dbusername: #{response_data['dbusername']}")
f.puts("dbpassword: #{response_data['dbpassword']}")
f.puts("api_token: #{response_data['api_token']}")
f.puts("app_token: #{response_data['app_token']}")
f.puts("plan_sku: #{response_data['plan_sku']}")
f.puts("renewable_date: #{response_data['renewable_date']}")
f.puts("plan_name: #{response_data['plan_name']}")
end
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
end
response = { "status": true, "message": "Success Activation. License also created."}
end
# Symmetric Configuration
def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password)
if File.directory? (sym_location)
begin
# Licese File Creation
File.open("config/license.yml", "w") do |f|
f.puts("iv_key: #{response_data['iv_key']}")
f.puts("shop_name: #{response_data['shop_name']}")
f.puts("email: #{response_data['email']}")
f.puts("telephone: #{response_data['telephone']}")
f.puts("fax: #{response_data['fax']}")
f.puts("address: #{response_data['address']}")
f.puts("dbhost: #{response_data['dbhost']}")
f.puts("dbschema: #{response_data['dbschema']}")
f.puts("dbusername: #{response_data['dbusername']}")
f.puts("dbpassword: #{response_data['dbpassword']}")
f.puts("api_token: #{response_data['api_token']}")
f.puts("app_token: #{response_data['app_token']}")
end
# sx properties create
f = File.open(sym_location + "engines/sx.properties", "w")
f.write("engine.name=sx\n")
f.write("db.driver=com.mysql.jdbc.Driver\n")
f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n")
f.write("db.user=#{db_user}\n")
f.write("db.password=#{db_password}\n")
f.write("registration.url=\n")
f.write("sync.url=http://#{db_host}:31415/sync/sx\n")
f.write("group.id=sx\n")
f.write("external.id=000\n")
f.write("job.purge.period.time.ms=7200000\n")
f.write("job.routing.period.time.ms=5000\n")
f.write("job.push.period.time.ms=10000\n")
f.write("job.pull.period.time.ms=10000\n")
f.write("initial.load.create.first=true\n")
f.write("initial.load.use.extract.job.enabled=true\n")
f.close
# read from license file
shop_name = read_license_no_decrypt("shop_name")
dbhost = read_license("dbhost")
dbschema = read_license("dbschema")
dbusername = read_license("dbusername")
dbpassword = read_license("dbpassword")
# shop properties create
f = File.open(sym_location + "engines/#{shop_name}.properties", "w")
f.write("engine.name=#{shop_name}\n")
f.write("db.driver=com.mysql.jdbc.Driver\n")
f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n")
f.write("db.user=#{dbusername}\n")
f.write("db.password=#{dbpassword}\n")
f.write("registration.url=http://#{db_host}:31415/sync/sx\n")
f.write("group.id=store\n")
f.write("external.id=001\n")
f.write("job.routing.period.time.ms=5000\n")
f.write("job.push.period.time.ms=10000\n")
f.write("job.pull.period.time.ms=10000\n")
# f.write("initial.load.create.first=true\n")
# f.write("initial.load.use.extract.job.enabled=true\n")
f.close
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
end
response = { "status": true, "message": "Success Activation. License also created."}
end
end
# Symmetric Configuration
def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password)
if File.directory? (sym_location)
begin
# sx properties create
f = File.open(sym_location + "engines/sx.properties", "w")
f.write("engine.name=sx\n")
f.write("db.driver=com.mysql.jdbc.Driver\n")
f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n")
f.write("db.user=#{db_user}\n")
f.write("db.password=#{db_password}\n")
f.write("registration.url=\n")
f.write("sync.url=http://#{db_host}:31415/sync/sx\n")
f.write("group.id=sx\n")
f.write("external.id=000\n")
f.write("job.purge.period.time.ms=7200000\n")
f.write("job.routing.period.time.ms=5000\n")
f.write("job.push.period.time.ms=10000\n")
f.write("job.pull.period.time.ms=10000\n")
f.write("initial.load.create.first=true\n")
f.write("initial.load.use.extract.job.enabled=true\n")
f.close
# Run Symmetric
def run_symmetric(sym_path)
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
# check_sym_proc_str = check_sym_proc_str.split("\n")
# sym_install_status = check_sym_proc_str[0].split(": ")
check_sym_proc_str = `#{"service SymmetricDS status"}`
# read from license file
shop_name = read_license("shop_name")
dbhost = read_license("dbhost")
dbschema = read_license("dbschema")
dbusername = read_license("dbusername")
dbpassword = read_license("dbpassword")
# Check Sym Installed
# if sym_install_status[1] == "false"
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
# end
# shop properties create
f = File.open(sym_location + "engines/#{shop_name}.properties", "w")
f.write("engine.name=#{shop_name}\n")
f.write("db.driver=com.mysql.jdbc.Driver\n")
f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n")
f.write("db.user=#{dbusername}\n")
f.write("db.password=#{dbpassword}\n")
f.write("registration.url=http://#{db_host}:31415/sync/sx\n")
f.write("group.id=store\n")
f.write("external.id=001\n")
f.write("job.routing.period.time.ms=5000\n")
f.write("job.push.period.time.ms=10000\n")
f.write("job.pull.period.time.ms=10000\n")
# f.write("initial.load.create.first=true\n")
# f.write("initial.load.use.extract.job.enabled=true\n")
f.close
rescue IOError
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
end
response = { "status": true, "message": "Success Activation. License also created."}
end
end
# Run Symmetric
def run_symmetric(sym_path)
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
# check_sym_proc_str = check_sym_proc_str.split("\n")
# sym_install_status = check_sym_proc_str[0].split(": ")
check_sym_proc_str = `#{"service SymmetricDS status"}`
# Check Sym Installed
# if sym_install_status[1] == "false"
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
# end
# Run Sym Service
sym_run_status = check_sym_running(check_sym_proc_str, sym_path)
if sym_run_status
# Create Sym Table
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym
response = { "status": true, "message": "Activation is success and Configuration done..."}
end
else
response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"}
# Run Sym Service
sym_run_status = check_sym_running(check_sym_proc_str, sym_path)
if sym_run_status
# Create Sym Table
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
if check_sym_table
sym_sql = Rails.root + "db/sym_master.sql"
if File.exist? (sym_sql)
# Import Sym Sql to db and start sym
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
stop_sym = system("service SymmetricDS stop")
run_sym = system("service SymmetricDS start")
if run_sym
response = { "status": true, "message": "Activation is success and Configuration done..."}
end
else
response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"}
end
else
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
end
else
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
end
end
# Check Symmetric Running
def check_sym_running(status, sym_path)
# Run Sym Service
# if status.include? "Server is already running"
# return true
# elsif status.include? "false"
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
# if sym_start_str.include? "Started"
# return true
# else
# check_sym_running(sym_start_status[0])
# end
# else
# return true
# end
# Check Symmetric Running
def check_sym_running(status, sym_path)
# Run Sym Service
# if status.include? "Server is already running"
# return true
# elsif status.include? "false"
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
# if sym_start_str.include? "Started"
# return true
# else
# check_sym_running(sym_start_status[0])
# end
# else
# return true
# end
if status.include? "Active: active (running)" #"Server is already running"
return true
end
return false
if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
return true
end
return false
end
# Delete License File
def delete_license_file
File.delete("config/license.yml") if File.exist?("config/license.yml")
end
# Delete License File
def delete_license_file
File.delete("config/license.yml") if File.exist?("config/license.yml")
end
# Assign db info for Cloud
def assign(aes_key, aes_iv)
# self.name = @license["name"]
# self.address_1 = @license["address_1"]
# self.address_2 = @license["address_2"]
# self.township = @license["township"]
# self.city = @license["city"]
# self.country = @license["country"]
# self.email = @license["email"]
# self.phone = @license["phone"]
# self.fax = @license["fax"]
# self.logo = @license["logo"]
# self.localhost_address = @license["localhost_address"]
# self.subdomain = @license["subdomain"]
# self.plan_activation_date = Date.parse(@license["plan_activation_date"])
# self.plan_next_renewal_date = Date.parse(@license["plan_next_renewal_date"])
## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d")
## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d")
# self.plan_max_products = @license["plan_max_products"].to_i
# self.plan_max_customers = @license["plan_max_customers"].to_i
# self.plan_active_connections = @license["plan_active_connections"].to_i
# salt = @license["secret_key"]
def assign(aes_key, aes_iv)
key = Base64.decode64(aes_key)
iv = Base64.decode64(aes_iv)
@@ -349,18 +424,6 @@ class License
self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE'])
self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
end
# self.exchange_unqiue_id = @license["exchange_unqiue_id"]
# self.localqueue_host= @license["localqueue_host"]
# self.localqueue_user= @license["localqueue_user"]
# self.localqueue_password= @license["localqueue_password"]
# self.remotequeue_host = @license["remotequeue_host"]
# self.remotequeue_user = @license["remotequeue_user"]
# self.remotequeue_password = @license["remotequeue_password"]
# self.api_token = @license["api_token"]
# self.app_token = @license["app_token"]
end
end

View File

@@ -1,2 +1,3 @@
class MembershipSetting < ApplicationRecord
MembershipSetting = MembershipSetting.find_by_id(1)
end

View File

@@ -17,8 +17,7 @@ class MyAesCrypt
passphrase = passphrase + ENV['SX_KEY']
passphrase = passphrase.gsub(".","_")
digest = Digest::SHA256.new
key_digest = digest.update(passphrase)
# iv_digest = digest.update(iv_salt)
key_digest = digest.update(passphrase)
key = key_digest.digest
# iv = iv_digest.digest

View File

@@ -10,7 +10,7 @@ class Order < ApplicationRecord
has_many :assigned_order_items
#internal references attributes for business logic control
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
#Main Controller method to create new order - validate all inputs and generate new order
# order_item : {
@@ -25,14 +25,33 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
#add extra time
if self.is_extra_time && self.extra_time
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc,:checkout_at => Time.now.utc + self.extra_time.to_i,
:checkin_by => self.employee_name,
:booking_status => "assign" })
else
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
end
#end extra time
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
booking = Booking.find(self.booking_id)
#add extra time
if self.is_extra_time
if !booking.checkout_at.nil?
new_time = booking.checkout_at + self.extra_time.to_i
booking.update_attributes(checkout_at: new_time)
end
end
#end extra time
end
booking.save!

View File

@@ -1,4 +1,8 @@
class PrintSetting < ApplicationRecord
# validations
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
def self.get_precision_delimiter
PrintSetting.find_by_unique_code("CloseCashierPdf")
end
end

View File

@@ -12,7 +12,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
filename = "tmp/order_item.pdf"
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
# check for item not to show
# if order_item[0].price != 0
@@ -46,14 +46,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item.pdf"
order_items.each do|odi|
odi_item=print_query('order_item', odi.order_items_id)
filename = "tmp/order_item_#{order_id}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
# check for item not to show
#if odi.price != 0
pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name)
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy
@@ -68,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/order_summary.pdf"
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
@@ -96,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Per Item
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item.pdf"
filename = "tmp/order_item_#{booking_id}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
@@ -120,7 +122,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/booking_summary.pdf"
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy

View File

@@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
pdf.render_file "tmp/print_crm_order.pdf"
self.print("tmp/print_crm_order.pdf")
end
#Queue No Print
def print_call_waiter(printer_settings,table,time,shop_detail)
#Use CUPS service
#Generate PDF
#Print
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
pdf.render_file "tmp/print_call_waiter.pdf"
self.print("tmp/print_call_waiter.pdf")
end
end

View File

@@ -114,7 +114,14 @@ class Sale < ApplicationRecord
order.save
booking.sale_id = self.id
booking.checkout_at = Time.now.utc.getlocal
if !booking.checkout_at.nil?
if booking.checkout_at < Time.now.utc.getlocal
booking.checkout_at = Time.now.utc.getlocal
end
else
booking.checkout_at = Time.now.utc.getlocal
end
booking.checkout_by = requested_by.name
booking.save
@@ -222,8 +229,6 @@ class Sale < ApplicationRecord
sales_items.each do |item|
#compute each item and added to total
puts "item.sales_item_id ddd"
puts item.sale_item_id
subtotal_price = subtotal_price + item.price
# only calc tax when true
@@ -247,6 +252,7 @@ class Sale < ApplicationRecord
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil)
sale = Sale.find(sale_id)
sales_items = sale_itemss
@@ -659,7 +665,7 @@ def self.get_item_query()
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
# query = query.where("i.item_instance_code IS NOT NULL")
query = query.group("i.product_name").order("mi.account_id asc","mi.menu_category_id asc")
query = query.group("acc.title,mi.account_id,i.product_name").order("acc.title desc, mi.account_id desc")
end
def self.get_other_charges()
@@ -1107,7 +1113,7 @@ end
def self.top_items(today)
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.group("a.product_code")
.order("SUM(a.qty) DESC")
.first()

View File

@@ -173,13 +173,20 @@ class SalePayment < ApplicationRecord
private
def cash_payment
status = false
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
if sale_payments_data.nil?
status = true
end
payment_status = false
self.payment_method = "cash"
self.payment_amount = self.received_amount
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
sale_update_payment_status(self.received_amount,status)
return payment_status
end
@@ -187,7 +194,7 @@ class SalePayment < ApplicationRecord
payment_status = false
# add to sale item with foc
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
sale_items.each do|item|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
@@ -271,7 +278,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
if membership_data["status"]==true
self.payment_method = "paypar"
@@ -290,7 +297,7 @@ class SalePayment < ApplicationRecord
end
def sale_update_payment_status(paid_amount)
def sale_update_payment_status(paid_amount,check_foc = false)
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save!
@@ -328,7 +335,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
if !response.nil?
if response["status"] == true
@@ -349,8 +356,10 @@ class SalePayment < ApplicationRecord
self.sale.save!
table_update_status(sObj)
if paid_amount != "0.0"
if check_foc
update_shift
elsif paid_amount != "0.0"
update_shift
end
end
@@ -363,6 +372,11 @@ class SalePayment < ApplicationRecord
shift.update(self.sale)
self.sale.shift_sale_id = shift.id
self.sale.save
else
shift = ShiftSale.current_shift
shift.update(self.sale)
self.sale.shift_sale_id = shift.id
self.sale.save
end
end
@@ -436,7 +450,7 @@ class SalePayment < ApplicationRecord
'Accept' => 'application/json; version=2'
}, :timeout => 10)
rescue Net::OpenTimeout
response = { "status": false , "message": "Connect To" }
response = { "status": false , "message": " Connection timeout" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}

View File

@@ -0,0 +1,71 @@
class CallWaiterPdf < 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
def initialize(printer_settings, table,time,shop_detail)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 35
self.qty_width = 20
self.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
self.header_font_size = 10
self.item_font_size = 8
header( shop_detail.name, printer_settings.name)
call_waiter(table)
stroke_horizontal_rule
# date_info(queue)
end
def header (shop_name, name)
text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
move_down 5
end
def call_waiter (table)
move_down 3
text "Table Name : #{table.name}",:align => :center
end
# def date_info(queue)
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
# text "Date:", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.label_width,y_position], :width => self.item_width) do
# text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
# end
# move_down 5
# end
end

View File

@@ -1,4 +1,5 @@
class CloseCashierPdf < Prawn::Document
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,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
@@ -38,11 +39,22 @@ class CloseCashierPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
#check delimiter
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header( shop_details)
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter)
end
def header (shop_details)
@@ -58,7 +70,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -97,7 +109,7 @@ class CloseCashierPdf < Prawn::Document
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.opening_balance}" , :size => self.item_font_size,:align => :left
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
@@ -105,7 +117,8 @@ class CloseCashierPdf < Prawn::Document
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.closing_balance}" , :size => self.item_font_size,:align => :left
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
@@ -122,7 +135,8 @@ class CloseCashierPdf < Prawn::Document
text "Received Amount :", :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.closing_balance}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -130,7 +144,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash In:", :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.cash_in}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -138,7 +152,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Out:", :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.cash_out}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
@@ -151,7 +165,7 @@ class CloseCashierPdf < Prawn::Document
text "Cash Payment :", :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.cash_sales}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -159,7 +173,7 @@ class CloseCashierPdf < Prawn::Document
text "Credit Payment :", :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.credit_sales}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
@@ -170,7 +184,7 @@ class CloseCashierPdf < Prawn::Document
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.mpu_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -178,7 +192,7 @@ class CloseCashierPdf < Prawn::Document
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -186,7 +200,7 @@ class CloseCashierPdf < Prawn::Document
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -194,7 +208,7 @@ class CloseCashierPdf < Prawn::Document
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -202,7 +216,7 @@ class CloseCashierPdf < Prawn::Document
text "Reedem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
else
@@ -211,7 +225,7 @@ class CloseCashierPdf < Prawn::Document
text "Other Payment :", :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.other_sales}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -220,7 +234,7 @@ class CloseCashierPdf < Prawn::Document
text "Rounding Adjustments :", :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_rounding.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -228,7 +242,7 @@ class CloseCashierPdf < Prawn::Document
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.grand_total.round(2)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
# end other payment details
@@ -243,7 +257,7 @@ class CloseCashierPdf < Prawn::Document
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{tax.st_amount.round(2)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
@@ -252,7 +266,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Taxes :", :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_taxes}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -260,7 +274,7 @@ class CloseCashierPdf < Prawn::Document
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.nett_sales}", :style => :bold , :size => self.header_font_size - 1, :align => :right
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
#end for service charges and commercial tax
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
@@ -283,7 +297,7 @@ class CloseCashierPdf < Prawn::Document
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
@@ -297,7 +311,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@member_discount}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
@@ -308,7 +322,7 @@ class CloseCashierPdf < Prawn::Document
text "Total Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@overall}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -316,7 +330,7 @@ class CloseCashierPdf < Prawn::Document
text "Total FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{@total_foc})", :size => self.item_font_size, :align => :right
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor

View File

@@ -40,7 +40,7 @@ class OrderItemPdf < Prawn::Document
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
move_down 3
#order_info
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
@@ -56,13 +56,13 @@ class OrderItemPdf < Prawn::Document
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 5
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 5
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
@@ -92,7 +92,7 @@ class OrderItemPdf < Prawn::Document
move_down 5
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
@@ -100,23 +100,27 @@ class OrderItemPdf < Prawn::Document
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
if !(order_item.alt_name).empty?
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
move_down 5
if !options.empty?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 5

View File

@@ -0,0 +1,129 @@
class OrderItemSlimPdf < Prawn::Document
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
def initialize(print_settings,order_item_slim, print_status, options, alt_name)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
self.header_font_size = 11
self.item_font_size = 9
else
self.header_font_size = 12
self.item_font_size = 10
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 1
#order_info
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
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
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 3
end
# Write Order items to PDF
def order_items_slim(order_item_slim, options, alt_name, precision)
y_position = cursor
#Add Order Item
add_order_items_slim(order_item_slim, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
end
# Add order items slim under order info
def add_order_items_slim(order_item_slim, options, alt_name, precision)
y_position = cursor
move_down 1
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
end
# if alt_name
# if !(order_item_slim.alt_name).empty?
# move_down 1
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
# text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
# end
# end
if !options.empty?
move_down 1
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 1
end
end

View File

@@ -108,7 +108,7 @@ class OrderSummaryPdf < Prawn::Document
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
@@ -117,24 +117,26 @@ class OrderSummaryPdf < Prawn::Document
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
if !(odi.alt_name).empty?
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
move_down 5
# add option
options = odi.options == "[]"? "" : odi.options
if options != ""
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left

View File

@@ -0,0 +1,155 @@
class OrderSummarySlimPdf < Prawn::Document
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
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
self.header_font_size = 11
self.item_font_size = 9
else
self.header_font_size = 12
self.item_font_size = 10
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 1
#order_info
order_info(order[0].order_id, order[0].order_by,order[0].order_at)
# order items
if order_items == nil
order_items(order, alt_name, print_settings.precision)
else
order_items(order_items, alt_name, print_settings.precision)
end
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
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
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 1
end
# Write Order items to PDF
def order_items(order_item, alt_name, precision)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Item", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 1
#Add Order Item
add_order_items(order_item, alt_name, precision)
end
# Add order items under order info
def add_order_items(order_item, alt_name, precision)
y_position = cursor
move_down 1
order_item.each do|odi|
# check for item not to show
# if odi.price != 0
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
if !(odi.alt_name).empty?
move_down 1
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
# add option
options = odi.options == "[]"? "" : odi.options
if options != ""
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left
end
move_down 1
end
move_down 1
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
# end
end
end
end

View File

@@ -0,0 +1,507 @@
class ReceiptBillA5Pdf < Prawn::Document
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
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 15
self.price_width = 120
self.qty_width = 50
self.total_width = 120
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 25
self.item_description_width = (self.page_width-40) / 2
self.label_width = 150
self.description_width = 500
self.price_num_width = 100
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 16
self.item_font_size = 14
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
sign(sale_data)
footer(printed_status)
end
def header (shop_details)
move_down 10
text "#{shop_details.name}", :size => self.header_font_size,:align => :center
move_down 10
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 10
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down 10
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
move_down 12
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
end
move_down 10
y_position = cursor
bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 20, :height => self.item_height) do
text "Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
# :size => self.item_font_size,:align => :right
# end
move_down 10
stroke_horizontal_rule
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 5
item_label_qty_end_width = self.qty_width + 4
item_label_total_front_width = (self.item_width+self.price_width) + 10
item_label_total_end_width = self.total_width + 9
else
self.item_width = self.item_width.to_i + 8
item_label_qty_front_width = (self.item_width+self.price_width) + 8
item_label_qty_end_width = self.qty_width + 7
item_label_total_front_width = (self.item_width+self.price_width) + 5
item_label_total_end_width = self.total_width + 4
end
move_down 10
y_position = cursor
move_down 10
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down -5
stroke_horizontal_rule
add_line_item_row(sale_items,precision,delimiter)
end
def add_line_item_row(sale_items,precision,delimiter)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 5
item_qty_end_width = self.qty_width + 4
item_total_front_width = item_name_width + 10
item_total_end_width = self.total_width + 9
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 8
item_qty_end_width = self.qty_width + 7
item_total_front_width = item_name_width + 5
item_total_end_width = self.total_width + 4
end
y_position = cursor
move_down 10
sub_total = 0.0
sale_items.each do |item|
# check for item not to show
if item.price != 0
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
product_name = item.product_name
y_position = cursor
pad_top(15) {
bounding_box([0,y_position], :width =>self.item_width) do
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 10
end
end
stroke_horizontal_rule
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right
end
move_down 10
end
def all_total(sale_data,precision,delimiter)
item_name_width = self.item_width
y_position = cursor
if sale_data.discount_type == 'member_discount'
dis_type = "Member Discount:"
else
dis_type = "Overall Discount:"
end
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
if sale_data.sale_taxes.length > 0
sale_data.sale_taxes.each do |st|
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "#{ st.tax_name } ( #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
else
end
# move_down 10
# y_position = cursor
# bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
# text "Total Tax", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.description_width,y_position], :width =>self.label_width) do
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
# end
if sale_data.rounding_adjustment != 0.0
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
end
end
move_down 10
y_position = cursor
move_down 10
bounding_box([0,y_position], :width =>self.description_width) do
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down 10
sale_payment(sale_data,precision,delimiter)
end
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
move_down 10
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method").where('sale_id = ?', sale_data.sale_id).group("payment_method")
sale_payments.each do |payment|
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Redeem Payment", :size => self.item_font_size,:align => :left
end
else
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
end
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down 10
end
if sale_data.amount_received > 0
y_position = cursor
move_down 10
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down 10
end
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
balance = 0
rebate_balance =0
redeem = 0
redeem_count = 0
rebate_amount["data"].each do |res|
total = total + res["balance"]
#total redeem amount
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
redeem = redeem + res["withdraw"]
balance = balance + res["balance"]
end
#end Total redem
#total Rebate Earn
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
# Total Rebate Amount if birthday
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
#end Total rebate if birthday
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end
end
if member_info["status"] == true && member_info["data"].present?
total_balance = 0
member_info["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
total_balance = total_balance + res["balance"]
end
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.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
end
end
end
def customer(customer_name)
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "Customer Name", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
end
end
def discount_account(discount_price_by_accounts,precision,delimiter)
move_down 10
stroke_horizontal_rule
move_down 10
y_position = cursor
discount_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
end
end
def items_account(item_price_by_accounts,precision,delimiter)
move_down 10
stroke_horizontal_rule
move_down 10
y_position = cursor
item_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.description_width) do
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
break;
end
end
if sale_data.payment_status == "foc"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.description_width) do
move_down 73
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
end
end
def footer(printed_status)
move_down 10
stroke_horizontal_rule
move_down 10
y_position = cursor
bounding_box([0, y_position], :width =>self.item_description_width) do
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right
end
move_down 10
end
end

View File

@@ -4,13 +4,13 @@ class ReceiptBillPdf < Prawn::Document
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.margin = 0
self.price_width = 60
self.qty_width = 25
self.total_width = 60
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
self.description_width = 150
@@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -74,7 +79,7 @@ class ReceiptBillPdf < Prawn::Document
end
def header (shop_details)
move_down 7
move_down 5
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
@@ -124,15 +129,27 @@ class ReceiptBillPdf < Prawn::Document
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 5
item_label_qty_end_width = self.qty_width + 4
item_label_total_front_width = (self.item_width+self.price_width) + 10
item_label_total_end_width = self.total_width + 9
else
self.item_width = self.item_width.to_i + 8
item_label_qty_front_width = (self.item_width+self.price_width) + 8
item_label_qty_end_width = self.qty_width + 7
item_label_total_front_width = (self.item_width+self.price_width) + 5
item_label_total_end_width = self.total_width + 4
end
move_down 5
y_position = cursor
move_down 5
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down -5
stroke_horizontal_rule
@@ -140,7 +157,19 @@ class ReceiptBillPdf < Prawn::Document
end
def add_line_item_row(sale_items,precision,delimiter)
item_name_width = (self.item_width+self.price_width)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 5
item_qty_end_width = self.qty_width + 4
item_total_front_width = item_name_width + 10
item_total_end_width = self.total_width + 9
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 8
item_qty_end_width = self.qty_width + 7
item_total_front_width = item_name_width + 5
item_total_end_width = self.total_width + 4
end
y_position = cursor
move_down 5
sub_total = 0.0
@@ -162,8 +191,8 @@ class ReceiptBillPdf < Prawn::Document
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 5
end
@@ -469,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
end
move_down 5

View File

@@ -60,16 +60,16 @@ if (@booking)
end
# For YGN BBQ
if adult_count > 0
json.per_adult_spent (adult_spent/adult_count) * 0.05
else
# if adult_count > 0
# json.per_adult_spent (adult_spent/adult_count) * 0.05
# else
json.per_adult_spent 0
end
if child_count > 0
json.per_child_spent (child_spent/child_count) * 0.05
else
# end
# if child_count > 0
# json.per_child_spent (child_spent/child_count) * 0.05
# else
json.per_child_spent 0
end
# end
# End YGN BBQ
json.sub_total @total_amount

View File

@@ -7,8 +7,11 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
json.categories menu.menu_categories do |category|
json.id category.id
json.code category.code
json.order_by category.order_by
json.name category.name
json.alt_name category.alt_name
json.order_by category.order_by
json.parent_id category.menu_category_id
json.is_available category.is_available

View File

@@ -52,6 +52,7 @@
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.membership_type") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
<th><%= t("views.right_panel.detail.action") %></th>
@@ -75,6 +76,15 @@
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td>
<% if !@membership_types.nil? %>
<% @membership_types.each do |member_type| %>
<% if member_type[1] == crm_customer.membership_type %>
<%= member_type[0] %>
<% end %>
<% end %>
<% end %>
</td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.email %></td>
<td><%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %></td>

View File

@@ -14,11 +14,16 @@
<div class="container-fluid">
<div class="navbar-header">
<!-- <a href="javascript:void(0);" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false"></a> -->
<a href="javascript:void(0);" class="bars"></a>
<a class="navbar-brand" href="<%=dashboard_path%>">
<%if current_login_employee.role !="waiter" %>
<a href="javascript:void(0);" class="bars"></a>
<a class="navbar-brand" href="<%=dashboard_path%>" style="margin-left: 20px;">
<% else %>
<a class="navbar-brand m-0" href="<%=dashboard_path%>">
<%end%>
<img src="<%= asset_path('SX-Logo-small.png') %>" width="40" height="40" alt="Logo" />
<span class="navbar-brand-txt">SX Restaurant</span>
</a>
</a>
</div>
<!-- Start Delete confirrm text !-->
<div class="navbar-right">
@@ -29,16 +34,16 @@
</a>
<ul class="dropdown-menu">
<li>
<%if current_login_employee.role !="waiter" %>
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i>
<span class="font-18">Logout</span>
</p>
<span class="hidden" id="delete_text">
<h6>Are you sure you want to Logout ?</h6>
<!-- <h6>This action can't be undo. </h6> -->
</span>
<%end%>
<!-- <%if current_login_employee.role !="waiter" %> -->
<!-- <%end%> -->
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i>
<span class="font-18">Logout</span>
</p>
<span class="hidden" id="delete_text">
<h6>Are you sure you want to Logout ?</h6>
<!-- <h6>This action can't be undo. </h6> -->
</span>
</li>
</ul>
<!-- NO Need for color Change

View File

@@ -145,6 +145,31 @@
<% end %>
<% end %>
</div>
<div class="row">
<div class="col-1 col-black">
<span>Waiter</span>
</div>
<div class="col-11">
<hr />
</div>
</div>
<div class="row m-b-15">
<% @employees.each do |employee| %>
<%if employee.role == "waiter" %>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 empBtn" data-formid="#form_<%= employee.emp_id %>" >
<form id="form_<%= employee.emp_id %>" action="<%= emp_login_path(employee.emp_id) %>" method="PATCH">
</form>
<div class="card emp-body">
<div class="body bg-teal">
<%= employee.name%>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!-- <div class="col-xs-12 col-sm-12 col-md-2 col-lg-2"> </div> -->
</div>

View File

@@ -84,8 +84,8 @@
<%= qid.qty %>
</span> ]
</p>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<span class="card-text">
<span class="text-muted">Order at -

View File

@@ -7,17 +7,28 @@
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<% if menu.menu_category_id.nil?%>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
</ul>
</a>
</li>
<% @menu.each do |menu| %>
<% if menu.menu_category_id.nil? %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
</ul>
</a>
</li>
<% end%>
<% else %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
</ul>
</a>
</li>
<% end%>
<% end%>
<%end %>
<!-- <li class="nav-item menu_category">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1 <b class="caret"></b></a>

View File

@@ -32,7 +32,7 @@
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
<input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>">
<!-- <input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>"> -->
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
@@ -54,6 +54,7 @@
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.membership_type") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
<!-- <th>Paypar No</th> -->
@@ -76,7 +77,16 @@
<% end %>
</td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td>
<% if !@membership_types.nil? %>
<% @membership_types.each do |member_type| %>
<% if member_type[1] == crm_customer.membership_type %>
<%= member_type[0] %>
<% end %>
<% end %>
<% end %>
</td>
<td style="width:20%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td style="width:20%;word-break: break-all;"><%= crm_customer.email %></td>
<!-- <td><%= crm_customer.paypar_account_no %></td> -->
@@ -423,13 +433,13 @@
success: function(data) {
if(data.status == true)
{
var id = $("#table_id").val()
var type = $("#type").val()
var id = $("#table_id").val();
var type = $("#type").val();
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
window.location.href = '/origami/room/'+id
}
}else{
swal("Alert!", "Record not found!", "error");
location.reload();

View File

@@ -118,12 +118,13 @@
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
</button>
<%end%>
<%if current_login_employee.role != "waiter" %>
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
<!-- Temporary Disabled -->
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<%end%>
</div>
</div>
</div>

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row clearfix">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -140,7 +143,11 @@
</div>
<% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong> | Table <%= @dining.name rescue "" %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% if !@booking.reserved_by.nil? && %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% end %>
</div>
<% else %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
@@ -153,8 +160,7 @@
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<% if @status_sale == 'sale' %>
<%= @sale_array[0].receipt_no rescue '' %>
<%= @sale_array[0].receipt_no rescue '' %>
<% end %>
</span>
<br>
@@ -264,7 +270,7 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
<td class="item-attr"><strong id="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<% if @obj_sale != nil && @obj_sale.discount_type == 'member_discount' %>
@@ -291,7 +297,8 @@
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr">
<strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0 %></strong></td>
<strong id="order-round-adj"><%= @obj_sale.rounding_adjustment
%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
@@ -366,6 +373,7 @@
<%= t("views.btn.back") %>
</button>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<% if current_login_employee.role != "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<% if @dining.status != "available" %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
@@ -389,6 +397,7 @@
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button> -->
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
<% end %>
@@ -398,11 +407,52 @@
<% else %>
<button type="button" id="check_in" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.check_in") %></button>
<% end %>
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<option value="Cash">Cash</option>
<option value="Credit">Credit</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
<script>
$(document).ready(function () {
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
// console.log(checkReceiptNoInFirstBillData(receipt_no));
if(checkReceiptNoInFirstBillData(receipt_no,"")){
$("#pay").show();
}else{
$("#pay").hide();
}
/* end check first bill or not*/
$('.invoicedetails').on('click', function () {
var dining_id = "<%= @dining.id %>";
@@ -491,7 +541,7 @@
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -510,13 +560,12 @@
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
});
});
// Print for first bill
// $("#first_bill").on('click', function () {
// var sale_id = $('#sale_id').val();
@@ -556,18 +605,19 @@
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
else {
location.reload();
}
}
});
});
$('#move').on('click', function () {
var dining_id = "<%= @dining.id %>"
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/movetable";
})
@@ -584,8 +634,16 @@
url: ajax_url,
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id,
success: function (result) {
alert("Invoice updated")
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
});
})
@@ -685,7 +743,7 @@
$.ajax({
type: 'POST',
data: {dining_id : dining_id},
data: {'dining_id' : dining_id},
datatype: 'JSON',
url: '/origami/check_in',
success: function(data) {

View File

@@ -162,19 +162,19 @@ $('#jcb_pay').on('click',function(){
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
//start member discount 5% by pay card
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",

View File

@@ -160,18 +160,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// // success:function(result){
// // }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",

View File

@@ -163,18 +163,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
//Mpu Payment
$.ajax({type: "POST",

View File

@@ -96,7 +96,8 @@
<div class="form-horizontal">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="bottom-5">
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" />
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" onkeypress="return isNumberKey(event);" />
<br><span id="other-charges-amountErr" style="color:red;"></span>
</div>
<div class="bottom-5">
<textarea id="reasons" name="reasons" rows="2" class="form-control" placeholder="Reasons"></textarea>
@@ -278,12 +279,19 @@
if ($("#is_taxable:checked").length > 0) {
is_taxable = 1
}
$("#other-charges-amountErr").html("");
if(charge_amount != ""){
$("#other-charges-amount").val("");
$("#reasons").val("");
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
var item_row = item_row_template(sale_id, charge_amount, reasons, is_taxable);
$("#order-items-table tbody").append(item_row);
var item_row = item_row_template(sale_id, charge_amount, reasons, is_taxable);
$("#order-items-table tbody").append(item_row);
}
else{
$("#other-charges-amountErr").html("can't be blank");
}
});
// Calculate Other Charges for Payment
@@ -361,4 +369,13 @@
return item_row;
}
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
</script>

View File

@@ -14,8 +14,9 @@
<div class="col-lg-11col-md-11 col-sm-11">
<div >
<div >
<span id="receipt_no" class="hidden"><%=@sale_data.receipt_no rescue ' '%></span>
<% @payment_method_setting.where("is_active = true").each do |payment_method|%>
<div class="purple others-payment bottom left m-l-30" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
<div class="purple others-payment bottom left m-l-30 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
<% end %>
</div>
</div>
@@ -26,6 +27,19 @@
</div>
</div>
<script type="text/javascript">
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
if(payment_type) {
$(".others-payment").hide();
$("."+payment_type).show();
}
/* end check first bill or not*/
$('.others-payment').on('click',function(){
var input_type = $(this).attr("data-type");

View File

@@ -94,11 +94,11 @@
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><span id="rounding_adj"><%=@rounding_adj rescue 0%></span></strong></td>
<td class="item-attr"><strong><%= @sale_data.rounding_adjustment rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total+ @rounding_adj rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
@@ -124,7 +124,7 @@
<div class="col-md-4">
<strong>
<span id="grand_total" class="hidden"><%= @sale_data.grand_total rescue 0%></span>
<span id="amount_due"><%= @sale_data.grand_total + @rounding_adj rescue 0%></span></strong>
<span id="amount_due"><%= @sale_data.grand_total rescue 0%></span></strong>
</div>
</div>
@@ -223,7 +223,7 @@
<!-- <br> -->
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total+ @rounding_adj rescue 0 %></span></strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
</div>
<!-- <br> -->
</div>
@@ -290,6 +290,24 @@
<script>
$(document).ready(function(){
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if(payment_type=="Cash"){
$("#card_payment").hide();
$("#credit_payment").hide();
}else if(payment_type=="Credit"){
$("#card_payment").hide();
$("#others_payment").hide();
}else if(payment_type=="MPU"||payment_type=="VISA"||payment_type=="JCB"||payment_type=="Master"){
$("#credit_payment").hide();
}
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
$("#back").on('click', function() {
@@ -351,7 +369,7 @@
var master1 = $('#mastercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - othertotal;
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(amt);
update_balance();
break;
@@ -380,68 +398,91 @@
});
$('#pay').click(function() {
// $('#pay').text("Processing, Please wait!")
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper").hide();
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Opps","Please Pay with MPU Payment","warning");
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Redeem Payment","warning");
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Visa Payment","warning");
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with jcb Payment","warning");
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Credit Payment","warning");
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" );
$("#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// 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){
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
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),
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
if (credit <= 0) {
calculate_member_discount(sale_id);
}
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
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),
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami';
});
}
}
}
});
});
}
}
});
});
$('#void').on('click',function () {
if ($(this).attr('active') === "true") {
@@ -476,7 +517,7 @@
var master = $('#mastercount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
var result = amount_due - total;
var result = parseFloat(amount_due) - parseFloat(total);
$('#balance').text(result.toFixed(2));
}
@@ -497,7 +538,7 @@
//$( "#loading_wrapper" ).hide();
if (cash > 0) {
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
@@ -517,15 +558,20 @@
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var item_row = $('.is_card');
if (member_id && member_discount) {
if (item_row.length < 1) {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -183,7 +186,7 @@
<div class="card-title row customer_detail p-l-5 p-r-5" >
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @obj_sale_sale.customer_id rescue '' %></p>
<p class="hidden customer-id"><%= @obj_sale.customer_id rescue '' %></p>
&nbsp; Customer : <%= @obj_sale.customer.name rescue '-' %>
<%else%>
<p class="hidden customer-id"><%= @obj_order.customer_id rescue "-" %></p>
@@ -260,7 +263,7 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
<td class="item-attr"><strong id="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
@@ -353,12 +356,14 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
<!-- <button type="button" id="discount" class="btn bg-blue btn-block" disabled >Discount</button> -->
<!-- <button type="button" id="other-charges" class="btn bg-blue btn-block" disabled>Charges</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
<!-- <button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button> -->
<!-- <button type="button" class="btn bg-blue btn-block" disabled=""> Void </button> -->
<% else %>
<% end %>
<% if @status_sale == 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='edit'>Edit</button>
@@ -369,10 +374,40 @@
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" class="btn bg-blue btn-block" id='move' disabled="">Move</button> -->
<!-- <button type="button" id="request_bills" class="btn bg-blue btn-block" disabled> Req.Bill</button> -->
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block">First Bill</button> -->
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-blue btn-block" > Void </button>
<% end %>
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<option value="Cash">Cash</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<!-- Cashier Buttons -->
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
@@ -411,6 +446,19 @@ $(document).ready(function(){
// window.location.href = '/origami/order/' + order_id;
// })
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
// console.log(checkReceiptNoInFirstBillData(receipt_no));
if(checkReceiptNoInFirstBillData(receipt_no,"")){
$("#pay").show();
}else{
$("#pay").hide();
}
/* end check first bill or not*/
$('.invoicedetails').on('click',function(){
var dining_id = "<%= @room.id %>";
var sale_id = this.id;
@@ -498,7 +546,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -517,7 +565,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -533,11 +581,54 @@ $("#first_bill").on('click', function(){
type: "GET",
url: ajax_url,
success:function(result){
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
location.reload();
}
});
});
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
calculate_member_discount(sale_id,type);
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
@@ -600,8 +691,16 @@ $('#add_invoice').on('click',function(){
url: ajax_url,
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
success:function(result){
alert("Invoice updated")
window.location.reload();
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
});
});

View File

@@ -162,18 +162,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_visa_path %>",

View File

@@ -15,8 +15,8 @@
<%= f.input :api_settings %>
<%= f.input :page_width %>
<%= f.input :page_height %>
<%= f.input :print_copies, input_html: { min: '1', step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision %>
<%= f.input :print_copies, input_html: { min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %>
<%= f.input :delimiter %>
<%= f.input :heading_space %>
</div>
@@ -73,4 +73,8 @@
function greaterThanOne(val){
if(parseInt(val)==0) $("#print_setting_print_copies").val(1);
}
function greaterThanTwo(val){
if(parseInt(val)>2) $("#print_setting_precision").val(2);
}
</script>

View File

@@ -43,6 +43,18 @@
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% total_qty = 0 %>
<% total_price = 0 %>
<% total_amount = 0 %>
@@ -53,9 +65,9 @@
<td><%= result.sale_item_id rescue '-' %></td>
<td><%= result.commissioner.name rescue '-' %></td>
<td><%= result.commission.menu_item.name rescue '-' %></td>
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
<td><%= number_with_precision(result.qty.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.price.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.amount.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
</tr>
<% total_qty += result.qty.to_f %>
@@ -65,9 +77,9 @@
<tr style="border-top: 3px solid grey;">
<td colspan="4"></td>
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
<td><b><%= number_with_precision(total_qty, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(total_price, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
<td></td>
</tr>
</tbody>

View File

@@ -23,6 +23,18 @@
<div class="margin-top-20">
<div class="card ">
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% unless @sale_data.blank? %>
<table class="table table-striped" border="0">
@@ -52,7 +64,7 @@
<td><%= credit.receipt_no rescue '-' %></td>
<td><%= credit.cashier_name rescue '-' %></td>
<td><%= credit.sale.customer.name rescue '-' %></td>
<td><%= credit.payment_amount rescue '-' %></td>
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr>
<% end %>
</tbody>
@@ -123,7 +135,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -44,6 +44,18 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
</tr>
</thead>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% unless @sale_data.empty? %>
<tbody>
@@ -79,37 +91,37 @@
<tr>
<td style='text-align:right;'><%= count %></td>
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
<td style='color:red;text-align:right;'><%= number_with_precision(sale[:void_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:mpu_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:master_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:visa_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:jcb_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:paypar_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision, delimiter: delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision,delimiter:delimiter) rescue '-'%></td>
</tr>
<% count = count + 1 %>
<% end %>
<tr style="font-weight:600;">
<td colspan="3" style='text-align:center;'>Total</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(mpu , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(master, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(visa, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(jcb, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(paypar, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_precision(total, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision,delimiter:delimiter) rescue '-'%></td>
</tr>
<% total_tax = 0 %>
@@ -118,7 +130,7 @@
<% total_tax += tax.tax_amount.to_f %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
@@ -126,7 +138,7 @@
<% net = total - total_tax %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(net, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>

View File

@@ -50,18 +50,30 @@
<th><%= t("views.right_panel.detail.foc_sales") %></th>
</tr>
</thead>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% unless @sale_data.empty? %>
<tbody>
<% @sale_data.each do |sale| %>
<tr>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td><%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr>
<% end %>
@@ -108,11 +120,11 @@
<!--<td><%= payment.sale.customer.name rescue '-' %></td>-->
<td><%= payment.payment_method rescue '-' %></td>
<% if payment.payment_method === 'cash' %>
<td><%= payment.payment_amount - payment.change_amount%> </td>
<td><%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
<%else%>
<td><%= payment.payment_amount%> </td>
<td><%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
<%end%>
<td><%= payment.sale.grand_total rescue '-' %></td>
<td><%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr>
@@ -120,7 +132,7 @@
<%if total>0%>
<tr>
<td colspan="4" style="text-align: right;"><strong >Total </strong></td>
<td colspan="2"><strong><%=total%></strong></td>
<td colspan="2"><strong><%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
</tr>
<%end%>
</tbody>
@@ -189,7 +201,10 @@
var shift = $('#shift_name');
shift.empty();
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';

View File

@@ -58,6 +58,22 @@
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
puts precision
puts "predelidm"
puts delimiter %>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
<% total_tax = 0 %>
@@ -81,31 +97,31 @@
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
<%if result.customer.customer_type == "Takeaway"%>
<td>0.0</td>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%>
<% result.sale_taxes.each do |tax| %>
<td><%= tax.tax_payable_amount rescue '-' %></td>
<td><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<% @sale_taxes.each do |tax| %>
<td><b><%= tax.st_amount.round(2) %></b></td>
<td><b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<% end %>
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(rounding_adj, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
@@ -196,7 +212,10 @@
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){

View File

@@ -45,10 +45,23 @@
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% count = 0 %>
@@ -70,12 +83,12 @@
end %>
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
@@ -85,7 +98,7 @@
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= total %></b>
<b><%= number_with_precision(total, precision:precision,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
@@ -104,30 +117,37 @@
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<td><%= sale.unit_price rescue '-' %></td>
<td><%= sale.grand_total rescue '-' %></td>
<td><%= number_with_precision(sale.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.menu_category_id == key %>
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type != "Discount" && sale.status_type != "foc"
sub_qty += sale.total_item
end %>
<% if count == value %>
<tr>
<td colspan="5">&nbsp;</td>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= sub_total %></span></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<!-- end sub total -->
<% end %>
<!--Other Charges -->
<% if @other_charges.present? %>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
@@ -144,8 +164,8 @@
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item rescue '-' %></td>
<td><%= other.unit_price rescue '-' %></td>
<td><%= other.grand_total rescue '-' %></td>
<td> <%= number_with_precision(other.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
@@ -155,38 +175,38 @@
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= other_sub_total %></span></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= grand_total%></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision,delimiter:delimiter)%></span></td>
</tr>
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= total_item_foc %></span></td>
<td><span><%= number_with_precision(total_item_foc , precision:precision,delimiter:delimiter) %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= total_item_dis %></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision,delimiter:delimiter) %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.foc_sales") %></td>
<td><span><%= @foc_data %></span></td>
<td><span><%= number_with_precision(@foc_data , precision:precision,delimiter:delimiter) %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= @discount_data %></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(@discount_data , precision:precision,delimiter:delimiter) %></span></td>
</tr>
<% @sale_taxes.each do |tax| %>
@@ -202,7 +222,7 @@
<td colspan="5">&nbsp;</td>
<td style="border-top:2px solid grey;">Net Amount</td>
<!-- <td><span class="double_underline"><%= grand_total.to_f - @discount_data.to_f%></span></td> -->
<td style="border-top:2px solid grey;"><%= grand_total.to_f - @discount_data.to_f%></td>
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision,delimiter:delimiter)%></td>
</tr>
<!-- <tr>
<td colspan="5">&nbsp;</td>
@@ -291,12 +311,15 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var selected = '';
var str = '';
var param_shift = '<%= params[:shift_name]%>';
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
console.log(data)

View File

@@ -63,6 +63,18 @@
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% void = 0%>
<% cash = 0%>
<% credit = 0%>
@@ -86,16 +98,16 @@
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result[:cash_sales].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:credit_sales].to_f.to_d rescue '-'%></td>
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision,delimiter:delimiter) %></td>
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result[:other_sales].to_f.to_d rescue '-'%></td>
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td>
<%= sprintf "%.2f",result[:foc_sales].to_f.to_d rescue '-'%>
<%= number_with_precision(result[:foc_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%>
</td>
<td><%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%></td>
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
<% grand_total = result[:grand_total].to_f %>
@@ -114,15 +126,15 @@
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<td><b><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td>
<td><b><%= number_with_precision(card, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
<td><b><%= number_with_precision(g_total, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
</tr>
</tbody>
</table>
@@ -191,7 +203,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -52,6 +52,18 @@
</tr>
</thead>
<tbody>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% total_amount = 0.0 %>
<% grand_total = 0.0 %>
<% rounding_adjustment = 0.0 %>
@@ -61,10 +73,10 @@
<tr>
<td><%= item.receipt_no rescue '-' %> </td>
<td><%= item.receipt_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-' %></td>
<td><%= item.total_amount.to_f rescue '-'%> </td>
<td><%= item.grand_total.to_f rescue '-'%> </td>
<td><%= item.rounding_adjustment.to_f rescue '-' %></td>
<td><%= item.grand_total.to_f + item.rounding_adjustment.to_f rescue '-'%> </td>
<td><%= number_with_precision(item.total_amount.to_f, precision: precision.to_i ,delimiter: delimiter) %> </td>
<td><%= number_with_precision(item.grand_total.to_f , precision: precision.to_i ,delimiter: delimiter) rescue '-'%> </td>
<td><%= number_with_precision(item.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(item.grand_total.to_f + item.rounding_adjustment.to_f , precision: precision.to_i ,delimiter: delimiter) rescue '-'%> </td>
<!-- <td><%= result.sales_status rescue '-' %> </td> -->
<!-- <td><%= item.remarks rescue '-' %> </td> -->
</tr>
@@ -76,10 +88,10 @@
<% end %>
<tr style="border-top:4px double #666;font-weight:600;">
<td colspan="2" style="text-align:center;">Total Void Amount :</td>
<td><%= total_amount rescue '-' %></td>
<td><%= grand_total rescue '-' %></td>
<td><%= rounding_adjustment rescue '-'%></td>
<td colspan="3"><%= grand_rounding_adjustment rescue '-'%></td>
<td><%= number_with_precision(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(rounding_adjustment, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></td>
<td colspan="3"><%= number_with_precision(grand_rounding_adjustment, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></td>
</tr>
</tbody>
</table>
@@ -144,7 +156,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -30,7 +30,7 @@
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.alt_name") %></th>
<th><%= t("views.right_panel.detail.is_available") %></th>
<th><%= t("views.right_panel.detail.order_by") %></th>
<!-- <th><%= t("views.right_panel.detail.order_by") %></th> -->
<th><%= t("views.right_panel.detail.parent") %></th>
<th><%= t("views.right_panel.detail.actions") %></th>
</tr>
@@ -43,7 +43,7 @@
<td><%= link_to settings_menu_category.name, settings_menu_category_path(settings_menu_category) %></td>
<td><%= settings_menu_category.alt_name rescue ''%></td>
<td><%= settings_menu_category.is_available rescue false%></td>
<td><%= settings_menu_category.order_by rescue ''%></td>
<!-- <td><%= settings_menu_category.order_by rescue ''%></td> -->
<td><%= settings_menu_category.parent.name rescue ''%></td>
<td><%= link_to t("views.btn.edit"), edit_settings_menu_category_path(settings_menu_category),:class => 'btn btn-info btn-sm waves-effect' %>
</td></td>
@@ -51,8 +51,8 @@
<% end %>
</tbody>
</table>
<%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
</div>
<%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">

View File

@@ -0,0 +1 @@

20
config/deploy.rb Normal file
View File

@@ -0,0 +1,20 @@
lock "3.10.1"
set :application, "zsai"
set :repo_url, 'git@bitbucket.org:code2lab/sxrestaurant.git'
set :deploy_user, 'deploy'
set :rbenv_type, :global
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :keep_releases, 5
set :linked_files, %w{config/database.yml config/secrets.yml config/puma.rb config/sidekiq.yml config/shops.json}
set :linked_dirs, %w{bin log tmp/puma tmp/pids tmp/cache tmp/sockets vendor/bundle public/system pids sockets}
set :tests, []
set :pty, true

View File

@@ -0,0 +1,9 @@
set :stage, :production
set :server_name, "svr.sxrestaurant.host"
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
server '192.168.1.27', user: 'deploy', roles: %w{web app db}, primary: true
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
set :rbenv_ruby, '2.4.1'
set :rails_env, :production

View File

@@ -1,16 +1,15 @@
iv_key: A30HZdW+iDZA0vM5PAqwgg==
shop_name: 7DdPBxVo8m1xpa5T2kIcWQ==
email: yanaung.nyein@code2lab.com
telephone: 111111
fax: 111111
address: bitp
dbhost: 9+83FZetcbLZi6COG5PbSw==
dbschema: shztSYIsNmM9nlHkR/4exQ==
dbusername: LapN+Geriht8yk866FxNiQ==
dbpassword: QtboWZ4ATE05vvYw6J+Uqw==
api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH
app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA
plan_sku: 001
renewable_date: 2018-12-14
plan_name: Community
iv_key: TP8dIx4nBGzr+tYyKn5+Xw==
shop_name: Osaka
email: wathonaun9@gmail.com
telephone: 09979204288
fax: 09979204288
address: Yangon
dbhost: nk57NaR38B2eSYyron3Nbw==
dbschema: 3orxFaTi0uQhatBqZGiitQ==
dbusername: EtMle9Gr0/PE3NFHHfwo5A==
dbpassword: 86h61/O38GGo64nekz6oeA==
api_token: FVAGMnjVdaScfydXMbMvPPRWnkEwCSuxs
app_token: IoXPdqzbnQWbHsnxLAjMjimnjEJNySOeIo
plan_sku: PyQJ2sk5NZTudqQ2YIU16A==
renewable_date: d/Fk1deU/iPbZFDOdyKsjA==
plan_name: weWOqr1tZ61Av6YKth1lDw==

View File

@@ -12,6 +12,7 @@ scope "(:locale)", locale: /en|mm/ do
#--------- SmartSales Activation ------------#
get 'activate' => 'install#index'
post 'activate' => 'install#activate'
get 'run_sym' => 'sym_control#run'
#--------- Login/Authentication ------------#
get 'auth/:emp_id' => 'home#show', as: :emp_login
@@ -244,7 +245,7 @@ scope "(:locale)", locale: /en|mm/ do
post "/:id", to: "edit#update"
# Pass assigned_order_item_id
get 'print/print/:id', to: "print#print"
post 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary"
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"

View File

@@ -12,12 +12,10 @@
development:
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
sx_provision_url: connect.smartsales.asia/api #provision.zsai.ws/api
server_mode: cloud
sx_provision_url: 192.168.1.49:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api
server_mode: application
cipher_type: AES-256-CBC
sx_key: Wh@t1$C2L
aes_key: <%= ENV['AES_KEY'] %>
aes_iv: <%= ENV['AES_IV'] %>
test:
secret_key_base: 5c92143fd4a844fdaf8b22aba0cda22ef1fc68f1b26dd3d40656866893718ae5e58625b4c3a5dc86b04c8be0a505ec0ebc0be3bf52249a3d1e0c1334ee591cf0
@@ -30,6 +28,4 @@ production:
server_mode: cloud
cipher_type: AES-256-CBC
sx_key: Wh@t1$C2L
aes_key: <%= ENV['AES_KEY'] %>
aes_iv: <%= ENV['AES_IV'] %>

View File

@@ -140,10 +140,11 @@ menu_options = MenuItemOption.create([{option_type: "Oil", name: "Less Oil", val
menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle", value: "Bottle"},{option_type: "Package", name: "Can", value: "can"}])
# #Default Menu Category
# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"})
# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"})
# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"})
# menu_category5 = MenuCategory.create({menu: menu, code:"C001", name: "Extra Time", alt_name: "Extra Time", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
#
# #Default Menu items
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
@@ -162,11 +163,21 @@ menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle
# menu_item_attribute_adult = MenuItemAttribute.create({attribute_type:"person", name: "Adult", value: "adult"})
# menu_item_attribute_child = MenuItemAttribute.create({attribute_type:"person", name: "Child", value: "child"})
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" })
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" })
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
# menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" })
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
# menu_item_attribute_30_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "30 min", value: "30_min"})
# menu_item_attribute_60_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "1 hrs", value: "60_min"})
# menu_category1_menu_item2 = SimpleMenuItem.create({item_code:"Ext30", name: "30 minutes", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['1']", created_by: "System" })
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti30", menu_item: menu_category1_menu_item2, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
# menu_category1_menu_item3 = SimpleMenuItem.create({item_code:"Ext60", name: "1 hour", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['2']", created_by: "System" })
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti60", menu_item: menu_category1_menu_item3, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
# menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" })
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
# END
menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"})