Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into ui_ux_changes

This commit is contained in:
phyusin
2018-03-30 15:29:26 +06:30
35 changed files with 1024 additions and 99 deletions

View File

@@ -344,7 +344,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
if(jobj.STATUS == "Approved"){
$.ajax({type: "POST",
url: "/origami/payment/"+payment_type,
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id,
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM,
success:function(result){
if(result){
swal({

View File

@@ -84,6 +84,17 @@ class Api::PaymentsController < ActionController::API
sale_payment.payment_reference = params[:payment_reference]
#TODO: implement paypar implementation
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
when "JunctionPay"
sale_payment.payment_method = "JunctionPay"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:vochure_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
when "alipay"
sale_payment.payment_method = "alipay"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
end
end
end

View File

@@ -0,0 +1,77 @@
class Origami::AlipayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
# limit alipay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = 0
@alipaycount = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_alipay = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "alipay"
@alipaycount = @alipaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_alipay = total - @alipaycount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
# 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)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -95,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -53,6 +53,7 @@ class Origami::JcbController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -66,7 +67,7 @@ class Origami::JcbController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no)
end
end

View File

@@ -50,6 +50,7 @@ class Origami::MasterController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -63,7 +64,7 @@ class Origami::MasterController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no)
end
end

View File

@@ -51,6 +51,7 @@ class Origami::MpuController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -64,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
end
end

View File

@@ -113,8 +113,6 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
#end rounding adjustment
puts "sale"
puts saleObj.to_json
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
@@ -228,6 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@alipaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@@ -348,6 +347,8 @@ class Origami::PaymentsController < BaseOrigamiController
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
elsif spay.payment_method == "alipay"
@alipaycount += spay.payment_amount
end
end
end

View File

@@ -79,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -48,6 +48,7 @@ class Origami::UnionpayController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -62,7 +63,7 @@ class Origami::UnionpayController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
end
end

View File

@@ -48,6 +48,7 @@ class Origami::VisaController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -62,7 +63,7 @@ class Origami::VisaController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no)
end
end

View File

@@ -48,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else

View File

@@ -0,0 +1,128 @@
class Origami::WasteSpoileController < BaseOrigamiController
def waste_and_spoilage
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
sale.payment_status = remark
sale.sale_status = remark
sale.save
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
# add to sale item with foc
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
sale.sale_items.each do|item|
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
item.status = remark
item.remark = remark
item.save
end
if sale.bookings[0].dining_facility_id.to_i > 0
table_avaliable = true
table_count = 0
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end
# FOr Sale Audit
action_by = current_user.name
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,remark )
# For Print
member_info = nil
rebate_amount = nil
current_balance = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
end
end
if bookings[0].dining_facility_id.to_i > 0
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
aoi.delivery_status = 1
aoi.save
end
end
end
end
end

View File

@@ -0,0 +1,19 @@
class Reports::WasteAndSpoilageController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
@sale_type = params[:sale_type]
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls
end
end
end

View File

@@ -179,6 +179,11 @@ class Ability
can :remove_all_discount, :discount
can :member_discount, :discount
can :move_dining, :movetable
can :moving, :movetable
can :move_dining, :moveroom
can :manage, Customer
can :manage, DiningQueue

View File

@@ -950,7 +950,7 @@ def self.get_menu_item_query(order_by)
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
" LEFT JOIN sales s ON s.sale_id = si.sale_id")
.where("(CASE WHEN s.sale_status IS NOT NULL THEN s.sale_status='completed' ELSE 1 END)")
.group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END)")
.group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END)")
.order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}")
end
#product sale report query
@@ -1109,6 +1109,16 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
return all_total,sale_type
end
def self.get_wastes_and_spoilages(from,to,status)
if status == "spoile"
type = "and sales.sale_status = 'spoile'"
else
type = "and sales.sale_status = 'waste'"
end
query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to)
.group("sales.receipt_no")
end
# def self.get_separate_tax(from,to,payment_method=nil)
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")

View File

@@ -38,7 +38,8 @@ class SaleItem < ApplicationRecord
sale_item.product_alt_name = item.product_alt_name
sale_item.account_id = item.account_id
sale_item.status = type
if type == "foc" || type == "promotion" || type == "void"
sale_item.remark = type
if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile"
sale_item.qty = qty * (-1)
else
sale_item.qty = qty

View File

@@ -51,6 +51,8 @@ class SalePayment < ApplicationRecord
payment_status = foc_payment
when "JunctionPay"
payment_status = junction_pay_payment
when "alipay"
payment_status = external_terminal_card_payment(:alipay)
else
puts "it was something else"
end
@@ -230,7 +232,7 @@ class SalePayment < ApplicationRecord
payment_status = false
self.payment_method = method
self.payment_amount = self.received_amount
self.payment_reference = self.card_payment_reference
# self.payment_reference = self.card_payment_reference
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
@@ -418,7 +420,7 @@ class SalePayment < ApplicationRecord
bookings.each do |tablebooking|
if tablebooking.booking_status != 'moved'
if tablebooking.sale_id
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste'
status = false
sale_count += 1
else

View File

@@ -144,6 +144,9 @@
<li>
<a href="<%= reports_void_sale_index_path %>">Void Sales</a>
</li>
<li>
<a href="<%= reports_waste_and_spoilage_index_path %>">Wastes & Spoilages</a>
</li>
<li>
<a href="<%= reports_payment_method_index_path %>">Payment Method</a>
</li>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -0,0 +1,258 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
<li class="breadcrumb-item active"><%= t("views.btn.alipay") %></li>
<span class="float-right">
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
</span>
</ol>
</div> -->
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-5">
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_alipay = @can_alipay +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @can_alipay %>" data-member-value="">
</div>
<hr>
</div>
<% if @alipaycount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Recent Alipay paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@alipaycount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label>
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
<div class=" m-t-10 p-l-20">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left green" data-type="nett" >Nett</div>
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom m-l-5">
<div class="pay purple left" id="alipay_pay">Pay</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1 col-lg-1 col-sm-1">
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"><i class="material-icons m-t--5">reply</i> Back </button>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_alipay %>") - parseFloat(localStorage.getItem("cash")));
}
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'Alipay is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment/others_payment";
});
}
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#alipay_pay').on('click',function(){
var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
var cashier_type = "<%= @cashier_type %>";
$("#reference_no_Err").html("");
if(reference_no.length > 0){
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){
// }
// });
// }
//end member discount
if(bank_integration == '1'){
pay_withBank("SALE", "alipay", amount, sale_id, receipt_no,cashier_type);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_alipay_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment";
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
}
}else{
$("#reference_no_Err").html("can't be blank");
}
})
</script>

View File

@@ -26,7 +26,7 @@
</div>
<% end %>
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
<% path ="/origami/#{@sale_id}/customers" %>
<% path ="/origami/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">

View File

@@ -488,6 +488,11 @@
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
@@ -573,6 +578,30 @@
</div>
</div>
</div>
<div class="modal fade" id="waste_spoileModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="waste_spoileModalLabel">Are you sure Waste or Spoile ?</h4>
</div>
<div class="modal-body">
<div class="row p-r-20">
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')"><strong>Waste</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')"><strong>Spoile</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-blue waves-effect" data-dismiss="modal"><strong>CLOSE</strong></button>
</div>
</div>
</div>
<div class="modal-footer ">
</div>
</div>
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function () {
@@ -737,19 +766,19 @@
});
// click select option icon for add
$(document).on('click', '.payment_btn', function(event){
active = $(this).hasClass('selected-payment');
value = $(this).data('value');
type = $(this).data('type');
group = $(this).data('group');
payments = $(".payment_btn");
$(document).on('click', '.payment_btn', function(event){
active = $(this).hasClass('selected-payment');
value = $(this).data('value');
type = $(this).data('type');
group = $(this).data('group');
payments = $(".payment_btn");
if (active) {
$(this).removeClass('selected-payment');
}else{
$(this).addClass('selected-payment');
}
}); //End selecct attribute buttom
if (active) {
$(this).removeClass('selected-payment');
}else{
$(this).addClass('selected-payment');
}
}); //End selecct attribute buttom
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
@@ -1014,4 +1043,34 @@
});
return attribute_arr;
}
function waste_and_spoilage(remark) {
swal({
title: "Alert",
text: "Are you sure want to " + remark +" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, " +remark+ " it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage';
$.ajax({
type: 'POST',
url: url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) {
console.log(result)
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/origami/';
}
});
}
});
}
</script>

View File

@@ -182,103 +182,125 @@
<div class="card-title m-l-5 m-r-5">
<!-- mpu -->
<% if @other != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<div class="row payment others-color">
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<% if @other != 0.0 %>
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- paypar -->
<% if @ppamount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<% if @ppamount != 0.0 %>
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<% end %>
<!-- Visa -->
<% if @visacount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% if @visacount != 0.0 %>
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<% end %>
<!-- JCB -->
<% if @jcbcount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% if @jcbcount != 0.0 %>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<% end %>
<!-- Master -->
<% if @mastercount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% if @mastercount != 0.0 %>
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<% end %>
<!-- <br> -->
<!-- UNIONPAY -->
<% if @unionpaycount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% if @unionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Alipay -->
<% if @alipaycount != 0.0 %>
<div class="row payment others-color">
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">Alipay</div>
<% if @alipaycount != 0.0 %>
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="alipaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Junction Pay -->
<% if @junctionpaycount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">JUNCTION PAY</div>
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<% end %>
<div class="col-md-5"></div>
<div class="col-md-3">JUNCTION PAY</div>
<div class="col-md-4" id="junctionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% if @junctionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="junctionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<% end %>
<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'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
@@ -585,6 +607,9 @@ var customer_name = "<%= @customer.name %>";
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Alipay" && $('#alipaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Alipay Payment","warning");
}
else if(payment_type == "JUNCTIONPAY" && $('#junctionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
@@ -867,8 +892,9 @@ var customer_name = "<%= @customer.name %>";
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var unionpay1 = $('#unionpaycount').text();
var alipay1 = $('#alipaycount').text();
var junctionpay1 = $('#junctionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(junctionpay1);
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1);
var total = $('#amount_due').text();
var amt = 0;
<% if precision.to_i > 0 %>;
@@ -896,9 +922,10 @@ var customer_name = "<%= @customer.name %>";
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var unionpay = $('#unionpaycount').text();
var alipay = $('#alipaycount').text();
var junctionpay = $('#junctionpaycount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(junctionpay)
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay)
var result = parseFloat(amount_due) - parseFloat(total);
<% if precision.to_i > 0 %>
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));

View File

@@ -450,10 +450,11 @@
<!-- <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>
<% if current_login_employee.role != "waiter" %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button>
@@ -512,6 +513,32 @@
</div>
</div>
</div>
<div class="modal fade" id="waste_spoileModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="waste_spoileModalLabel">Are you sure Waste or Spoile ?</h4>
</div>
<div class="modal-body">
<div class="row p-r-20">
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')"><strong>Waste</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')"><strong>Spoile</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-blue waves-effect" data-dismiss="modal"><strong>CLOSE</strong></button>
</div>
</div>
</div>
<div class="modal-footer ">
</div>
</div>
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function(){
@@ -979,4 +1006,34 @@ $('#add_invoice').on('click',function(){
});
return attribute_arr;
}
function waste_and_spoilage(remark) {
swal({
title: "Alert",
text: "Are you sure want to " + remark +" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, " +remark+ " it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage';
$.ajax({
type: 'POST',
url: url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) {
console.log(result)
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/origami/';
}
});
}
});
}
</script>

38
app/views/reports/product_sale/index.html.erb Executable file → Normal file
View File

@@ -45,41 +45,58 @@
<th><%= t("views.right_panel.detail.code") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<!-- <th><%= t("views.right_panel.detail.unit_price") %></th> -->
<th><%= t("views.right_panel.detail.total") %></th>
</tr>
</thead>
<tbody id="tbd_data">
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% cate_arr = Array.new %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_item = {} %>
<% total_data = {} %>
<% @sale_data.each do |sale|
if !total_item.has_key?(sale.item_code)
total_item[sale.item_code] = sale.total_item
total_data[sale.item_code] = sale.grand_total
else
if sale.status_type == "void"
total_item[sale.item_code] += sale.total_item
end
if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc"
total_data[sale.item_code] += sale.grand_total
end
end
end %>
<% @sale_data.each do |sale| %>
<% grand_total += sale.grand_total %>
<% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if !sale.status_type %>
<% if sale.status_type != "Discount" && sale.price.to_f >= 0 %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<% cate_arr = Array.new %>
<% if sale.total_item > 0 %>
<% cate_arr = Array.new %>
<% end %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
<td><%= total_item[sale.item_code] rescue '-' %></td>
<!-- <td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
<td><%= number_with_precision(total_data[sale.item_code] , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
</tr>
<!-- sub total -->
<!-- end sub total -->
@@ -89,7 +106,6 @@
<td colspan="3"></td>
<td><strong>Total</strong></td>
<td><strong><%= total_qty %></strong></td>
<td></td>
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
</tr>

30
app/views/reports/product_sale/index.xls.erb Executable file → Normal file
View File

@@ -11,7 +11,7 @@
<th><%= t("views.right_panel.detail.code") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<!-- <th><%= t("views.right_panel.detail.unit_price") %></th> -->
<th><%= t("views.right_panel.detail.total") %></th>
</tr>
</thead>
@@ -21,6 +21,21 @@
<% cate_arr = Array.new %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_item = {} %>
<% total_data = {} %>
<% @sale_data.each do |sale|
if !total_item.has_key?(sale.item_code)
total_item[sale.item_code] = sale.total_item
total_data[sale.item_code] = sale.grand_total
else
if sale.status_type == "void"
total_item[sale.item_code] += sale.total_item
end
if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc"
total_data[sale.item_code] += sale.grand_total
end
end
end %>
<% @sale_data.each do |sale| %>
<% grand_total += sale.grand_total %>
@@ -31,21 +46,23 @@
total_qty += sale.total_item
end %>
<% if !sale.status_type %>
<% if sale.status_type != "Discount" && sale.price.to_f >= 0 %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<% cate_arr = Array.new %>
<% if sale.total_item > 0 %>
<% cate_arr = Array.new %>
<% end %>
<td>&nbsp;</td>
<% end %>
<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><%= total_item[sale.item_code] rescue ' ' %></td>
<!-- <td><%= sale.unit_price rescue ' ' %></td> -->
<td><%= total_data[sale.item_code] rescue ' ' %></td>
</tr>
<!-- sub total -->
<!-- end sub total -->
@@ -55,7 +72,6 @@
<td colspan="3"></td>
<td><strong>Total</strong></td>
<td><strong><%= total_qty rescue ' ' %></strong></td>
<td></td>
<td><strong><%= grand_total rescue ' ' %></strong></td>
</tr>
<% end %>

View File

@@ -0,0 +1,73 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14">Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<%if @sale_type=="waste" %>
<option value="waste" selected>Waste</option>
<% else %>
<option value="waste">Waste</option>
<% end %>
<%if @sale_type=="spoile" %>
<option value="spoile" selected>Spoilage</option>
<% else %>
<option value="spoile">Spoilage</option>
<% end %>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-1 col-md-1 col-sm-1 margin-top-20">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
</script>

View File

@@ -0,0 +1,75 @@
<div class="container-fluid">
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% @sale_data.each do |sale| %>
<% waste_and_spoil_item_count = 0%>
<thead>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
</thead>
<tbody>
<tr>
<td ><strong>Item Name</strong></td>
<td ><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
<% sale.sale_items.each do |item| %>
<% if !item.item_instance_code.nil?%>
<% waste_and_spoil_item_count += item.qty.to_i%>
<tr>
<td><%= item.product_name %></td>
<td><%= item.product_code %></td>
<td><%= item.qty %></td>
<td><%= item.price %></td>
<td><%= item.price %></td>
</tr>
<% end %>
<% end %>
<tr>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td><span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
</span>
</td>
</tr>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,58 @@
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% @sale_data.each do |sale| %>
<% waste_and_spoil_item_count = 0%>
<thead>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
</thead>
<tbody>
<tr>
<td ><strong>Item Name</strong></td>
<td ><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
<% sale.sale_items.each do |item| %>
<% if !item.item_instance_code.nil?%>
<% waste_and_spoil_item_count += item.qty.to_i%>
<tr>
<td><%= item.product_name %></td>
<td><%= item.product_code %></td>
<td><%= item.qty %></td>
<td><%= item.price %></td>
<td><%= item.price %></td>
</tr>
<% end %>
<% end %>
<tr>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td><span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
</span>
</td>
</tr>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>

View File

@@ -122,6 +122,8 @@ en:
mpu: "MPU"
jcb: "JCB"
visa: "VISA"
master: "MASTER"
alipay: "Alipay"
credit: "CREDIT"
other_payment: "Other Payment"
percentage: "PERCENTAGE"
@@ -412,6 +414,7 @@ en:
redeem_sales: "Redeem Sales"
cash_sales: "Cash Sales"
credit_sales: "Credit Sales"
alipay_sales: "Alipay Sales"
foc_sales: "FOC Sales"
foc_item: "Item FOC"
net_amount: "Net Amount"

View File

@@ -117,6 +117,8 @@ mm:
mpu: "MPU"
jcb: "JCB"
visa: "VISA"
master: "MASTER"
alipay: "Alipay"
credit: "အကြွေး"
other_payment: "အခြားငွေပေးဆောင်မှုများ"
percentage: "ရာခိုင်နှုန်း"
@@ -404,6 +406,7 @@ mm:
master_sales: "Master ရောင်းရငွေ"
visa_sales: "Visa ရောင်းရငွေ"
jcb_sales: "JCB ရောင်းရငွေ"
alipay_sales: "Alipay ရောင်းရငွေ"
redeem_sales: "ဆုကြေးပြန်သုံးငွေနှင့် ရောင်းရငွေ"
cash_sales: "ငွေသား ရောင်းရငွေ"
credit_sales: "အကြွေး ရောင်းရငွေ"

View File

@@ -84,7 +84,8 @@ scope "(:locale)", locale: /en|mm/ do
end
#--------- Cashier ------------#
namespace :origami do
namespace :origami do
get "dashboard" => "dashboard#index"
get "quick_service" => "quick_service#index"
@@ -178,6 +179,8 @@ scope "(:locale)", locale: /en|mm/ do
post 'payment/paypar' => 'paypar_payments#create'
post 'payment/credit' => 'credit_payments#create'
post 'payment/voucher' => 'voucher_payments#create'
post 'payment/alipay' => 'alipay#create'
post 'payment/junctionpay' => 'junctionpay#create'
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
@@ -188,10 +191,14 @@ scope "(:locale)", locale: /en|mm/ do
get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index"
get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index"
get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index"
get 'sale/:sale_id/:type/payment/others_payment/JunctionPay' => "junction_pay#index"
get 'sale/:sale_id/:type/payment/others_payment/Alipay' => "alipay#index"
#---------Void --------------#
post 'sale/:sale_id/:type/void' => 'void#overall_void'
post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage"
#---------Multiple Invoices --------------#
get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index"
get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show", :as => "table_invoice_show"
@@ -245,6 +252,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :second_display #second display routes
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
end
#--------- Waiter/Ordering Station ------------#
@@ -398,6 +406,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :only => [:index, :show]
resources :waste_and_spoilage, :only => [:index, :show]
resources :commission, :only => [:index, :show]
resources :stock_check, :only => [:index, :show]
resources :payment_method

View File

@@ -2,7 +2,7 @@ class CreateTaxProfiles < ActiveRecord::Migration[5.1]
def change
create_table :tax_profiles do |t|
t.string :name, :null => false
t.string :group_type, :null => false
t.string :group_type
t.decimal :rate, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.boolean :inclusive, :null => false, :default => false
t.integer :order_by, :null => false, :default => 1

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Origami::AlipayController, type: :controller do
end