Pull from master

This commit is contained in:
San Wai Lwin
2018-05-25 16:22:30 +06:30
parent f906134fbf
commit 578c14ccc3
26 changed files with 536 additions and 358 deletions

View File

@@ -1012,12 +1012,14 @@ $(function() {
//calculate subtotal
function calculate_sub_total(){
var total_price = 0;
var total_qty = 0;
var taxable_amount = 0;
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
total_qty += qty;
total_price += qty*unit_price;
});
var fixed_total_price = parseFloat(total_price).toFixed(2);
@@ -1026,6 +1028,9 @@ $(function() {
$('#sub_total').empty();
$('#sub_total').append(fixed_total_price);
$('#total_qty').empty();
$('#total_qty').append(total_qty);
if (item_row.length > 0) {
$('.create').removeAttr("disabled", false);
}else{
@@ -1432,7 +1437,8 @@ $(function() {
}
}
row = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
row = '<div class="col-md-3">'
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
+'<div class="col-md-10 " style="padding:0px !important;">'+ menu_items[field].name +'</div>'
+"<div class='col-md-2 "+menu_item_box+" ' data-item-code='"
@@ -1466,7 +1472,8 @@ $(function() {
+'<div class="card-footer custom-card-footer" style="opacity:0.7">'
+'<span>'+ price +'</span>'
+'</div>'
+'</div>';
+'</div>'
+'</div>'; ;
$('.menu_items_list').append(row);
}
//end instances in menu-items alest 1 instance

View File

@@ -1,7 +1,6 @@
$(document).ready(function() {
$(".processitems").click(function(event){
event.preventDefault();
console.log($(this).data("id"));
var item = $(this).data("id");
$(this).toggleClass("opi_selected");
@@ -13,7 +12,6 @@ $(document).ready(function() {
console.log($(this).data("id"));
var group_id = $(this).data("id");
var selector = "#" + group_id + " li div";
console.log ($(selector));
$(selector).removeClass("opi_selected");
$(selector).addClass("opi_selected");
@@ -25,7 +23,6 @@ $(document).ready(function() {
console.log($(this).data("id"));
var group_id = $(this).data("id");
var selector = "#" + group_id + " li div";
console.log ($(selector));
$(selector).removeClass("opi_selected");
});
@@ -36,7 +33,6 @@ $(document).ready(function() {
var items = new Array();
selected_div = $(".opi_selected");
$.each( selected_div, function( key, value ) {
console.log($(value).attr("data-id"));
items.push($(value).attr("data-id"));
});

View File

@@ -12,6 +12,7 @@ section .content{
}
.custom-card {
border: 2px solid rgba(0, 0, 0, 0.125) !important;
margin-bottom: 7px !important;
}
.custom-card-footer{
padding:0.35rem 1.25rem !important;
@@ -72,16 +73,26 @@ section .content{
.nav-tabs {
background-color: #ccc;
}
.nav-tabs li a.active{
border-bottom:1px solid #54A5AF !important;
}
.nav-tabs .nav-link {
padding: 0.7286rem 0.2575;
border-top-left-radius: 0rem;
border-top-right-radius: 0rem;
}
.nav-tabs .nav-link:focus, .nav-tabs .nav-link:hover {
color: #54A5AF #54A5AF #54A5AF;
}
.nav-tabs .nav-link.active:focus, .nav-tabs .nav-link.active:hover {
background-color: #009688;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #a1aade;
border-left: 6px solid #111;
color:#54A5AF;
font-weight: bold;
background-color: #fff !important;
border-left: 6px solid #54A5AF !important;
color: #54A5AF !important;
font-weight: bold !important;
border-color: #fff #fff #fff #54A5AF;
}
.sub_category_list{

View File

@@ -462,4 +462,9 @@ iframe {
/* section class for webview */
.section-margin {
margin-top: -50px;
}
.tax-btn-box {
width: 230px;
height: 80px;
}

View File

@@ -63,7 +63,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation = params
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if flag #&& ENV["SERVER_MODE"] != 'cloud'
if flag
shop = Shop.find_by_id(1)
if !shop.shop_code.nil?
shop_code = shop.shop_code

View File

@@ -117,6 +117,9 @@ class Api::OrdersController < Api::ApiController
end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
end
# # for parallel order
# remoteIP = ""
# begin

View File

@@ -18,8 +18,8 @@ class Api::SurveyController < Api::ApiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
if params[:id]
survey = Survey.find(params[:id])
if params[:survey][:id]
survey = Survey.find(params[:survey][:id])
else
survey = Survey.new
end

View File

@@ -48,8 +48,16 @@ class Origami::OrderReservationController < BaseOrigamiController
end
def send_status
response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],params[:status],params[:waiting_time],params[:min_type],params[:reason])
order_reservation = OrderReservation.find_by_transaction_ref(params[:ref_no])
if !order_reservation.nil?
if !ShiftSale.current_shift.nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected')
response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],params[:status],params[:waiting_time],params[:min_type],params[:reason])
else
response = { status: false, message: 'No current shift open for this employee!'}
end
else
response = { status: false, message: 'There is no order for '+params[:ref_no]+'!'}
end
render :json => response
end

View File

@@ -96,6 +96,8 @@ class Origami::PaymentsController < BaseOrigamiController
cash = params[:cash]
sale_id = params[:sale_id]
member_info = nil
type = params[:type]
tax_type = params[:tax_type]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
@@ -298,11 +300,18 @@ class Origami::PaymentsController < BaseOrigamiController
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
@tax_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc.id)
@account_arr.push(account)
# @account_arr.push(account)
@tax_arr.push(account.name)
end
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
if !sale_taxes.empty?
sale_taxes.each do |sale_tax|
@account_arr.push(sale_tax)
end
end
rebate = MembershipSetting.find_by_rebate(1)
# get member information
if @customer.membership_id != nil && rebate
@@ -571,4 +580,15 @@ class Origami::PaymentsController < BaseOrigamiController
render :json => result.to_json
# render :json => {status: true}
end
#changable tax for sale
def change_tax
sale_id = params[:sale_id]
order_source = params[:cashier_type]
tax_type = params[:tax_type]
sale = Sale.find(sale_id)
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount,nil,order_source,tax_type)
render json: JSON.generate({:status => true})
end
end

View File

@@ -83,54 +83,66 @@ class Origami::ProductCommissionsController < BaseOrigamiController
def set_commissioner_to_sale_item
# byebug
deselect = false
sale_item_id = params[:sale_item_id]
deselect = false
type = nil
sale_item_id = params[:sale_item_id]
commissioner_id = params[:commissioner_id]
@sale_item = SaleItem.find(sale_item_id)
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
@sale_item = SaleItem.find(sale_item_id)
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
# @commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.item_code, true).take
Commission.all.each do |com|
if com.product_code.include? @menu_item.item_code && com.is_active == true
@commission = Commission.find(com.id)
break
Commission.all.active.each do |com|
if com.product_code != "[]"
if com.product_code.to_s.include? @menu_item.item_code
@commission = Commission.find(com.id)
break
end
end
end
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
@product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take
if !@commission.nil? && @commissioner.commission_id == @commission.commission_id
if !@product_commission.nil?
if @product_commission.commissioner_id == @commissioner.id
@product_commission.destroy
deselect = true
else
@product_commission.commissioner_id = @commissioner.id
deselect = false
end
else
@product_commission = ProductCommission.new
@product_commission.product_code = @menu_item.item_code
@product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
unless @commission.nil?
@product_commission.commission_id = @commission.id
if @commission.commission_type == 'Percentage'
@product_commission.price = @sale_item.unit_price * (@commission.amount / 100.0)
@product_commission.amount = @product_commission.price * @sale_item.qty
elsif @commission.commission_type == 'Net Amount'
@product_commission.price = @commission.amount
@product_commission.amount = @product_commission.price * @sale_item.qty
if @product_commission.commissioner_id == @commissioner.id
@product_commission.destroy
deselect = true
type = "remove"
# render json: {status: true,deselect:deselect, message: "Remove Success !"}
else
@product_commission.commissioner_id = @commissioner.id
deselect = false
end
end
@product_commission.commissioner_id = @commissioner.id
@product_commission.qty = @sale_item.qty
@product_commission.sale_id = @sale_item.sale_id
@product_commission.sale_item_id = @sale_item.sale_item_id
else
@product_commission = ProductCommission.new
@product_commission.product_code = @menu_item.item_code
@product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
unless @commission.nil?
@product_commission.commission_id = @commission.id
if @commission.commission_type == 'Percentage'
@product_commission.price = @sale_item.unit_price * (@commission.amount / 100.0)
@product_commission.amount = @product_commission.price * @sale_item.qty
elsif @commission.commission_type == 'Net Amount'
@product_commission.price = @commission.amount
@product_commission.amount = @product_commission.price * @sale_item.qty
end
end
@product_commission.commissioner_id = @commissioner.id
@product_commission.qty = @sale_item.qty
@product_commission.sale_id = @sale_item.sale_id
@product_commission.sale_item_id = @sale_item.sale_item_id
end
if @product_commission.save
render json: {status: true, deselect: deselect}
message = "Success !"
if type == "remove"
message = "Remove Success !"
end
render json: {status: true, deselect:deselect,type:type,message: message}
else
render json: {status: false, deselect: deselect}
render json: {status: false, deselect:deselect,type:type,message: "No Commission"}
end
else
render json: {status: false, deselect:deselect,type:type,message: "No Commission"}
end
end

View File

@@ -71,6 +71,7 @@ class Ability
can :rounding_adj, :payment
can :foc, :payment
can :print, :payment
can :change_tax, :payment
can :move_dining, :movetable
can :moving, :movetable
@@ -154,6 +155,7 @@ class Ability
can :rounding_adj, :payment
can :foc, :payment
can :print, :payment
can :change_tax, :payment
can :move_dining, :movetable
can :moving, :movetable
@@ -249,6 +251,7 @@ class Ability
can :rounding_adj, :payment
can :print, :payment
can :foc, :payment
can :change_tax, :payment
can :manage, Commission
can :manage, Commissioner

View File

@@ -10,7 +10,7 @@ class Commission < ApplicationRecord
# validations
validates_presence_of :name, :commission_type, :amount
scope :active, -> {where(is_active: true)}
private
def generate_custom_id
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')

View File

@@ -301,13 +301,6 @@ class Order < ApplicationRecord
end
# end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
#send order items and send to order queue
def send_order_broadcast(booking)
@@ -317,10 +310,10 @@ class Order < ApplicationRecord
#Send to background job for processing
# OrderBroadcastJob.perform_later(table,type)
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
@@ -485,68 +478,74 @@ class Order < ApplicationRecord
end
#Process order items and send to order queue
# def process_order_queue
# print_status = nil
# cup_status = nil
def self.process_order_queue(order_id,table_id,source)
print_status = nil
cup_status = nil
# #Send to background job for processing
# order = Order.find(self.id)
# sidekiq = Lookup.find_by_lookup_type("sidekiq")
#Send to background job for processing
order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
# if ENV["SERVER_MODE"] != 'cloud'
# cup_status = `#{"sudo service cups status"}`
# print_status = check_cup_status(cup_status)
# end
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
# if print_status
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# else
# if ENV["SERVER_MODE"] != 'cloud'
# cup_start = `#{"sudo service cups start"}`
# cup_status = `#{"sudo service cups status"}`
# print_status = check_cup_status(cup_status)
# end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
# if print_status
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# else
# if ENV["SERVER_MODE"] != 'cloud'
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
# msg = ' Print Error ! Please contact to service'
# ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
# end
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# end
# end
# end
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
end
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end
end
end
def self.check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
private

View File

@@ -61,9 +61,10 @@ class ProductCommission < ApplicationRecord
end
def self.get_transaction(from, to, commissioner)
transaction = all
transaction = ProductCommission.select("product_commissions.*,menu_items.name as porduct_name")
.joins("join menu_items on menu_items.item_code = product_commissions.product_code")
if !from.nil? && !to.nil?
transaction = transaction.where('updated_at between ? and ?', from, to)
transaction = transaction.where('product_commissions.updated_at between ? and ?', from, to)
end
if commissioner != 0
transaction = transaction.where(commissioner_id: commissioner)

View File

@@ -131,7 +131,6 @@ class Sale < ApplicationRecord
if order_source.nil?
order_source = order.source
end
puts "compute source"
compute(order_source)
#Update the order items that is billed
@@ -346,7 +345,7 @@ class Sale < ApplicationRecord
end
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil)
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
sale = Sale.find(sale_id)
sales_items = sale_itemss
@@ -365,7 +364,7 @@ class Sale < ApplicationRecord
end
end
compute_tax(sale, total_taxable, total_discount, order_source)
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
sale.total_amount = subtotal_price
sale.total_discount = total_discount
@@ -412,7 +411,7 @@ class Sale < ApplicationRecord
end
# Tax Re-Calculte
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil)
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
shop = Shop.first();
#if tax is not apply create new record
@@ -422,6 +421,7 @@ class Sale < ApplicationRecord
end
total_tax_amount = 0
tax_incl_exec = "exclusive"
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(sale.customer_id)
@@ -429,11 +429,9 @@ class Sale < ApplicationRecord
if sale.payment_status != 'foc'
tax_profiles.each do |tax|
# customer.tax_profiles.each do |cus_tax|
# if cus_tax.to_i == tax.id
if tax.group_type.to_s == order_source.to_s
if customer.customer_type.downcase == 'takeaway'
if tax.name.downcase == 'commercial tax'
if tax_type
if tax_type.to_s == tax.name.to_s || tax_type == 'all'
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
@@ -442,6 +440,7 @@ class Sale < ApplicationRecord
total_tax = total_taxable - total_discount
#include or execulive
if tax.inclusive
tax_incl_exec = "inclusive"
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
@@ -453,39 +452,41 @@ class Sale < ApplicationRecord
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
else
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
# customer.tax_profiles.each do |cus_tax|
# if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
# substract , to give after discount
total_tax = total_taxable - total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save
# substract , to give after discount
total_tax = total_taxable - total_discount
#include or execulive
if tax.inclusive
tax_incl_exec = "inclusive"
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save
# end
# end
end
end
# end
# end
end
end
sale.tax_type = tax_incl_exec
sale.total_tax = total_tax_amount
end
@@ -500,6 +501,7 @@ class Sale < ApplicationRecord
end
total_tax_amount = 0
tax_incl_exec = "exclusive"
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
@@ -510,11 +512,9 @@ class Sale < ApplicationRecord
#Create new tax records
tax_profiles.each do |tax|
# customer.tax_profiles.each do |cus_tax|
# if cus_tax.to_i == tax.id
if tax.group_type.to_s == order_source.to_s
if customer.customer_type.downcase == 'takeaway'
if tax.name.downcase == 'commercial tax'
# customer.tax_profiles.each do |cus_tax|
# if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
@@ -523,6 +523,7 @@ class Sale < ApplicationRecord
total_tax = total_taxable - self.total_discount
#include or execulive
if tax.inclusive
tax_incl_exec = "inclusive"
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
@@ -538,37 +539,12 @@ class Sale < ApplicationRecord
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
else
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
# substract , to give after discount
total_tax = total_taxable - self.total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
# end
# end
end
# end
# end
end
self.total_tax = total_tax_amount
self.tax_type = tax_incl_exec
self.total_tax = total_tax_amount
end
def product_get_unit_price(item_code)

View File

@@ -303,12 +303,16 @@ class ReceiptBillA5Pdf < Prawn::Document
end
if sale_data.sale_taxes.length > 0
incl_tax = ""
if sale_data.tax_type == "inclusive"
incl_tax = "Incl."
end
sale_data.sale_taxes.each do |st|
move_down line_move
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
text "#{ st.tax_name } (#{incl_tax} #{ 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

View File

@@ -290,12 +290,17 @@ class ReceiptBillPdf < Prawn::Document
end
if sale_data.sale_taxes.length > 0
incl_tax = ""
if sale_data.tax_type == "inclusive"
incl_tax = "Incl."
end
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ st.tax_name } ( #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_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

View File

@@ -53,7 +53,7 @@ json.id item.id
json.code item.item_code
json.name item.name
json.alt_name item.alt_name
if !request_url.nil? && request_url != ''
if !request_url.nil? && request_url != '' && !item.image_path.url.nil?
json.image request_url + item.image_path.url.to_s
else
json.image item.image_path.url

View File

@@ -101,7 +101,7 @@
<div class="card">
<div class="card-block" style="">
<div class="card-text" id="custom-slimscroll">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 0.5rem;">
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
@@ -255,9 +255,9 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td style="padding:2px;" width="5%"></td>
<td style="padding:2px;" width="15%"></td>
<td style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
<td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table>

View File

@@ -6,11 +6,12 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
order_by = Lookup.find_by_lookup_type("order_by")
if !order_by.nil? && order_by.value == "name"
categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
else
categories = menu.menu_categories
end
# if !order_by.nil? && order_by.value == "name"
# categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
# else
# categories = menu.menu_categories
# end
categories = menu.menu_categories
json.categories categories do |category|
menu_category = MenuCategory.find_by_menu_category_id(category.id)

View File

@@ -1,4 +1,4 @@
`<div class="container-fluid">
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
@@ -97,16 +97,23 @@
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
</strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
<td class="charges-name">
<strong>
<% if !@account_arr.empty? %>
Tax
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.tax_name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
</td>
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
@@ -536,6 +543,61 @@
</div>
</div>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body">
<% if !@tax_arr.empty? %>
<% if @tax_arr.count > 1 %>
<div class="row text-center">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
<% @i = 0
@tax_arr.each do |tax| %>
<%= tax %>
<% if @tax_arr.count != @i+1%>
+ <% @i =+1 %><br>
<%end%>
<% end %>
</button>
</div>
<% @tax_arr.each_with_index do |tax, tax_index| %>
<% if (tax_index+1)%2 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
<%= tax %>
</button>
</div>
<% end %>
<% else %>
<div class="row clearfix"></div>
<div class="row text-center">
<% @tax_arr.each do |tax| %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
</div>
<% end %>
<% end %>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
</div>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content">
<h3>Card Tap</h3>
@@ -681,6 +743,8 @@ var customer_name = "<%= @customer.name %>";
var credit = $('#credit').text();
var card = $('#card').text();
var tax_type = $("input:radio[name=tax_type]:checked").val();
if (credit <= 0) {
calculate_member_discount(sale_id);
}
@@ -689,7 +753,7 @@ var customer_name = "<%= @customer.name %>";
$('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
@@ -1346,4 +1410,41 @@ var customer_name = "<%= @customer.name %>";
}
});
}
/* Start function for tax changable */
$(".change_tax").on("click",function(){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var cashier_type = '<%= @cashier_type %>';
var sale_id = $('#sale_id').text();
console.log(type);
swal({
title: "Alert",
text: "Are you sure want to change tax?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, change it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment';
}
}
});
}else{
swal.close();
}
});
});
/* End function for tax changable */
</script>

View File

@@ -126,7 +126,9 @@
$('.sale_item').on('click', function () {
$('#order-items-table tr').siblings().css( "background-color", "white" );
this.style.backgroundColor = 'lightgray';
$('#order-items-table tr').siblings().css( "color", "black" );
this.style.backgroundColor = 'blue';
this.style.color = 'white';
var sale_item_id = this.getAttribute('data-sale-item');
var ajax_url = "/origami/select_sale_item";
selected_sale_item = sale_item_id;
@@ -179,11 +181,17 @@
url: ajax_url,
data: param_data,
success: function (result) {
console.log(selected_sale_item + "," +commissioner_id);
console.log(result);
if(result.deselect == true){
$(commissioner).removeClass("blue").addClass("green");
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text('-');
}
if(result.status == true){
swal("Information",result.message,"success");
}else{
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text('-');
swal("Opps",result.message,"warning");
}
}
});
};

View File

@@ -64,7 +64,7 @@
<td><%= result.sale_id rescue '-' %></td>
<td><%= result.sale_item_id rescue '-' %></td>
<td><%= result.commissioner.name rescue '-' %></td>
<td><%= result.commission.menu_item.name rescue '-' %></td>
<td><%= result.porduct_name 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>

View File

@@ -1,158 +1,173 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 ">
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="card" >
<div class="body table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th colspan="15"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.mpu_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.master_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.visa_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.jcb_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.unionpay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.alipay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.paymal_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.dinga_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.redeem_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
</tr>
</thead>
<% unless @sale_data.empty? %>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="card" style="width:129%;">
<div class="body table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th colspan="15"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.mpu_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.master_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.visa_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.jcb_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.unionpay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.alipay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.paymal_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.dinga_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.redeem_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<tbody>
<% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% unionpay = 0 %>
<% alipay = 0 %>
<% paymal = 0 %>
<% dinga = 0 %>
<% junctionpay = 0 %>
<% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
<% total = 0 %>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
<% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% unionpay += sale[:unionpay_amount] %>
<% alipay += sale[:alipay_amount] %>
<% paymal += sale[:paymal_amount] %>
<% dinga += sale[:dinga_amount] %>
<% junctionpay += sale[:junctionpay_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %>
<% rounding_adj += sale[:rounding_adj].to_f %>
<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[:unionpay_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:dinga_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:junctionpay_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>
</tr>
<% count = count + 1 %>
<% end %>
</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? %>
<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>
</tr>
<tbody>
<% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% unionpay = 0 %>
<% alipay = 0 %>
<% paymal = 0 %>
<% dinga = 0 %>
<% junctionpay = 0 %>
<% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
<% total = 0 %>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
<% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% unionpay += sale[:unionpay_amount] %>
<% alipay += sale[:alipay_amount] %>
<% paymal += sale[:paymal_amount] %>
<% dinga += sale[:dinga_amount] %>
<% junctionpay += sale[:junctionpay_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% old_grand_total += sale[:old_grand_total].to_f %>
<% rounding_adj += sale[:rounding_adj].to_f %>
<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[:unionpay_amount]),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:dinga_amount]),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:junctionpay_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: 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(sale[:grand_total].to_f + 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='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f),delimiter => ',') rescue '-'%></td>
<% total_tax = 0 %>
<% net = 0 %>
<% unless @tax.empty? %>
<% @tax.each do |tax| %>
<% 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 colspan="2">&nbsp;</td>
</tr>
</tr>
<% count = count + 1 %>
<% end %>
<% end %>
<% net = grand_total %>
<% net = net - rounding_adj%>
<% net = net - 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 colspan="2">&nbsp;</td>
</tr>
<% end %>
</tbody>
<% end %>
</table>
<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",unionpay),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",alipay),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paymal),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",dinga),delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",junctionpay),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(discount,delimiter => ',') rescue '-'%>)</td>
<!-- <td style='text-align:right;'><%= number_with_delimiter(total,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_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></td>
</tr>
<% total_tax = 0 %>
<% net = 0 %>
<% unless @tax.empty? %>
<% @tax.each do |tax|
total_tax += tax.tax_amount.to_f %>
<tr style="font-weight:600;">
<td colspan="17" 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 colspan="2">&nbsp;</td>
</tr>
<% end %>
<% end %>
<% net = grand_total %>
<% net = net - rounding_adj%>
<% net = net - total_tax %>
<tr style="font-weight:600;">
<td colspan="17" 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 colspan="2">&nbsp;</td>
</tr>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -199,6 +199,8 @@ scope "(:locale)", locale: /en|mm/ do
post 'payment/junctionpay' => 'junctionpay#create'
post 'payment/dinga' => 'dinga#create'
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
get 'sale/:sale_id/:type/payment/others_payment/MPU' => "mpu#index"

View File

@@ -15,18 +15,19 @@ namespace :clear do
ShiftSale.delete_all
PaymentJournal.delete_all
Survey.delete_all
ProductCommission.delete_all
DiningFacility.update_all(status:'available')
CashierTerminal.update_all(is_currently_login: 0)
SeedGenerator.where("id > 1").update(:current => 0, :next => 0)
Receipt.delete_all
ReceiptDetail.delete_all
# Receipt.delete_all
# ReceiptDetail.delete_all
OrderReservation.delete_all
OrderReservationItem.delete_all
Delivery.delete_all
puts "Clear Data Done."
end
desc "Clear Menu"
desc "Clear-- Menu"
task :menu => :environment do