Pull from master

This commit is contained in:
San Wai Lwin
2018-08-20 11:26:07 +06:30
parent 3c2faf5970
commit d1852d24c3
28 changed files with 464 additions and 216 deletions

1
.gitignore vendored
View File

@@ -28,6 +28,7 @@ capybara-*.html
/public/uploads/* /public/uploads/*
/public/swf/* /public/swf/*
/public/receipts/ /public/receipts/
/public/orders_*
/public/*.mp3 /public/*.mp3
/coverage/ /coverage/
/spec/tmp/* /spec/tmp/*

View File

@@ -2,7 +2,8 @@ FROM ruby:2.4.1
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
RUN mkdir /sxrestaurant RUN mkdir /sxrestaurant
RUN mkdir -p /sxrestaurant/tmp/puma RUN mkdir -p /sxrestaurant/tmp/puma
ENV RAILS_ENV production ENV RAILS_ENV staging
ENV RACK_ENV staging
WORKDIR /sxrestaurant WORKDIR /sxrestaurant
COPY Gemfile /sxrestaurant/Gemfile COPY Gemfile /sxrestaurant/Gemfile
COPY Gemfile.lock /sxrestaurant/Gemfile.lock COPY Gemfile.lock /sxrestaurant/Gemfile.lock
@@ -10,4 +11,5 @@ RUN bundle install --without development test
RUN echo "Asia/Rangoon" > /etc/timezone RUN echo "Asia/Rangoon" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata RUN dpkg-reconfigure -f noninteractive tzdata
COPY . /sxrestaurant COPY . /sxrestaurant
RUN bundle exec rails assets:precompile RUN bundle exec rake assets:precompile
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

View File

@@ -254,6 +254,9 @@ For Customer Settings On/Off
For TaxProfiles On/Off For TaxProfiles On/Off
1) settings/lookups => {type:changable_tax, name:change, value: {1 or 0}} 1) settings/lookups => {type:changable_tax, name:change, value: {1 or 0}}
For Add Kitchen Role
1) settings/lookups => {type:employee_roles, name:Kitchen, value:kitchen}
* ToDo list * ToDo list
1. Migration 1. Migration

View File

@@ -354,12 +354,16 @@ $(document).on('turbolinks:load', function() {
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text(); var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text(); var options = $('.selected-item').children('.card-block').find('.item-options').text();
var params = { 'options':options }; var params = { 'options':options };
$.ajax({ $.ajax({
type: 'POST', type: 'GET',
url: '/oqs/print/print/'+assigned_item_id, url: '/oqs/print/print/'+assigned_item_id,
data: params, data: params,
success: function(data){ } success: function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}); });
}); });
@@ -374,7 +378,12 @@ $(document).on('turbolinks:load', function() {
type: 'GET', type: 'GET',
url: '/oqs/print/print_order_summary/'+assigned_item_id, url: '/oqs/print/print_order_summary/'+assigned_item_id,
data: params, data: params,
success: function(data){ } success: function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}); });
}); });
}); });

View File

@@ -1,8 +1,36 @@
class Inventory::InventoryController < BaseInventoryController class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource load_and_authorize_resource
def index def index
@products = InventoryDefinition.all.active.order('created_at desc') least_stock = "SELECT (CASE WHEN SIGN(MIN(stock_journals.balance)) > 0
end THEN MIN(stock_journals.balance) WHEN stock_journals.remark NOT LIKE '%out of stock%'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code
AND remark NOT LIKE '%out of stock%'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance")
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.group("inventory_definitions.item_code")
.order("(CASE WHEN sj.balance > 0 THEN MIN(sj.balance) ELSE NULL END )")
end
def show
inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find(inventory_definition_id)
@stock_journals = StockJournal.where(item_code: inventory.item_code)
respond_to do |format|
format.html
format.xls
end
end
#Shop Name in Navbor #Shop Name in Navbor
helper_method :shop_detail helper_method :shop_detail

View File

@@ -24,7 +24,14 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions # POST /inventory_definitions
# POST /inventory_definitions.json # POST /inventory_definitions.json
def create def create
@inventory_definition = InventoryDefinition.new(inventory_definition_params) inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
else
@inventory_definition = InventoryDefinition.find(inventory.id)
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
end
@inventory_definition.created_by = current_user.id @inventory_definition.created_by = current_user.id
respond_to do |format| respond_to do |format|
if @inventory_definition.save if @inventory_definition.save

View File

@@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController
authorize_resource :class => false authorize_resource :class => false
# Print Order Item # Print Order Item
def print def print
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all printer = PrintSetting.all
unique_code="OrderItemPdf" unique_code="OrderItemPdf"
@@ -41,19 +41,30 @@ class Oqs::PrintController < ApplicationController
# print when complete click # print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options ) filename, receipt_no, cashier_printer = order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
# update print status for completed same order items # update print status for completed same order items
assigned_items.each do |ai| assigned_items.each do |ai|
ai.print_status=true ai.print_status=true
ai.save ai.save
end end
end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
if ENV["SERVER_MODE"] == "cloud"
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
end
# end
end end
# Print Order Details with booking id # Print Order Details with booking id
def print_order_summary def print_order_summary
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all printer = PrintSetting.all
unique_code="OrderSummaryPdf" unique_code="OrderSummaryPdf"
@@ -98,14 +109,25 @@ class Oqs::PrintController < ApplicationController
# print when complete click # print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) filename, receipt_no, cashier_printer = order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
# update print status for completed same order items # update print status for completed same order items
assigned_items.each do |ai| assigned_items.each do |ai|
ai.print_status = true ai.print_status = true
ai.save ai.save
end end
end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
if ENV["SERVER_MODE"] == "cloud"
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
end
# end
end end
end end

View File

@@ -26,15 +26,16 @@ class Origami::SalesController < BaseOrigamiController
dining = params[:dining_id] dining = params[:dining_id]
sale_id = params[:sale_id] sale_id = params[:sale_id]
tax_type = params[:tax_type] tax_type = params[:tax_type]
sale_data = []
table = DiningFacility.find(dining) table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id) existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.each do |booking| table.bookings.each do |booking|
# if !booking.checkout_at.nil? # if !booking.checkout_at.nil?
# existing_booking.update_attributes(checkout_at: checkout_at) # existing_booking.update_attributes(checkout_at: checkout_at)
# end # end
if booking.sale_id.nil? if booking.sale_id.nil?
order_array = [] order_array = []
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved' booking.booking_status = 'moved'
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@@ -49,6 +50,7 @@ class Origami::SalesController < BaseOrigamiController
if !orer_item.set_menu_items.nil? if !orer_item.set_menu_items.nil?
saleobj.add_sub_item(orer_item.set_menu_items) saleobj.add_sub_item(orer_item.set_menu_items)
end end
sale_data.push(orer_item)
end end
# Re-compute for add # Re-compute for add
@@ -58,7 +60,7 @@ class Origami::SalesController < BaseOrigamiController
booking.save booking.save
order_array.push(order.order_id) order_array.push(order.order_id)
end end
receipt_no = Sale.find(sale_id).receipt_no receipt_no = Sale.find(sale_id).receipt_no
@@ -75,6 +77,10 @@ class Origami::SalesController < BaseOrigamiController
end end
end end
end end
if !sale_data.empty?
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(nil,sale_data)
end
end end
end end

View File

@@ -2,11 +2,20 @@ class InventoryDefinition < ApplicationRecord
scope :active, -> {where(:is_active => true)} scope :active, -> {where(:is_active => true)}
def self.calculate_product_count(saleObj) def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
saleObj.sale_items.each do |item| if !saleObj.nil?
found, inventory_definition = find_product_in_inventory(item) saleObj.sale_items.each do |item|
if found found, inventory_definition = find_product_in_inventory(item)
check_balance(item,inventory_definition) if found
check_balance(item,inventory_definition)
end
end
else
saleobj_after_req_bill.each do |item|
found, inventory_definition = find_product_in_inventory(item)
if found
check_balance(item,inventory_definition)
end
end end
end end
end end
@@ -16,7 +25,12 @@ class InventoryDefinition < ApplicationRecord
if product.nil? if product.nil?
return false, nil return false, nil
else else
return true, product stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
if stock_check_item.nil?
return false, nil
else
return true, product
end
end end
end end
@@ -31,11 +45,19 @@ class InventoryDefinition < ApplicationRecord
def self.modify_balance(item, stock, inventory_definition) #saleitemObj def self.modify_balance(item, stock, inventory_definition) #saleitemObj
if stock.balance.to_i >= item.qty if stock.balance.to_i >= item.qty
puts ">> stock is greater than orde qty" puts ">> stock is greater than order qty"
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition) StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
else else
puts " << stock is less than order qty" puts " << stock is less than order qty"
StockJournal.add_to_journal(item, stock.balance, "out of stock", inventory_definition) item_data = item
if stock.balance.to_i > 0
item_data.qty = item.qty.to_i - stock.balance.to_i
StockJournal.add_to_journal(item_data, stock.balance, "out of stock", inventory_definition)
item.qty = stock.balance.to_i
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
else
StockJournal.add_to_journal(item_data, stock.balance, "out of stock", inventory_definition)
end
end end
end end
end end

View File

@@ -234,7 +234,7 @@ class OrderQueueStation < ApplicationRecord
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true) AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
# assigned_items =AssignedOrderItem.where("order_id = '#{ order.order_id }'") # assigned_items =AssignedOrderItem.where("order_id = '#{ order.order_id }'")
# assigned_items.each do |ai| # assigned_items.each do |ai|
@@ -283,6 +283,6 @@ class OrderQueueStation < ApplicationRecord
# ai.save # ai.save
# end # end
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true) AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
end end
end end

View File

@@ -1,9 +1,6 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="") def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
#Use CUPS service
#Generate PDF
#Print
# Must be one print # Must be one print
if print_settings.print_copies == 0 if print_settings.print_copies == 0
print_settings.print_copies = 1 print_settings.print_copies = 1
@@ -12,7 +9,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code) order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" # filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
print_setting = PrintSetting.all print_setting = PrintSetting.all
@@ -39,6 +36,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
# end # end
shop = Shop.first
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
pdf.render_file filename pdf.render_file filename
if oqs.print_copy if oqs.print_copy
@@ -56,7 +59,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, oqs.printer_name) self.print(filename, oqs.printer_name)
end end
end end
return filename, order_id, oqs.printer_name
end end
# Query for per order # Query for per order
@@ -72,12 +77,19 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting = PrintSetting.all.order("id ASC") print_setting = PrintSetting.all.order("id ASC")
order=print_query('order_summary', order_id) order=print_query('order_summary', order_id)
shop = Shop.first
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item # For Print Per Item
if oqs.cut_per_item if oqs.cut_per_item
order_items.each do|odi| order_items.each do|odi|
odi_item=print_query('order_item', odi.order_items_id) odi_item=print_query('order_item', odi.order_items_id)
filename = "tmp/order_item_#{order_id}" + ".pdf"
filename = directory_name + "/order_item_#{order_id}" + ".pdf"
# filename = "tmp/order_item_#{order_id}" + ".pdf"
# For Item Options # For Item Options
options = odi.options == "[]"? "" : odi.options options = odi.options == "[]"? "" : odi.options
@@ -122,7 +134,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
# For Print Order Summary # For Print Order Summary
else else
filename = "tmp/order_summary_#{order_id}" + ".pdf" filename = directory_name + "/order_summary_#{order_id}" + ".pdf"
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty) pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
if !print_setting.empty? if !print_setting.empty?
print_setting.each do |print_settings| print_setting.each do |print_settings|
@@ -160,6 +173,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
end end
end end
return filename, order_id, oqs.printer_name
end end
# Print for orders in booking # Print for orders in booking
@@ -173,10 +187,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting = PrintSetting.all.order("id ASC") print_setting = PrintSetting.all.order("id ASC")
order=print_query('booking_summary', booking_id) order=print_query('booking_summary', booking_id)
shop = Shop.first
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item # For Print Per Item
if oqs.cut_per_item if oqs.cut_per_item
order.each do|odi| order.each do|odi|
filename = "tmp/order_item_#{booking_id}" + ".pdf" # filename = "tmp/order_item_#{booking_id}" + ".pdf"
filename = directory_name + "/order_item_#{booking_id}" + ".pdf"
# For Item Options # For Item Options
options = odi.options == "[]"? "" : odi.options options = odi.options == "[]"? "" : odi.options
@@ -222,7 +242,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
# For Print Order Summary # For Print Order Summary
else else
filename = "tmp/booking_summary_#{booking_id}" + ".pdf" # filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty) pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
if !print_setting.empty? if !print_setting.empty?
@@ -261,6 +282,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
end end
end end
return filename, booking_id, oqs.printer_name
end end
# Query for OQS with status # Query for OQS with status

View File

@@ -2125,7 +2125,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2133,7 +2133,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end end
else else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
@@ -2144,7 +2144,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2152,7 +2152,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end end
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
@@ -2164,7 +2164,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
@@ -2172,7 +2172,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end end
end end
end end
@@ -2185,7 +2185,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
@@ -2194,7 +2194,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
else else
shift = ShiftSale.current_open_shift(current_user.id) shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil? if !shift.nil?
@@ -2204,7 +2204,7 @@ end
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
end end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first() query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) + (#{outstanding_query})) WHEN sp.payment_method='creditnote' THEN SUM(sp.payment_amount) - (#{sub_query}) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end end
end end
end end

View File

@@ -98,7 +98,7 @@ class SalePayment < ApplicationRecord
booking = Booking.find_by_sale_id(sale_id) booking = Booking.find_by_sale_id(sale_id)
booking.booking_orders.each do |sodr| booking.booking_orders.each do |sodr|
assigned =AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").pluck(:assigned_order_item_id) assigned =AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true) AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(delivery_status: true)
# AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| # AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
# aoi.delivery_status = 1 # aoi.delivery_status = 1
# aoi.save # aoi.save

View File

@@ -36,10 +36,10 @@ class StockCheckItem < ApplicationRecord
def self.get_transaction(from, to, item_code) def self.get_transaction(from, to, item_code)
transaction = all transaction = all
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
transaction = transaction.where('created_at between ? and ?', from, to) transaction = transaction.where('created_at between ? and ?', from, to).order("item_code asc, different desc")
end end
if item_code.present? if item_code.present?
transaction = transaction.where(item_code: item_code) transaction = transaction.where(item_code: item_code).order("item_code asc, different desc")
end end
transaction transaction
end end

View File

@@ -4,10 +4,11 @@ class StockJournal < ApplicationRecord
STOCK_CHECK_TRANS = "stock_check" STOCK_CHECK_TRANS = "stock_check"
def self.add_to_journal(item, balance, stock_message, inventory_definition) # item => saleObj | balance => Stock journal def self.add_to_journal(item, balance, stock_message, inventory_definition) # item => saleObj | balance => Stock journal
journal = StockJournal.new
journal.credit = balance
balance = calculate_balance(balance, item.qty) balance = calculate_balance(balance, item.qty)
journal = StockJournal.new
journal.item_code = item.item_instance_code journal.item_code = item.item_instance_code
journal.inventory_definition_id = inventory_definition.id journal.inventory_definition_id = inventory_definition.id
journal.debit = item.qty journal.debit = item.qty

View File

@@ -5,12 +5,14 @@
<th><%= t("views.right_panel.detail.product") %></th> <th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.min_order") %></th> <th><%= t("views.right_panel.detail.min_order") %></th>
<th><%= t("views.right_panel.detail.max_stock") %></th> <th><%= t("views.right_panel.detail.max_stock") %></th>
<th><%= t("views.right_panel.detail.created_by") %></th> <th><%= t("views.right_panel.detail.balance") %></th>
<th><%= t("views.right_panel.detail.created_time") %></th> <th><%= t("views.right_panel.detail.action") %></th>
<!-- <th><%= t("views.right_panel.detail.created_by") %></th>
<th><%= t("views.right_panel.detail.created_time") %></th> -->
</tr> </tr>
<% <%
count = 0 count = 0
@products.each do |item| @inventory_definitions.each do |item|
count += 1 count += 1
%> %>
<tr> <tr>
@@ -26,9 +28,20 @@
</td> </td>
<td><%= item.min_order_level %></td> <td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td> <td><%= item.max_stock_level %></td>
<td><%= Employee.find(item.created_by).name rescue '-' %></td> <td><%= item.balance rescue '0' %></td>
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td> <td>
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"><%= t("views.btn.show") %> <%= t("views.right_panel.detail.stock_check") %></button>
</td>
<!-- <td><%= Employee.find(item.created_by).name rescue '-' %></td>
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td> -->
</tr> </tr>
<% end %> <% end %>
</table> </table>
<script>
$('.show_track').on('click', function () {
var ID = $(this).attr("data-value");
window.location.href = '/inventory/'+ID+'/show';
});
</script>

View File

@@ -12,10 +12,10 @@
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9"> <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<div class="m-b-10 clearfix"> <div class="m-b-10 clearfix">
<button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %> <!-- <button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
</button> </button> -->
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.new_stock_taking") %></button> <button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_taking") %></button>
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= t("views.btn.new") + " " + (t :inventory) %> <button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %>
</button> </button>
</div> </div>
<div class="card"> <div class="card">
@@ -27,14 +27,14 @@
<div class="body"> <div class="body">
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5> <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p> <p>
1) <%= t("views.btn.new") + " " + (t :inventory) %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br> 1) <%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br>
</p> </p>
<p> <p>
2) <%= t("views.btn.new") + " " + t("views.right_panel.detail.stock_taking") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_taking_txt") %> <br> 2) <%= t("views.right_panel.detail.stock_taking") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_taking_txt") %> <br>
</p> </p>
<p> <!-- <p>
3) <%= t("views.right_panel.detail.stock_check_report") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_report_txt") %> <br> 3) <%= t("views.right_panel.detail.stock_check_report") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_report_txt") %> <br>
</p> </p> -->
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5> <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p> <p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br> 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
@@ -51,12 +51,12 @@
window.location.href = '<%= inventory_stock_checks_path %>'; window.location.href = '<%= inventory_stock_checks_path %>';
}); });
$('#stock_check_report').on('click', function () { // $('#stock_check_report').on('click', function () {
window.location.href = '<%= reports_stock_check_index_path %>'; // window.location.href = '<%= reports_stock_check_index_path %>';
}); // });
$('#new_inventory_product').on('click',function(){ $('#new_inventory_product').on('click',function(){
window.location.href = '/inventory/inventory_definitions/new'; window.location.href = '/inventory/inventory_definitions/new';
}) });
</script> </script>

View File

@@ -0,0 +1,70 @@
<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 :inventory %></li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<table class="table table-responsive table-striped table-hover">
<thead>
<tr>
<th><%= t("views.right_panel.detail.date") %></th>
<th><%= t("views.right_panel.detail.type") %></th>
<th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t :credit %></th>
<th><%= t :debit %></th>
<th><%= t("views.right_panel.detail.balance") %></th>
<th><%= t("views.right_panel.detail.remark") %></th>
</tr>
</thead>
<tbody>
<% total_credit = 0 %>
<% total_debit = 0 %>
<% total_balance = 0 %>
<% if !@stock_journals.nil? && !@stock_journals.empty? %>
<% @stock_journals.each do |result| %>
<tr>
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
<td><%= result.trans_type rescue '-' %></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(result.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% end %>
</td>
<td><%= result.credit rescue '-' %></td>
<td><%= result.debit rescue '-' %></td>
<td><%= result.balance rescue '-' %></td>
<td><%= result.remark rescue '-' %></td>
</tr>
<% !result.credit.nil? ? total_credit += result.credit : total_credit += 0 %>
<% !result.debit.nil? ? total_debit += result.debit : total_debit += 0 %>
<% !result.balance.nil? ? total_balance += result.balance : total_balance += 0 %>
<% end %>
<!-- <tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<td><b><%= total_credit rescue '-' %></b></td>
<td><b><%= total_debit rescue '-' %></b></td>
<td><b><%= total_balance rescue '-' %></b></td>
<td colspan="2"></td>
</tr> -->
<% else %>
<tr>
<td colspan="8" class="text-center">There is no record...</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -101,14 +101,25 @@
</div> </div>
<script> <script>
var count = 0; var count = 0;
$(document).ready(function(){
clearFormData();
});
function clearFormData(){
$('#stock_check_reason').val("");
$('#product_qty').val("");
$('#product_sku').val("");
}
$('#save_to_stock_check').on('click', function () { $('#save_to_stock_check').on('click', function () {
count += 1; count += 1;
product_sku = $('#product_sku').val(); product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val(); product_qty = $('#product_qty').val();
product_name = $("#product_sku").find("option:selected").text(); product_name = $("#product_sku").find("option:selected").text();
// clearFormData();
var tr = '<tr>' var tr = '<tr>'
//+ '<td>' + count + '</td>' //+ '<td>' + count + '</td>'
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>' + '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'

View File

@@ -176,12 +176,15 @@
<!-- OQS Buttons --> <!-- OQS Buttons -->
<br> <br>
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a> <a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a> <button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button> <button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<% if ENV["SERVER_MODE"] != "cloud" %>
<%end%> <%end%>
</div> </div>
</div> </div>
<input type="hidden" id="server_mode" value="<%=ENV["SERVER_MODE"]%>">
<script type="text/javascript"> <script type="text/javascript">
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {

View File

@@ -21,19 +21,19 @@
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;"> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label class="font-14">Definition Item</label> <label class="font-14">Select Item</label>
<select class="form-control" name="item_code" id="item_code"> <select class="form-control" name="item_code" id="item_code">
<option value="">Select Product</option> <option value="">Select Item</option>
<% @inventory_definitions.each do |id| %> <% @inventory_definitions.each do |id| %>
<option value="<%= id.item_code %>"> <option value="<%= id.item_code %>">
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %> <% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
<% if menu_item.nil? %> <% if menu_item.nil? %>
<%= Product.find_by_item_code(id.item_code).name rescue "-" %> <%= Product.find_by_item_code(id.item_code).name rescue "-" %>
<% else %> <% else %>
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %> <%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
<% end %>
</option>
<% end %> <% end %>
</option>
<% end %>
</select> </select>
</div> </div>
<div class="form-group col-md-2 margin-top-20"><br> <div class="form-group col-md-2 margin-top-20"><br>

View File

@@ -3,102 +3,107 @@
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li> <li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item active">Stock Check Report</li> <li class="breadcrumb-item active">Stock Check Report</li>
<span class="float-right"> <span class="float-right">
<%= link_to 'Back', inventory_path %> <%= link_to 'Back', inventory_path %>
</span> </span>
</ol> </ol>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<!-- <div class="container"> -->
<%= render :partial => 'stock_check_report_filter',
:locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %>
<hr/>
<!-- </div> -->
<!-- <div class="container"> --> <!-- <div class="container"> -->
<!-- <div class="row"> --> <%= render :partial => 'stock_check_report_filter',
<div class="text-right"> :locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %>
<a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to <hr/>
Excel</a> <!-- </div> -->
</div>
<!-- </div> -->
<!-- </div> -->
<div class="margin-top-20"> <!-- <div class="container"> -->
<div class="card"> <!-- <div class="row"> -->
<div class="table-responsive"> <div class="text-right">
<% if @print_settings.precision.to_i > 0 <a href="javascript:export_to('<%= reports_stock_check_index_path %>.xls')" class="btn btn-info wave-effects">Export to
precision = @print_settings.precision Excel</a>
else </div>
precision = 0 <!-- </div> -->
end <!-- </div> -->
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<table class="table table-striped">
<thead>
<tr>
<th colspan="8"><i> From Date </i>: <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <i>To Date</i> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
</tr>
<tr>
<th>Stock Check Reason</th>
<th>Checked By</th>
<th>Item Name</th>
<th>Stock Count</th>
<th>Stock Balance</th>
<th>Different</th>
<th>Remark</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<% total_stock_count = 0 %>
<% total_stock_balance = 0 %>
<% total_different = 0 %>
<% @transaction.each do |result| %> <div class="margin-top-20">
<tr> <div class="card">
<td><%= result.stock_check.reason rescue '-' %></td> <div class="table-responsive">
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td> <% if @print_settings.precision.to_i > 0
<td> precision = @print_settings.precision
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%> else
<% if menu_item.nil? %> precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<table class="table table-striped">
<thead>
<tr>
<th colspan="8"><i> From Date </i>: <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <i>To Date</i> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
</tr>
<tr>
<th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.stock_count") %></th>
<th><%= t("views.right_panel.detail.stock_balance") %></th>
<th><%= t("views.right_panel.detail.different") %></th>
<th><%= t("views.right_panel.detail.remark") %></th>
<th><%= t("views.right_panel.detail.checked_by") %></th>
<th><%= t("views.right_panel.detail.stock_check") %> <%= t("views.right_panel.detail.reason") %></th>
</tr>
</thead>
<tbody>
<% total_stock_count = 0 %>
<% total_stock_balance = 0 %>
<% total_different = 0 %>
<% arr_item_code = [] %>
<% @transaction.each do |result| %>
<tr>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
<% if menu_item.nil? %>
<% if !arr_item_code.include?(result.item_code) %>
<%= Product.find_by_item_code(result.item_code).name rescue "-" %> <%= Product.find_by_item_code(result.item_code).name rescue "-" %>
<% else %> <% arr_item_code.push(result.item_code) %>
<% else %>
&nbsp;
<% end %>
<% else %>
<% if !arr_item_code.include?(result.item_code) %>
<%= menu_item.menu_item.name rescue "-" %> <%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %> - <%= menu_item.item_instance_name rescue "-" %>
<% end %> <% arr_item_code.push(result.item_code) %>
</td> <% else %>
<td><%= result.stock_count rescue '-' %></td> &nbsp;
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td> <% end %>
<td><%= result.different rescue '-' %></td>
<td><%= result.remark rescue '-' %></td>
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
</tr>
<% !result.stock_count.nil? ? total_stock_count += result.stock_count : total_stock_count += 0 %>
<% !result.stock_balance.nil? ? total_stock_balance += result.stock_balance : total_stock_balance += 0 %>
<% !result.different.nil? ? total_different += result.different : total_different += 0 %>
<% end %> <% end %>
</td>
<td><%= result.stock_count rescue '-' %></td>
<td><%= result.stock_balance rescue '-' %></td>
<td><%= result.different rescue '-' %></td>
<td><%= result.remark rescue '-' %></td>
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td>
<td><%= result.stock_check.reason rescue '-' %></td>
</tr>
<% !result.stock_count.nil? ? total_stock_count += result.stock_count : total_stock_count += 0 %>
<% !result.stock_balance.nil? ? total_stock_balance += result.stock_balance : total_stock_balance += 0 %>
<% !result.different.nil? ? total_different += result.different : total_different += 0 %>
<% end %>
<tr style="border-top: 3px solid grey;"> <!-- <tr style="border-top: 3px solid grey;">
<td colspan="3"></td> <td colspan="3"></td>
<td><b><%= total_stock_count rescue '-' %></b></td> <td><b><%= total_stock_count rescue '-' %></b></td>
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td> <td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
<td><b><%= total_different rescue '-' %></b></td> <td><b><%= total_different rescue '-' %></b></td>
<td colspan="2"></td> <td></td>
</tr> </tr> -->
</tbody> </tbody>
</table> </table>
</div>
</div>
</div> </div>
<script> </div>
$(function () { </div>
</div>
}); </div>
</script>

View File

@@ -14,44 +14,60 @@
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th> <th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
</tr> </tr>
<tr> <tr>
<th>Commissioner Name</th> <th><%= t("views.right_panel.detail.item") %> <%= t("views.right_panel.detail.name") %></th>
<th>Product Name</th> <th><%= t("views.right_panel.detail.stock_count") %></th>
<th>Qty</th> <th><%= t("views.right_panel.detail.stock_balance") %></th>
<th>Commission Price</th> <th><%= t("views.right_panel.detail.different") %></th>
<th>Commission Amount</th> <th><%= t("views.right_panel.detail.remark") %></th>
<th>Date</th> <th><%= t("views.right_panel.detail.checked_by") %></th>
<th><%= t("views.right_panel.detail.stock_check") %> <%= t("views.right_panel.detail.reason") %></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% total_qty = 0 %> <% total_stock_count = 0 %>
<% total_price = 0 %> <% total_stock_balance = 0 %>
<% total_amount = 0 %> <% total_different = 0 %>
<% arr_item_code = [] %>
<% @transaction.each do |result| %>
<tr>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(result.item_code)%>
<% if menu_item.nil? %>
<% if !arr_item_code.include?(result.item_code) %>
<%= Product.find_by_item_code(result.item_code).name rescue "-" %>
<% arr_item_code.push(result.item_code) %>
<% else %>
&nbsp;
<% end %>
<% else %>
<% if !arr_item_code.include?(result.item_code) %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% arr_item_code.push(result.item_code) %>
<% else %>
&nbsp;
<% end %>
<% end %>
</td>
<td><%= result.stock_count rescue '-' %></td>
<td><%= result.stock_balance rescue '-' %></td>
<td><%= result.different rescue '-' %></td>
<td><%= result.remark rescue '-' %></td>
<td><%= Employee.find(result.stock_check.check_by).name rescue '-' %></td>
<td><%= result.stock_check.reason rescue '-' %></td>
</tr>
<% !result.stock_count.nil? ? total_stock_count += result.stock_count : total_stock_count += 0 %>
<% !result.stock_balance.nil? ? total_stock_balance += result.stock_balance : total_stock_balance += 0 %>
<% !result.different.nil? ? total_different += result.different : total_different += 0 %>
<% end %>
<% @transaction.each do |result| %> <!-- <tr style="border-top: 3px solid grey;">
<tr> <td colspan="3"></td>
<td> <td><b><%= total_stock_count rescue '-' %></b></td>
<%= result.commissioner.name rescue '-' %> <td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
</td> <td><b><%= total_different rescue '-' %></b></td>
<td> <td></td>
<%= result.commission.menu_item.name rescue '-' %> </tr> -->
</td>
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
</tr>
<% total_qty += result.qty.to_f %>
<% total_price += result.price.to_f %>
<% total_amount += result.amount.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="2"></td>
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
<td></td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@@ -84,6 +84,8 @@ en:
processed: "Processed" processed: "Processed"
delivery_details: "Delivery Details" delivery_details: "Delivery Details"
credits: "Credits" credits: "Credits"
track: "Track"
debit: "Debit"
views: views:
btn: btn:
@@ -494,6 +496,7 @@ en:
in_time: "In Time" in_time: "In Time"
out_time: "Out Time" out_time: "Out Time"
transaction_fee: "Transaction Fee" transaction_fee: "Transaction Fee"
checked_by: "Checked By"
code_txt: "code " code_txt: "code "
charge_txt: "charge" charge_txt: "charge"

View File

@@ -79,7 +79,9 @@ mm:
processed: "Processed" processed: "Processed"
delivery_details: "Delivery Details" delivery_details: "Delivery Details"
credits: "အကြွေးများ" credits: "အကြွေးများ"
track: "Track"
debit: "Debit"
views: views:
btn: btn:
create: "အသစ်တည်ဆောက်ရန်" create: "အသစ်တည်ဆောက်ရန်"
@@ -488,6 +490,7 @@ mm:
in_time: "In Time" in_time: "In Time"
out_time: "Out Time" out_time: "Out Time"
transaction_fee: "Transaction Fee" transaction_fee: "Transaction Fee"
checked_by: "Checked By"
code_txt: "ကုတ်ဒ် " code_txt: "ကုတ်ဒ် "
charge_txt: "ကောက်ခံသည်" charge_txt: "ကောက်ခံသည်"

View File

@@ -357,7 +357,7 @@ scope "(:locale)", locale: /en|mm/ do
post "/:id", to: "edit#update" post "/:id", to: "edit#update"
# Pass assigned_order_item_id # Pass assigned_order_item_id
post 'print/print/:id', to: "print#print" get 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary" get 'print/print_order_summary/:id', to: "print#print_order_summary"
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs" get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"
@@ -513,6 +513,7 @@ scope "(:locale)", locale: /en|mm/ do
# resources :stock_checks # resources :stock_checks
resources :stock_journals resources :stock_journals
resources :inventory_definitions resources :inventory_definitions
get ':inventory_definition_id/show' => 'inventory#show'
end end
#mount_compendium at: '/report' #, controller: 'reports' #mount_compendium at: '/report' #, controller: 'reports'

View File

@@ -9,7 +9,7 @@ class CreateSaleAudits < ActiveRecord::Migration[5.1]
t.string :action_by, :null => false t.string :action_by, :null => false
t.string :approved_by, :null => true t.string :approved_by, :null => true
t.datetime :approved_at, :null => true t.datetime :approved_at, :null => true
t.text :remark, :index => true t.string :remark, :index => true
t.timestamps t.timestamps
end end
add_index :sale_audits, [:sale_id, :action, :action_at, :remark] add_index :sale_audits, [:sale_id, :action, :action_at, :remark]

View File

@@ -1,16 +1,17 @@
version: '3' version: '3'
services: services:
code2lab: code2lab:
build: . build:
context: .
dockerfile: ./Dockerfile
links: links:
- redis - redis
command: bundle exec puma -C config/puma.rb
volumes: volumes:
- .:/sxrestaurant - .:/sxrestaurant
env_file: env_file:
- .code2lab.env - .code2lab.env
ports: ports:
- '8081:62158' - '8082:62158'
environment: environment:
- REDIS_URL=redis://redis:6379/0 - REDIS_URL=redis://redis:6379/0
sidekiq: sidekiq:
@@ -22,10 +23,9 @@ services:
- .:/sxrestaurant - .:/sxrestaurant
environment: environment:
- REDIS_URL=redis://redis:6379/0 - REDIS_URL=redis://redis:6379/0
redis: redis:
image: redis image: redis
ports: ports:
- '6379:6379' - '6380:6379'
volumes: volumes:
- ../data/redis:/data - ../data/redis:/data