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

This commit is contained in:
Nweni
2017-07-01 09:46:44 +06:30
21 changed files with 346 additions and 254 deletions

View File

@@ -22,10 +22,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_discount = overall_discount.to_f
sale.total_amount = sub_total.to_f
sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
sale.save
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
if discount_items.length > 0
#save sale item for discount
discount_items.each do |di|
@@ -35,6 +35,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.qty = 1
@@ -45,7 +46,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.price = di["price"]
sale_item.save
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
end
dining = {:table_id => table_id, :table_type => table_type }

View File

@@ -16,10 +16,11 @@ class Origami::OtherChargesController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_amount = sub_total.to_f
sale.grand_total = sub_total.to_f + sale.total_tax;
sale.save
table_type = DiningFacility.find(table_id).type
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
@@ -29,18 +30,22 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = "Other Charges"
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Other Charges"
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"]
sale_item.taxable_price = 0
sale_item.is_taxable = 0
sale_item.price = di["price"]
sale_item.save
end
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json

View File

@@ -9,10 +9,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = sale_data.grand_total - new_total
sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
@@ -43,7 +39,12 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
sale_payment.process_payment(saleObj, @user, cash, "cash")
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = saleObj.grand_total - new_total
saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
rebate_amount = nil

View File

@@ -26,6 +26,9 @@ class Origami::SalesController < BaseOrigamiController
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
end
# Re-compute for add
saleobj.compute
saleobj.save
order.save
booking.save

View File

@@ -1,5 +1,5 @@
class Reports::ShiftsaleController < ApplicationController
# authorize_resource :class => false
class Reports::ShiftsaleController < BaseReportController
authorize_resource :class => false
def index

View File

@@ -36,12 +36,13 @@ class Ability
can :index, :dailysale
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
can :add_customer, Customer
can :update_sale_by_customer, Customer
can :index, :other_charges
can :create, :other_charges
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
@@ -76,11 +77,14 @@ class Ability
can :add_customer, Customer
can :update_sale_by_customer, Customer
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :first_bill, :payment
can :show, :payment
can :create, :payment
can :reprint, :payment
@@ -89,18 +93,25 @@ class Ability
can :moving, :movetable
can :move_dining, :moveroom
can :first_bill, :payment
can :show, :payment
can :create, :payment
can :reprint, :payment
elsif user.role == "accountant"
can :index, :dailysale
can :manage, :saleitem
can :index, :receiptno
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
elsif user.role == "supervisour"
can :index, :dailysale
can :manage, :saleitem
can :index, :receiptno
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
end

View File

@@ -91,7 +91,7 @@ class Order < ApplicationRecord
# self.employee_name)
# end
OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id],
OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
self.employee_name)

View File

@@ -20,12 +20,13 @@ class OrderItem < ApplicationRecord
# option_values : [],
# sub_order_items : [],
# }
def self.processs_item (item_code, menu_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
def self.processs_item (item_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
orderitem = OrderItem.create do |oitem|
oitem.order_id = order_id
oitem.item_code = item_code
oitem.item_name = menu_name
oitem.alt_name = alt_name
oitem.account_id = account_id
oitem.qty = qty
oitem.price = price

View File

@@ -59,11 +59,11 @@ class OrderQueueStation < ApplicationRecord
private
#Print order_items in 1 slip
def print_slip(oqs, order, order_items)
unique_code="OrderSummaryPdf"
unique_code="OrderSummaryPdf"
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(oqs,order.order_id, order_items, print_status="")
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
@@ -80,7 +80,7 @@ class OrderQueueStation < ApplicationRecord
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs,item.order_id, item.item_code, print_status="" )
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, item.item_code, print_status="" )
# update print status for completed same order items
assigned_order_item.each do |ai|

View File

@@ -41,8 +41,10 @@ class Sale < ApplicationRecord
end
booking.sale_id = sale_id
end
order = booking.booking_orders.take.order
link_order_sale(order.id)
return status, sale_id
end
end
@@ -93,7 +95,6 @@ class Sale < ApplicationRecord
end
self.save!
#compute sales summary
@@ -148,6 +149,7 @@ class Sale < ApplicationRecord
#pull
sale_item.product_code = item.item_code
sale_item.product_name = item.item_name
sale_item.product_alt_name = item.alt_name
sale_item.account_id = item.account_id
sale_item.remark = item.remark
@@ -206,6 +208,33 @@ class Sale < ApplicationRecord
end
#compute - invoice total
def compute_by_sale_items(sale_id, sale_itemss, total_discount)
sale = Sale.find(sale_id)
sales_items = sale_itemss
#Computation Fields
subtotal_price = 0
total_taxable = 0
rounding_adjustment = 0
sales_items.each do |item|
#compute each item and added to total
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + (item.taxable_price * item.qty)
end
compute_tax(sale, total_taxable)
sale.total_amount = subtotal_price
sale.total_discount = total_discount
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
#compute rounding adjustment
# adjust_rounding
sale.save!
end
def compute_without_void
sales_items = self.sale_items
@@ -231,6 +260,39 @@ class Sale < ApplicationRecord
self.save!
end
# Tax Re-Calculte
def compute_tax(sale, total_taxable)
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
#delete existing and create new
existing_tax.delete
end
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
# #Creat new tax records
tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
#new taxable amount
total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
sale.total_tax = total_tax_amount
end
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record
@@ -447,6 +509,63 @@ def self.get_by_shiftsales(from,to)
return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
# def self.get_by_shiftsales(employee,from,to)
# shift_sales = ShiftSale.select('shift_sales.id, cs.name as cashier_station_name, shift_sales.shift_started_at as opening_date, shift_sales.shift_closeed_at as closing_date')
# .joins(" INNER JOIN cashier_terminals cs ON cs.id = shift_sales.cashier_terminal_id")
# .where("shift_sales.employee_id = ? and (shift_sales.shift_started_at between ? and ? OR shift_sales.shift_closeed_at between ? and ? )", employee, from, to, from, to)
# .order("shift_sales.id DESC")
# sale_arr = Array.new
# shift_sales.each do |shift|
# all_total= Sale.select("grand_total,sr.payment_method, sr.payment_amount, rounding_adjustment")
# .joins("join employees e on sales.cashier_id = e.id join shift_sales sh on sh.id = sales.shift_sale_id")
# .joins("INNER JOIN (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sr ON sr.sale_id = sales.sale_id")
# .where("sales.shift_sale_id =? and sales.sale_status = 'completed' and sales.total_amount != 0",shift.id)
# void = Sale.select("SUM(sales.grand_total) AS grand_total")
# .joins("join shift_sales sh on sh.id = sales.shift_sale_id")
# .where('sales.sales_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
# .sum(:grand_total)
# cash = all_total.select('sr.payment_type')
# .where('sr.payment_type = "cash"')
# .sum(:amount)
# credit = all_total.where('sr.payment_type = "credit"')
# .sum(:amount)
# accept_credit = all_total.select('ci.amout')
# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id")
# .where('sr.payment_type = "credit"')
# .sum(:amout)
# foc = all_total.where('sales.payment_type = "foc" and sales.sales_status = "completed"')
# .sum(:grand_total)
# card = all_total.select('payment_type')
# .where('sr.payment_type = "card"')
# .sum(:amount).to_f
# rounding_adj = all_total.sum(:rounding_adjustment)
# discount = all_total.sum(:discount_amount)
# void = void.nil? ? 0 : void
# cash = cash.nil? ? 0 : cash
# credit = credit.nil? ? 0 : credit
# foc = foc.nil? ? 0 : foc
# card = card.nil? ? 0 : card
# accept_credit = accept_credit.nil? ? 0 : accept_credit
# # all_payments = void.to_d + cash.to_d + credit.to_d + foc.to_d + card.to_d + accept_credit.to_d
# all_payments = cash.to_d + credit.to_d + foc.to_d + card.to_d + accept_credit.to_d
# payments = { void_amount: void, cash_amount: cash, credit_amount: credit,accept_credit_amount: accept_credit, foc_amount: foc, card_amount: card, grand_total: all_payments , cashier_station_name: shift.cashier_station_name, opening_date: shift.opening_date, closing_date: shift.closing_date, rounding_adj: rounding_adj }
# sale_arr.push(payments)
# end
# return sale_arr
# end
def get_cash_amount
cash = 0.0
self.sale_payments.each do |pay|
@@ -487,7 +606,6 @@ end
return tax
end
private
def generate_custom_id

View File

@@ -54,6 +54,14 @@ class SalePayment < ApplicationRecord
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ invoice.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
return true, self.save
else
#record an payment in sale-audit

View File

@@ -20,8 +20,8 @@ class ShiftSale < ApplicationRecord
#if current_user
#find open shift where is open today and is not closed and login by current cashier
today_date = DateTime.now.strftime("%Y-%m-%d")
puts today_date
shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}", today_date).take
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
return shift
#end

View File

@@ -95,7 +95,7 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
text "Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
end
@@ -202,6 +202,18 @@ class ReceiptBillPdf < Prawn::Document
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
# end
if sale_data.rounding_adjustment != 0.0
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
end
end
move_down 5
y_position = cursor
move_down 5
@@ -253,18 +265,13 @@ class ReceiptBillPdf < Prawn::Document
if rebate_amount["status"] == true
stroke_horizontal_rule
rebate = 0
rebate_amount["data"].each do |res|
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate"
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Current Rebate Amount", :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(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
rebate = rebate + res["rebate"]
end
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
@@ -279,6 +286,14 @@ class ReceiptBillPdf < Prawn::Document
end
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Current Rebate Amount", :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(rebate, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
if member_info["status"] == true && member_info["data"].present?

View File

@@ -60,7 +60,7 @@
<tr>
<th colspan="5">Membership Transactions</th>
<% if @response["status"] == true %>
<th>Current Balance : <%= @response["data"][0]["balance"]%></th>
<th>Current Balance : <%= @response["data"].last["balance"]%></th>
<% end %>
</tr>
<% end %>

View File

@@ -42,7 +42,7 @@
<li><%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li>
<!-- <li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li> -->
<li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li>
</ul>
</li>
</ul>

View File

@@ -35,16 +35,17 @@
<tr>
<th>Cashier Station</th>
<th>Cashier Name</th>
<th>Shift Name</th>
<th>Void Amount</th>
<!-- <th>Void Amount</th> -->
<th>Cash Payment</th>
<th>Credit Charges</th>
<!-- <th>Credit Charges</th> -->
<th>Credit Payment</th>
<th>FOC Payment</th>
<th>Card Payment</th>
<th>Grand Total +
<br/>Rounding Adj</th>
<th>Rounding Adj</th>
<!-- <th>FOC Payment</th> -->
<th>Other Payment</th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
<!-- <th>Rounding Adj</th> -->
<th>Grand Total</th>
</tr>
</thead>
@@ -58,48 +59,50 @@
<% total = 0%>
<% rounding_adj = 0%>
<% g_total = 0 %>
<% @sale_data.each do |result| %>
<% @sale_data.each do |result|%>
<tr>
<td>
<%= result[:cashier_station_name] rescue '-'%>
<%= result.cashier_terminal.name rescue '-'%>
</td>
<td><%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
<td>
<%= result.employee.name rescue '-'%>
</td>
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result[:void_amount].to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result[:cash_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:credit_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:accept_credit_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:foc_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:card_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td>
<% grand_total = result[:grand_total].to_f - result[:rounding_adj].to_f %>
<td><%= sprintf "%.2f",grand_total.to_f.to_d rescue '-'%></td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.rounding_adj.to_f.to_d rescue '-'%></td> -->
<% grand_total = result.grand_total.to_f %>
<td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td>
</tr>
<% void += result[:void_amount].to_f %>
<% cash += result[:cash_amount].to_f %>
<% credit += result[:credit_amount].to_f %>
<% accept_credit += result[:accept_credit_amount].to_f %>
<% foc += result[:foc_amount].to_f %>
<% card += result[:card_amount].to_f %>
<% total += result[:grand_total].to_f %>
<% rounding_adj += result[:rounding_adj].to_f %>
<% cash += result.cash_sales.to_f %>
<% credit += result.credit_sales.to_f %>
<% card += result.other_sales.to_f %>
<% total += result.grand_total.to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="2"></td>
<td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td>
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",total) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
</tr>
</tbody>
@@ -109,52 +112,3 @@
</div>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -1,116 +1,86 @@
<div class="card row">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<% if params[:from]%>
<tr>
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
</tr>
<% end %>
<tr>
<th style='text-align:center;'>Sr.no</th>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Void Amount</th>
<th style='text-align:center;'>Mpu Sales</th>
<th style='text-align:center;'>Master Sales</th>
<th style='text-align:center;'>Visa Sales</th>
<th style='text-align:center;'>Jcb Sales</th>
<th style='text-align:center;'>Paypar Sales</th>
<th style='text-align:center;'>Cash Sales</th>
<th style='text-align:center;'>Credit Sales</th>
<th style='text-align:center;'>FOC Sales</th>
<th style='text-align:center;'>(Discount)</th>
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
<th style='text-align:center;'>Rounding Adj.</th>
<th style='text-align:center;'>Grand Total</th>
</tr>
</thead>
<% unless @sale_data.empty? %>
<tbody>
<% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
<% total = 0 %>
<% 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] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_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 %>
<% 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[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_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 %>
<div class="card row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<% if params[:from]%>
<tr>
<th colspan="7">From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%></th>
</tr>
<% end %>
<tr>
<th>Cashier Station</th>
<th>Cashier Name</th>
<th>Shift Name</th>
<!-- <th>Void Amount</th> -->
<th>Cash Payment</th>
<!-- <th>Credit Charges</th> -->
<th>Credit Payment</th>
<!-- <th>FOC Payment</th> -->
<th>Other Payment</th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
<!-- <th>Rounding Adj</th> -->
<th>Grand Total</th>
</tr>
</thead>
<tbody>
<% void = 0%>
<% cash = 0%>
<% credit = 0%>
<% accept_credit = 0%>
<% foc = 0%>
<% card = 0%>
<% total = 0%>
<% rounding_adj = 0%>
<% g_total = 0 %>
<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_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :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>
<% @sale_data.each do |result|%>
<tr>
<td>
<%= result.cashier_terminal.name rescue '-'%>
</td>
<td>
<%= result.employee.name rescue '-'%>
</td>
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
<% total_tax = 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>
<% end %>
<% net = total - total_tax %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'>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>
<!-- <td><%= sprintf "%.2f",result.rounding_adj.to_f.to_d rescue '-'%></td> -->
<% grand_total = result.grand_total.to_f %>
<td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td>
</tr>
<% cash += result.cash_sales.to_f %>
<% credit += result.credit_sales.to_f %>
<% card += result.other_sales.to_f %>
<% total += result.grand_total.to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@@ -7,6 +7,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1]
t.string :item_order_by #person who order this
t.string :item_code, :null => false
t.string :item_name, :null => false
t.string :alt_name, :null => false
t.integer :account_id, :limit => 8, :null => false, :default => 1
t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -5,6 +5,7 @@ class CreateSaleItems < ActiveRecord::Migration[5.1]
t.string :sale_id, foreign_key: true, :limit => 16
t.string :product_code, :null => false
t.string :product_name, :null => false
t.string :product_alt_name, :null => false
t.integer :account_id, :limit => 8, :null => false, :default => 1
t.string :remark
t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -156,11 +156,11 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111
admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"})
admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})

View File

@@ -9,7 +9,7 @@ beverage = Account.create({title: "Beverage", account_type: "1"})
menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base", alt_name: "Soup_base", order_by: 1,created_by: "SYSTEM DEFAULT"})
# single pot
menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0051", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0061", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0071", menu_item: menu_category1_menu_item0, price:17800.00, is_on_promotion:false}])
@@ -18,7 +18,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0101", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
# twin pot
menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"01002", name: "Twin Pot", alt_name: "Twin Pot",menu_category: menu_category1 , min_selectable_item: 2, max_selectable_item:2, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Twin Pot",item_instance_code:"II0021", menu_item: menu_category1_menu_item1, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Twin Pot",item_instance_code:"II0021", menu_item: menu_category1_menu_item1, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0052", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0062", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0072", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
@@ -27,7 +27,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0102", menu_item: menu_category1_menu_item1, price:11800.00, is_on_promotion:false}])
# vip room Individual pot
menu_category1_menu_item2 = SimpleMenuItem.create({item_code:"01003", name: "VIP Room Individual Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"VIP Room Individual Pot",item_instance_code:"II0031", menu_item: menu_category1_menu_item2, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"VIP Room Individual Pot",item_instance_code:"II0031", menu_item: menu_category1_menu_item2, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0053", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0063", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0073", menu_item: menu_category1_menu_item2, price:8000.00, is_on_promotion:false}])
@@ -36,7 +36,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0103", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
# Quart pot
menu_category1_menu_item3 = SimpleMenuItem.create({item_code:"01004", name: "Quart Pot", alt_name: "Quart Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Quart Pot",item_instance_code:"II0041", menu_item: menu_category1_menu_item3, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Quart Pot",item_instance_code:"II0041", menu_item: menu_category1_menu_item3, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0054", menu_item: menu_category1_menu_item3, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0064", menu_item: menu_category1_menu_item3, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0074", menu_item: menu_category1_menu_item3, price:8000.00, is_on_promotion:false}])
@@ -629,9 +629,9 @@ zone3 = Zone.create({id:3, name: "H3", is_active:true, created_by: "SYSTEM DEFAU
table = Table.create({name:"78", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})
#Default Order Queue stations
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station2 = OrderQueueStation.create({station_name: "K2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
zone_order_queue_station = OrderQueueStation.create({station_name: "K3", is_active: true, printer_name: "print_station", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station2 = OrderQueueStation.create({station_name: "K2", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
zone_order_queue_station = OrderQueueStation.create({station_name: "K3", is_active: true, printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
# QueueStationZone
zone_queue_station1 = OrderQueueProcessByZone.create({order_queue_station: order_queue_station1, zone: zone})