diff --git a/.idea/.generators b/.idea/.generators new file mode 100644 index 00000000..16189766 --- /dev/null +++ b/.idea/.generators @@ -0,0 +1,8 @@ + + diff --git a/.idea/.rakeTasks b/.idea/.rakeTasks new file mode 100644 index 00000000..3577d8ad --- /dev/null +++ b/.idea/.rakeTasks @@ -0,0 +1,7 @@ + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..157739d4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..21ecc838 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml new file mode 100644 index 00000000..586fd380 --- /dev/null +++ b/.idea/sxrestaurant.iml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..4d3242d5 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,817 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + origami + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1498458293643 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8f16e924..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -#gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index e4b905ea..7e27774a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,7 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.21.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index c2e99054..2097db44 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -27,7 +27,7 @@ $(document).ready(function(){ $('.queue_station').on('click',function(){ var orderZone=$(this).children().children().children('.order-zone').text().trim(); // var orderItem=$(this).children().children().children('.order-item').text(); - //var assigned_item_id = $(this).children().find(".assigned-order-item").text(); + var assigned_item_id = $(this).children().find(".assigned-order-item").text(); var orderQty = $(this).children().children().children('.order-qty').text(); var orderBy = $(this).children().children().children().children('.order-by').text(); var orderAt = $(this).children().children().children().children('.order-at').text(); @@ -68,6 +68,12 @@ $(document).ready(function(){ $(this).addClass('selected-item'); }); + $(".order-item-edit").on('click', function(){ + var _self = $(this); // To know in ajax return + var assigned_item_id=$(this).attr('id').substr(5); + window.location.href = '/oqs/'+ assigned_item_id + "/edit" + }); + // complete for queue item $('.order-complete').on('click',function(e){ //e.preventDefault(); @@ -134,4 +140,21 @@ $(document).ready(function(){ success: function(data){ } }); }); + + // Qty update for OQS Edit Controller + $('#qty-update').on('click', function(){ + var qty_weight = $("input[name='qty_weight']").val(); + var remarks = $("textarea[name='remarks']").val(); + var order_items_id = $(this).attr('data-id'); + var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks } + $.ajax({ + type: 'POST', + url: '/oqs/' + order_items_id, + data: params, + success: function(result){ + alert("Updated!"); + window.location.href = '/oqs'; + } + }); + }); }); diff --git a/app/assets/javascripts/reports/daily_sales.coffee b/app/assets/javascripts/reports/daily_sales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/daily_sales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/reports/dailysales.coffee b/app/assets/javascripts/reports/dailysales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/dailysales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/reports/sale_items.coffee b/app/assets/javascripts/reports/sale_items.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/sale_items.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss index b516836a..57c5a36d 100644 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -19,3 +19,9 @@ color: #fff !important; background-color: blue; } + +.order-item { + width: 49%; + font-size: 18px; + margin: 0px 0px 5px 0px; +} \ No newline at end of file diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 3606dadc..2ba6fe52 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -148,6 +148,10 @@ background-color:#7a62d3; } +.orange{ + background-color:#FF7F50; +} + .red { background-color:#ff0000; } @@ -160,6 +164,10 @@ background-color: #FF8C00 } +.blue{ + background-color: blue +} + .left{ margin-left:1px; } diff --git a/app/assets/stylesheets/reports/daily_sales.scss b/app/assets/stylesheets/reports/daily_sales.scss new file mode 100644 index 00000000..79ed876a --- /dev/null +++ b/app/assets/stylesheets/reports/daily_sales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/daily_sales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/reports/dailysales.scss b/app/assets/stylesheets/reports/dailysales.scss new file mode 100644 index 00000000..cfc48374 --- /dev/null +++ b/app/assets/stylesheets/reports/dailysales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/dailysales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/reports/sale_items.scss b/app/assets/stylesheets/reports/sale_items.scss new file mode 100644 index 00000000..b9692327 --- /dev/null +++ b/app/assets/stylesheets/reports/sale_items.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/sale_items controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d0a8ca9e..a877bda0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,16 +3,17 @@ class ApplicationController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception - helper_method :current_company,:current_login_employee - + helper_method :current_company,:current_login_employee,:current_user + # alias_method :current_user, :current_login_employee,:current_user #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON - # rescue_from CanCan::AccessDenied do |exception| - # flash[:warning] = exception.message - # redirect_to root_path - # end + + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end def current_user diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index a6bf7754..38f0df3d 100644 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,9 +1,17 @@ class BaseCrmController < ActionController::Base - include LoginVerification - layout "CRM" + include LoginVerification + layout "CRM" #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end end diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 16fe9b07..50d7bd55 100644 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -5,5 +5,13 @@ class BaseOqsController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end end diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index b250303d..2af895da 100644 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -5,5 +5,14 @@ class BaseOrigamiController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end + end diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 0ea51cf5..28ba5c2b 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -5,6 +5,15 @@ class BaseReportController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end + PERIOD = { "today" => 0, "yesterday" => 1, diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb index 65511512..efaa5419 100644 --- a/app/controllers/crm/bookings_controller.rb +++ b/app/controllers/crm/bookings_controller.rb @@ -1,5 +1,5 @@ class Crm::BookingsController < BaseCrmController - + load_and_authorize_resource def update_booking booking = Booking.find(params[:booking_id]) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 43b0618e..f2846c12 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -1,4 +1,5 @@ class Crm::CustomersController < BaseCrmController + load_and_authorize_resource except: [:create] before_action :set_crm_customer, only: [:show, :edit, :update, :destroy] # GET /crm/customers @@ -47,7 +48,8 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) + # @response = "" #end customer amount end @@ -68,7 +70,7 @@ class Crm::CustomersController < BaseCrmController def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| if @crm_customers.save name = customer_params[:name] @@ -77,6 +79,7 @@ class Crm::CustomersController < BaseCrmController dob = customer_params[:date_of_birth] address = customer_params[:address] nrc = customer_params[:nrc_no] + card_no = customer_params[:card_no] member_group_id = params[:member_group_id] if !member_group_id.nil? @@ -87,16 +90,17 @@ class Crm::CustomersController < BaseCrmController url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob,address: address,nrc:nrc, - member_group_id: member_group_id, - merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' + response = HTTParty.post(url, + :body => {name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + member_group_id: member_group_id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' }, - :timeout => 10 - ) + :timeout => 10 + ) rescue Net::OpenTimeout response = { status: false } end @@ -149,10 +153,12 @@ end dob = customer_params[:date_of_birth] address = customer_params[:address] nrc = customer_params[:nrc_no] + card_no = customer_params[:card_no] id = @crm_customer.membership_id member_group_id = params[:member_group_id] if id.nil? && !member_group_id.nil? + membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") merchant_uid = memberaction.merchant_account_id.to_s @@ -160,16 +166,17 @@ end url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob,address: address,nrc:nrc, - member_group_id: member_group_id, - merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' + response = HTTParty.post(url, + :body => { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc, + card_no:card_no,member_group_id: member_group_id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' }, - :timeout => 10 - ) + :timeout => 10 + ) rescue Net::OpenTimeout response = { status: false } end @@ -185,20 +192,22 @@ end end else + membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("update_membership_customer") merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob,address: address,nrc:nrc, - id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' + response = HTTParty.post(url, + :body => {name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' }, - :timeout => 10 + :timeout => 10 ) rescue Net::OpenTimeout response = { status: false } diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index dbcc4046..b4f902fc 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -1,4 +1,5 @@ class Crm::DiningQueuesController < BaseCrmController + load_and_authorize_resource before_action :set_dining_queue, only: [:show, :edit, :update, :destroy] # GET /crm/dining_queues diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 29e9082a..f480b95f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,6 +18,12 @@ class HomeController < ApplicationController elsif @employee.role == "cashier" session[:session_token] = @employee.token_session redirect_to origami_root_path + elsif @employee.role == "manager" + session[:session_token] = @employee.token_session + redirect_to dashboard_path + elsif @employee.role == "accountant" + session[:session_token] = @employee.token_session + redirect_to dashboard_path else render :index end diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb new file mode 100644 index 00000000..d2236caa --- /dev/null +++ b/app/controllers/oqs/edit_controller.rb @@ -0,0 +1,18 @@ +class Oqs::EditController < BaseOqsController + def index + assigned_item_id = params[:id] + assigned_item = AssignedOrderItem.find(assigned_item_id) + @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_code='#{ assigned_item.item_code }'"); + end + + def update + order_items_id = params[:order_items_id] + qty_weight = params[:qty_weight] + remarks = params[:remarks] + + order_item = OrderItem.find(order_items_id); + order_item.qty = qty_weight + order_item.remark = remarks + order_item.save + end +end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 64fd840d..692b9c4a 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -109,7 +109,7 @@ class Oqs::HomeController < BaseOqsController # queue_items.push(queue_item) # end # return queue_items - AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") + AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id @@ -118,6 +118,6 @@ class Oqs::HomeController < BaseOqsController left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") .where("assigned_order_items.delivery_status = #{status}") - .group("odt.order_items_id") + .group("assigned_order_items.assigned_order_item_id") end end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index a348951e..ff9ae413 100644 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -2,9 +2,31 @@ class Origami::CreditPaymentsController < BaseOrigamiController def index + @sale_id = params[:sale_id] + + # limit visa_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @creditcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "visa" + @creditcount = @creditcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_credit = total - @creditcount - others end def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote") + end end end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index f15b8545..e8376fc4 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -1,8 +1,6 @@ class Origami::CustomersController < BaseOrigamiController - #Form to add customer - + load_and_authorize_resource def index - - end # GET /crm/customers/1 @@ -54,6 +52,10 @@ class Origami::CustomersController < BaseOrigamiController if(id == "SAL") sale = Sale.find(params[:sale_id]) status = sale.update_attributes(customer_id: params[:customer_id]) + sale.sale_orders.each do |sale_order| + order = Order.find(sale_order.order_id) + status = order.update_attributes(customer_id: params[:customer_id]) + end else @booking = BookingOrder.find_by_order_id(params[:sale_id]) @orders = BookingOrder.where("booking_id = ? ", @booking.booking_id) diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 73038556..463f6dc6 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -1,4 +1,5 @@ class Origami::DiscountsController < BaseOrigamiController + authorize_resource :class => false #discount page show from origami index with selected order def index diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3f70ad01..1b0aa491 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -35,7 +35,7 @@ class Origami::HomeController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" + if sale.sale_status != "completed" && sale.sale_status != 'void' puts "enter" @sale_array.push(sale) if @status_order == 'order' diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index c51fcbb1..ef1c286a 100644 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -1,5 +1,7 @@ class Origami::MoveroomController < BaseOrigamiController - + + authorize_resource :class => false + def move_dining @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 461f8694..50f2c774 100644 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -1,4 +1,6 @@ class Origami::MovetableController < BaseOrigamiController + + authorize_resource :class => false def move_dining @tables = Table.all.active.order('status desc') diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 0119953f..f5a0023e 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -1,6 +1,6 @@ class Origami::PaymentsController < BaseOrigamiController - + authorize_resource :class => false def index end @@ -17,6 +17,8 @@ class Origami::PaymentsController < BaseOrigamiController unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) rebate_amount = Customer.get_membership_transactions(customer) + #shop detail + shop_details = Shop.find(1) # get member information member_info = Customer.get_member_account(customer) @@ -26,7 +28,7 @@ class Origami::PaymentsController < BaseOrigamiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) end end @@ -39,6 +41,7 @@ class Origami::PaymentsController < BaseOrigamiController @visacount= 0.0 @jcbcount= 0.0 @mastercount = 0.0 + @credit = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount @@ -51,8 +54,8 @@ class Origami::PaymentsController < BaseOrigamiController @accountable_type = '' if response["status"]==true response["data"].each do |res| - if res["accountable_type"] == "RebateAccount" - @balance = res["balance"] + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + @balance += res["balance"] # @accountable_type = res["accountable_type"] @accountable_type = "Rebate Balance" end @@ -75,6 +78,8 @@ class Origami::PaymentsController < BaseOrigamiController @jcbcount += spay.payment_amount elsif spay.payment_method == "master" @mastercount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount end end end @@ -89,6 +94,8 @@ class Origami::PaymentsController < BaseOrigamiController unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) + #shop detail + shop_details = Shop.find(1) # get member information member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer) @@ -99,7 +106,7 @@ class Origami::PaymentsController < BaseOrigamiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 95f63e58..314835a2 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,4 +1,5 @@ class Origami::RequestBillsController < BaseOrigamiController + # Print Request Bill and add to sale tables def print @sale = Sale.new @@ -20,8 +21,9 @@ class Origami::RequestBillsController < BaseOrigamiController end unique_code = "ReceiptBillPdf" + #shop detail + shop_details = Shop.find(1) # customer= Customer.where('customer_id=' +.customer_id) - customer= Customer.find(@sale_data.customer_id) # get member information member_info = Customer.get_member_account(customer) @@ -36,7 +38,7 @@ class Origami::RequestBillsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) # redirect_to origami_path(@sale_data.sale_id) end diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb new file mode 100644 index 00000000..8d805771 --- /dev/null +++ b/app/controllers/origami/room_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::RoomInvoicesController < BaseOrigamiController + def index + @room = DiningFacility.find(params[:room_id]) + puts "room bookig lenght" + @sale_array = Array.new + @room.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @room = DiningFacility.find(params[:room_id]) + @sale_array = Array.new + @room.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 88cdf315..70a5a380 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -1,11 +1,13 @@ class Origami::SaleEditController < BaseOrigamiController + # Index for sale item void OR edit def edit sale_id = params[:sale_id] @table_id = params[:table_id] @saleobj = Sale.find(sale_id) end + # create item void. make duplicate old record and update qty and price def item_void saleitemId = params[:sale_item_id] saleitemObj = SaleItem.find(saleitemId) @@ -19,4 +21,38 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end + + # make cancel void item + def item_void_cancel + saleitemId = params[:sale_item_id] + saleitemObj = SaleItem.find(saleitemId) + both = SaleItem.where('product_code=?',saleitemObj.product_code) + both.each do |item| + if item.qty.to_i > 0 + item.remark = nil + item.save + end + end + saleitemObj.destroy + end + + # remove all void items + def cancel_all_void + sale_id = params[:sale_id] + saleobj = Sale.find(sale_id) + saleobj.sale_items.each do |item| + if item.qty.to_i < 0 + item.destroy + else + item.remark = nil + end + item.save + end + end + + def apply_void + sale_id = params[:sale_id] + saleObj = Sale.find(sale_id) + saleObj.compute_without_void + end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb new file mode 100644 index 00000000..32e0ef7f --- /dev/null +++ b/app/controllers/origami/table_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::TableInvoicesController < BaseOrigamiController + def index + @table = DiningFacility.find(params[:table_id]) + puts "table bookig lenght" + @sale_array = Array.new + @table.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @table = DiningFacility.find(params[:table_id]) + @sale_array = Array.new + @table.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb new file mode 100644 index 00000000..bea37a21 --- /dev/null +++ b/app/controllers/origami/void_controller.rb @@ -0,0 +1,28 @@ +class Origami::VoidController < BaseOrigamiController + + def overall_void + + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + sale = Sale.find_by_sale_id(sale_id) + sale.payment_status = 'void' + sale.sale_status = 'void' + sale.save + + table_avaliable = true + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.sale.sale_status == 'new' + table_avaliable = false + end + end + + if table_avaliable == true + table.status = 'available' + table.save + end + + end + end + +end \ No newline at end of file diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index fa5af7e8..bdd3061a 100644 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -1,4 +1,5 @@ class PrintSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_print_setting, only: [:show, :edit, :update, :destroy] # GET /print_settings diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/bksale_items_controller.rb similarity index 74% rename from app/controllers/reports/sale_item_controller.rb rename to app/controllers/reports/bksale_items_controller.rb index eb7d3b86..1f349320 100644 --- a/app/controllers/reports/sale_item_controller.rb +++ b/app/controllers/reports/bksale_items_controller.rb @@ -1,5 +1,5 @@ -class Reports::SaleItemController < BaseReportController - +class Reports::SaleItemsController < BaseReportController + authorize_resource :class => false def index from, to, report_type = get_date_range_from_params diff --git a/app/controllers/reports/daily_sales_controller.rb b/app/controllers/reports/daily_sales_controller.rb new file mode 100644 index 00000000..6d99551d --- /dev/null +++ b/app/controllers/reports/daily_sales_controller.rb @@ -0,0 +1,17 @@ +class Reports::DailySalesController < BaseReportController + # authorize_resource :class => false + def index + from, to ,report_type = get_date_range_from_params + @sale_data = Sale.daily_sales_list(from,to) + @tax = SaleTax.get_tax(from,to) + respond_to do |format| + format.html + format.xls + end + end + + def show + + end + +end \ No newline at end of file diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_salesbk_controller.rb similarity index 72% rename from app/controllers/reports/daily_sale_controller.rb rename to app/controllers/reports/daily_salesbk_controller.rb index ba453f55..1a878aaa 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_salesbk_controller.rb @@ -1,5 +1,5 @@ -class Reports::DailySaleController < BaseReportController - +class Reports::DailySalesController < BaseReportController + authorize_resource :class => false def index from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) diff --git a/app/controllers/reports/sale_items_controller.rb b/app/controllers/reports/sale_items_controller.rb new file mode 100644 index 00000000..81f7af01 --- /dev/null +++ b/app/controllers/reports/sale_items_controller.rb @@ -0,0 +1,19 @@ +class Reports::SaleItemsController < BaseReportController + # authorize_resource :class => false + def index + + from, to, report_type = get_date_range_from_params + + @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type) + + respond_to do |format| + format.html + format.xls + end + end + + def show + + end + +end \ No newline at end of file diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index 90e6a304..54f27480 100644 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -1,4 +1,5 @@ class Settings::AccountsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_account, only: [:show, :edit, :update, :destroy] # GET /settings/accounts diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index b397d68d..0808c0a7 100644 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -1,4 +1,5 @@ class Settings::CashierTerminalsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_cashier_terminal, only: [:show, :edit, :update, :destroy] # GET /settings/cashier_terminals diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index dc7093f3..07656470 100644 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -1,5 +1,5 @@ class Settings::EmployeesController < ApplicationController - # load_and_authorize_resource + load_and_authorize_resource before_action :set_employee, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index ad7311f2..f386aecd 100644 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -1,4 +1,5 @@ class Settings::MembershipActionsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy] # GET /settings/membership_actions diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb index cfd672d0..36bb0092 100644 --- a/app/controllers/settings/membership_settings_controller.rb +++ b/app/controllers/settings/membership_settings_controller.rb @@ -1,4 +1,5 @@ class Settings::MembershipSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_membership_setting, only: [:show, :edit, :update, :destroy] # GET /settings/membership_settings diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb index c2a521ae..8ca9cfb4 100644 --- a/app/controllers/settings/menu_categories_controller.rb +++ b/app/controllers/settings/menu_categories_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuCategoriesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_category, only: [:show, :edit, :update, :destroy] before_action :set_settings_menu, only: [:new] diff --git a/app/controllers/settings/menu_item_attributes_controller.rb b/app/controllers/settings/menu_item_attributes_controller.rb index 1433cf34..162325a2 100644 --- a/app/controllers/settings/menu_item_attributes_controller.rb +++ b/app/controllers/settings/menu_item_attributes_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemAttributesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_attribute, only: [:show, :edit, :update, :destroy] # GET /settings/menu_item_attributes diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index 2b1fcecf..fd651e5e 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemInstancesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy] before_action :set_settings_menu_item, only: [ :show, :edit, :new, :update] diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb index 4a3a44b7..41679796 100644 --- a/app/controllers/settings/menu_item_options_controller.rb +++ b/app/controllers/settings/menu_item_options_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemOptionsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_option, only: [:show, :edit, :update, :destroy] # GET /settings/menu_item_options diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index fa6ac158..1a5ada31 100644 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -1,4 +1,5 @@ class Settings::MenusController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu, only: [:show, :edit, :update, :destroy] # GET /settings/menus diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index 5a540ddb..9fe78de4 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -1,4 +1,5 @@ class Settings::OrderQueueStationsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy] # GET /settings/order_queue_stations diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb index f3ac595e..ecbbcced 100644 --- a/app/controllers/settings/payment_method_settings_controller.rb +++ b/app/controllers/settings/payment_method_settings_controller.rb @@ -1,4 +1,5 @@ class Settings::PaymentMethodSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_payment_method_setting, only: [:show, :edit, :update, :destroy] # GET /settings/payment_method_settings diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 1064055b..992f637a 100644 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -1,4 +1,5 @@ class Settings::TaxProfilesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_tax_profile, only: [:show, :edit, :update, :destroy] # GET /settings/tax_profiles diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 08a6f189..49505854 100644 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -1,4 +1,5 @@ class Settings::ZonesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_zone, only: [:show, :edit, :update, :destroy] # GET /settings/zones diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb new file mode 100644 index 00000000..0f370c96 --- /dev/null +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -0,0 +1,18 @@ +class Transactions::CreditNotesController < ApplicationController + before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] + + # GET /transactions/sales + # GET /transactions/sales.json + def index + + @sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) + + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end + + end + end \ No newline at end of file diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 35cefe6f..8303780f 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -1,4 +1,5 @@ class Transactions::OrdersController < ApplicationController + load_and_authorize_resource except: [:create] def index filter = params[:filter] diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 54432c38..19803c0d 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -1,4 +1,5 @@ class Transactions::SalesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] # GET /transactions/sales diff --git a/app/helpers/reports/daily_sales_helper.rb b/app/helpers/reports/daily_sales_helper.rb new file mode 100644 index 00000000..eb04c7b9 --- /dev/null +++ b/app/helpers/reports/daily_sales_helper.rb @@ -0,0 +1,2 @@ +module Reports::DailySalesHelper +end diff --git a/app/helpers/reports/dailysales_helper.rb b/app/helpers/reports/dailysales_helper.rb new file mode 100644 index 00000000..94e34c27 --- /dev/null +++ b/app/helpers/reports/dailysales_helper.rb @@ -0,0 +1,2 @@ +module Reports::DailysalesHelper +end diff --git a/app/helpers/reports/sale_items_helper.rb b/app/helpers/reports/sale_items_helper.rb new file mode 100644 index 00000000..63e884d7 --- /dev/null +++ b/app/helpers/reports/sale_items_helper.rb @@ -0,0 +1,2 @@ +module Reports::SaleItemsHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 2b28ab61..5e5fb4f3 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -4,30 +4,84 @@ class Ability def initialize(user) user ||= Employee.new - if user.role? :administrator + if user.role == "administrator" can :manage, :all - elsif user.role? :cashier - can :read, Order - can :update, Order - can :completed_order_item, Order + elsif user.role == "manager" + + can :manage, Menu + can :manage, MenuCategory + can :manage, MenuItemAttribute + can :manage, MenuItemInstance + can :manage, MenuItemOption + can :manage, SetMenuItem + can :manage, OrderQueueStation + can :manage, Zone + can :manage, CashierTerminal + can :manage, Employee + # can :manage, MembershipSetting + # can :manage, MembershipAction + # can :manage, PaymentMethodSetting + can :manage, TaxProfile + can :manage, PrintSetting + can :manage, Account + + can :manage, Order + can :manage, Sale + + can :manage, Customer + + can :index, :dailysale + can :index, :saleitem + + can :add_customer, Customer + can :update_sale_by_customer, Customer + + can :index, :discount + can :create, :discount + + can :show, :payment + can :create, :payment + can :reprint, :payment + + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom + + elsif user.role == "cashier" + + can :read, Order + can :update, Order - can :read, Sale - can :update, Sale + can :read, Sale + can :update, Sale + can :add_customer, Customer + can :update_sale_by_customer, Customer + + can :index, :discount + can :create, :discount + + can :show, :payment + can :create, :payment + can :reprint, :payment + + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom - elsif user.role? :accountant + elsif user.role == "accountant" - can :read, Order - can :update, Order - can :completed_order_item, Order - - can :read, Sale - can :update, Sale - can :manual_complete_sale, Sale + can :index, :dailysale + can :index, :saleitem + can :index, :receiptno + can :show, :dailysale + can :show, :saleitem + can :show, :receiptno end - end -end \ No newline at end of file +end diff --git a/app/models/order.rb b/app/models/order.rb index 78585b52..018013e4 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -27,7 +27,7 @@ class Order < ApplicationRecord if self.new_booking booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", - :checkin_at => Time.now.utc, :checkin_by => self.employee_name, + :checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name, :booking_status => "assign" }) table = DiningFacility.find(self.table_id) table.status = "occupied" diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 04619379..bd2e85ca 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -22,7 +22,8 @@ class OrderQueueStation < ApplicationRecord #Assign OQS id to order Items oqs_stations.each do |oqs| - is_auto_printed = false + is_auto_printed = false + oqs_order_items = [] #Get List of items - pq_items = JSON.parse(oqs.processing_items) @@ -37,15 +38,18 @@ class OrderQueueStation < ApplicationRecord # else AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - # end - - # Auto Printing - if oqs.auto_print && is_auto_printed == false - print_slip(oqs, order, order_items) - is_auto_printed = true - end + oqs_order_items.push(order_item) + # end end end + end + # Auto Printing + # ToDo per item per printer + if oqs.auto_print && is_auto_printed == false + if oqs_order_items.length > 0 + print_slip(oqs, order, oqs_order_items) + is_auto_printed = true + end end end end @@ -57,7 +61,7 @@ class OrderQueueStation < ApplicationRecord 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, print_status="") + order_queue_printer.print_order_summary(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 diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index f8fb5027..bbeafecf 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -22,14 +22,14 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Query for per order - def print_order_summary(oqs, order_id, print_status) + def print_order_summary(oqs, order_id, order_items, print_status) #Use CUPS service #Generate PDF - #Print + #Print order=print_query('order_summary', order_id) # For Print Per Item if oqs.cut_per_item - order.each do|odi| + order_items.each do|odi| filename = "tmp/order_item_#{odi.item_name}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -46,7 +46,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Order Summary else filename = "tmp/order_summary_#{ order_id }" + ".pdf" - pdf = OrderSummaryPdf.new(order, print_status) + pdf = OrderSummaryPdf.new(order, print_status, order_items) pdf.render_file filename if oqs.print_copy self.print(filename, oqs.printer_name) @@ -103,7 +103,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) if type == "order_item" - OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -112,7 +112,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .where("order_items.item_code = '#{ id }'") .group("order_items.item_code") elsif type == "order_summary" - OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -122,7 +122,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .group("order_items.order_items_id") else # order summary for booking - OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 4b7287db..8e389e79 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details) pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") diff --git a/app/models/sale.rb b/app/models/sale.rb index f79d8642..8f7f17d8 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -21,9 +21,9 @@ class Sale < ApplicationRecord "daily" => 0, "monthly" => 1, "yearly" => 2 - } - - SALE_STATUS_COMPLETED = "completed" + } + SALE_STATUS_OUTSTANDING = "outstanding" + SALE_STATUS_COMPLETED = "completed" def generate_invoice_from_booking(booking_id, requested_by) booking = Booking.find(booking_id) @@ -98,7 +98,7 @@ class Sale < ApplicationRecord order.save booking.sale_id = self.id - booking.checkout_at = Time.now.utc + booking.checkout_at = Time.now.utc.getlocal booking.checkout_by = requested_by.name booking.save @@ -115,7 +115,7 @@ class Sale < ApplicationRecord def generate_invoice_by_items (items, requested_by) taxable = true self.requested_by = requested_by - self.requested_at = DateTime.now.utc + self.requested_at = DateTime.now.utc.getlocal items.each do |item| add_item(item) @@ -185,7 +185,7 @@ class Sale < ApplicationRecord 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 + total_taxable = total_taxable + (item.taxable_price * item.qty) end apply_tax (total_taxable) @@ -199,6 +199,31 @@ class Sale < ApplicationRecord end + def compute_without_void + sales_items = self.sale_items + + #Computation Fields + subtotal_price = 0 + total_taxable = 0 + rounding_adjustment = 0 + + sales_items.each do |item| + if item.remark != 'void' + #compute each item and added to total + subtotal_price = subtotal_price + item.price + total_taxable = total_taxable + item.taxable_price + end + end + + apply_tax (total_taxable) + self.total_amount = subtotal_price + self.total_discount = total_discount + self.grand_total = (self.total_amount - self.total_discount) + self.total_tax + #compute rounding adjustment + adjust_rounding + + self.save! + end # Tax Calculate def apply_tax(total_taxable) #if tax is not apply create new record @@ -354,28 +379,28 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) mc.name as menu_category_name, mc.id as menu_category_id ") .group('mi.id') - .order("mi.menu_category_id") - - query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id - JOIN menu_items mi ON i.product_code = mi.item_code" + - " JOIN menu_categories mc ON mc.id = mi.menu_category_id + .order("mi.menu_category_id") + + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id + JOIN menu_items mi ON i.product_code = mi.item_code" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id JOIN employees ea ON ea.id = sales.cashier_id") - + query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) - + case report_type.to_i when REPORT_TYPE["daily"] return query when REPORT_TYPE["monthly"] - - return query.group("MONTH(date)") + + return query.group("MONTH(date)") when REPORT_TYPE["yearly"] - return query.group("YEAR(date)") + return query.group("YEAR(date)") end - + end private diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 950334cb..e4ad5364 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -9,7 +9,6 @@ class SalePayment < ApplicationRecord attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status def process_payment(invoice, action_by, cash_amount, payment_method) - self.sale = invoice self.received_amount = cash_amount amount_due = invoice.grand_total @@ -28,7 +27,7 @@ class SalePayment < ApplicationRecord when "cash" payment_status = cash_payment when "creditnote" - if !self.customer_id.nil? + if !self.sale.customer_id.nil? payment_status = creditnote_payment(self.customer_id) end when "visa" @@ -54,7 +53,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit 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) - + return true, self.save else #record an payment in sale-audit @@ -94,10 +93,15 @@ class SalePayment < ApplicationRecord sale_data = Sale.find_by_sale_id(sale_id) if sale_data + others = 0 + sale_data.sale_payments.each do |sale_payment| + others = others + sale_payment.payment_amount + end + redeem_prices = sale_data.grand_total -others # Control for Paypar Cloud begin response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :body => { generic_customer_id:membership_id,total_amount: redeem_prices,total_sale_transaction_amount: sale_data.grand_total,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -137,7 +141,7 @@ class SalePayment < ApplicationRecord self.payment_method = "creditnote" self.payment_amount = self.received_amount self.customer_id = self.customer_id - self.outstanding_amount = 0 - self.received_amount + self.outstanding_amount = 0 - self.received_amount.to_f self.payment_status = "outstanding" payment_method = self.save! @@ -202,10 +206,7 @@ class SalePayment < ApplicationRecord customer_data = Customer.find_by_customer_id(self.sale.customer_id) membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) - puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm' - puts membership_data.to_json - puts "amountttttttttttttttttttttt" - puts self.received_amount + if membership_data["status"]==true self.payment_method = "paypar" self.payment_amount = self.received_amount @@ -266,8 +267,7 @@ class SalePayment < ApplicationRecord def rebat(sObj) rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) - puts "eeeeeeeeeeeeeeeeeeeeeeee" - puts rebate_prices + generic_customer_id = sObj.customer.membership_id if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments @@ -292,7 +292,7 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 4b7559b1..6d6346f9 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -18,24 +18,29 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 14 - self.item_font_size = 12 + self.header_font_size = 12 + self.item_font_size = 10 - text "#{ order_item.dining+print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule move_down 5 #order_info - order_info(order_item.order_by,order_item.order_at) + order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items order_items(order_item, options) end # Write Order Information to PDF - def order_info(order_by, order_at) + def order_info(order_no, order_by, order_at) y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + move_down 5 + y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end @@ -43,7 +48,7 @@ class OrderItemPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 176749b8..d85a5916 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -1,6 +1,6 @@ class OrderSummaryPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(order, print_status) + def initialize(order, print_status, order_items = nil) self.page_width = 210 self.page_height = 1450 self.margin = 5 @@ -20,22 +20,30 @@ class OrderSummaryPdf < Prawn::Document self.header_font_size = 12 self.item_font_size = 10 - text "#{ order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule move_down 5 #order_info - order_info(order[0].order_by,order[0].order_at) + order_info(order[0].order_id, order[0].order_by,order[0].order_at) # order items - order_items(order) - + if order_items == nil + order_items(order) + else + order_items(order_items) + end end # Write Order Information to PDF - def order_info(order_by, order_at) + def order_info(order_no, order_by, order_at) y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + move_down 5 + y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end @@ -43,7 +51,7 @@ class OrderSummaryPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -68,6 +76,7 @@ class OrderSummaryPdf < Prawn::Document #Add Order Item add_order_items(order_item) + end # Add order items under order info @@ -84,11 +93,11 @@ class OrderSummaryPdf < Prawn::Document # text_box "#{odi.qty}", :at =>[self.item_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix # } bounding_box([0,y_position], :width => self.item_width) do - text "#{odi.item_name}", :size => self.item_font_size,:align => :left, :height => self.item_height + text "#{odi.item_name}", :size => self.item_font_size,:align => :left end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{odi.qty}", :size => self.item_font_size,:align => :left, :height => self.item_height + text "#{odi.qty}", :size => self.item_font_size,:align => :left end move_down 5 @@ -104,6 +113,10 @@ class OrderSummaryPdf < Prawn::Document move_down 5 end + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, (self.page_width - self.margin) + move_down 5 end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 96e16cf4..b156e2c2 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) self.page_width = 210 self.page_height = 2500 self.margin = 5 @@ -24,13 +24,12 @@ class ReceiptBillPdf < Prawn::Document self.header_font_size = 10 self.item_font_size = 8 - header( "Beauty In the Pot", printer_settings.name) + header( shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name) line_items(sale_items) - items_account(item_price_by_accounts) all_total(sale_data) @@ -39,16 +38,21 @@ class ReceiptBillPdf < Prawn::Document end customer(customer_name) + + items_account(item_price_by_accounts) footer end - def header (printer_name, name) - text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center + def header (shop_details) + move_down 7 + text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 - text "#{name}", :size => self.header_font_size,:align => :center + text "#{shop_details.address}", :size => self.item_font_size,:align => :center # move_down self.item_height move_down 5 + text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center + move_down 5 stroke_horizontal_rule end @@ -61,19 +65,10 @@ class ReceiptBillPdf < Prawn::Document text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right end move_down 5 - # y_position = cursor - # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - # text "Customer:", :size => self.item_font_size,:align => :left - # end - # bounding_box([self.label_width,y_position], :width =>self.item_width) do - # text "#{customer_name}" , :size => self.item_font_size,:align => :left - # end - # move_down 5 - y_position = cursor bounding_box([0, y_position], :width =>self.item_width) do text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left @@ -86,27 +81,26 @@ class ReceiptBillPdf < Prawn::Document end move_down 5 - # bounding_box([self.label_width,y_position], :width =>self.item_width) do - # text "#{customer_name}" , :size => self.item_font_size,:align => :left - # end - # move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left - end - bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right + 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].checkin_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left end + + # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , + # :size => self.item_font_size,:align => :right + # end + move_down 5 stroke_horizontal_rule - move_down 5 end def line_items(sale_items) + move_down 5 y_position = cursor - + move_down 5 pad_top(15) { # @item_width.to_i + @half_qty.to_i text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix @@ -114,10 +108,8 @@ class ReceiptBillPdf < Prawn::Document text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } - - move_down 5 + move_down -5 stroke_horizontal_rule - add_line_item_row(sale_items) end @@ -142,7 +134,7 @@ class ReceiptBillPdf < Prawn::Document text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } - move_down 3 + move_down 1 end stroke_horizontal_rule @@ -158,20 +150,6 @@ class ReceiptBillPdf < Prawn::Document move_down 5 end - def items_account(item_price_by_accounts) - y_position = cursor - item_price_by_accounts.each do |ipa| - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right - end - move_down 5 - end - end - def all_total(sale_data) item_name_width = self.item_width y_position = cursor @@ -267,7 +245,7 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Rebate Amount", :size => self.item_font_size,:align => :left + 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 "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right @@ -278,10 +256,10 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Redeem Amount", :size => self.item_font_size,:align => :left + text "Current Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right + text "(#{ res["redeem"] })" , :size => self.item_font_size,:align => :right end end @@ -289,22 +267,23 @@ class ReceiptBillPdf < Prawn::Document end end if member_info["status"] == true + balance = 0.0 member_info["data"].each do |res| - if res["accountable_type"]== "RebateAccount" - - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Balance", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right - end + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + balance = balance + res["balance"] 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 Balance", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ balance }" , :size => self.item_font_size,:align => :right + end end end @@ -317,7 +296,23 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ customer_name }" , :size => self.item_font_size,:align => :right - end + end + end + + def items_account(item_price_by_accounts) + move_down 5 + stroke_horizontal_rule + move_down 5 + y_position = cursor + item_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right + end + end end def footer @@ -331,3 +326,4 @@ class ReceiptBillPdf < Prawn::Document end end + diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index eb121c14..d52c0456 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -11,24 +11,20 @@ <% str="[\"#{msg['name']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> - <%= str %> + <%= str %> <% end -%>

- - - - + + <%= f.radio_button :salutation,"Mr", :class => "salutation mr", :value=>"Mr", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Mrs", :class => "salutation mrs", :value=>"Mrs", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Miss", :class => "salutation miss", :value=>"Miss", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
"> @@ -37,18 +33,16 @@ <% str="[\"#{msg['name']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> - <%= str %> + <%= str %> <% end -%>

- - + + <%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male", :style=>"width: 30px"%> + + <%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female", :style=>"width: 30px"%>
@@ -62,7 +56,7 @@ <% str="[\"#{msg['company']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> - <%= str %> + <%= str %> <% end -%>
"> @@ -72,7 +66,7 @@ <% str="[\"#{msg['contact_no']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> - <%= str %> + <%= str %> <% end -%>
@@ -83,7 +77,7 @@ <% str="[\"#{msg['contact_no']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> - <%= str %> + <%= str %> <% end -%> diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 67dc46f4..b3c1fce7 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -47,7 +47,7 @@ <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <% if crm_customer.customer_id != "CUS-00001" && crm_customer.customer_id != "CUS-000000000" %> @@ -152,7 +152,6 @@ $(document).on('click',".customer_tr",function(){ $("#new_customer").attr('class', 'simple_form edit_customer'); var id = "edit_customer_"+customer_id; - alert(id) $("#new_customer").attr('id', id); $(".edit_customer").attr('id', id); diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 0dead477..5c4bf7c8 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -55,12 +55,16 @@
+ <% puts "'''''''''''''''''''" + puts @response + if @response["status"] == true %> <% if @response["status"] == true %> <% end %> + <% end %> @@ -99,28 +103,22 @@
Membership TransactionsCurrent Balance : <%= @response["data"][0]["balance"]%>
Date Redeem
- - - - - - - - + + + + + - <% @order_items.each do |order_item| %> + <% @orders.each do |order| %> - - - - - - - - + + + + + <% end %> @@ -135,62 +133,33 @@
Order IDMenu ItemQTYUnit Price OptionStatusWaiterCreated at Order ID TypeOrder statusOrder dateItems Count
<%= order_item.order_id %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y") %><%= order.order_id %><%= order.order_type %><%= order.status %><%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %>
- - - - - - + + + + + + + - <% @sale_items.each do |sale_item| %> - - - - - - - - - - <% end %> + <% @sales.each do |sale| %> + + + + + + + + + + <% end %>
Sale ID Menu ItemQTYUnit Price Tax PriceCreated AtSale Id Receipt no Grand totalTax amountCashierSales statusReceipt Date
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
<%= sale.sale_id %><%= sale.receipt_no %><%= sale.grand_total rescue '-' %><%= sale.total_tax %><%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %>
-
-

Sale Details

-
- - - - - - - - - - - - - - <% @sale_items.each do |sale_item| %> - - - - - - - - - - <% end %> - -
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
-
-
+ diff --git a/app/views/layouts/OQS.html.erb b/app/views/layouts/OQS.html.erb index 9f736336..102edba2 100644 --- a/app/views/layouts/OQS.html.erb +++ b/app/views/layouts/OQS.html.erb @@ -23,7 +23,6 @@ <% end %> <%= yield %> - diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index c528003d..05b74b7a 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -33,13 +33,14 @@ @@ -49,10 +50,13 @@ <% if current_login_employee %>
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1d4991e6..d2b57a7a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,7 +18,16 @@ <%= render 'layouts/header' %>
<% flash.each do |type, message| %> -
+ <% + if type== "warning" + alert = "alert-warning" + elsif type== "notice" + alert = "alert-success" + else + alert = "alert-danger" + end + %> +
<%= message %>
diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb new file mode 100644 index 00000000..15d48144 --- /dev/null +++ b/app/views/oqs/edit/index.html.erb @@ -0,0 +1,27 @@ +
+
+
+
Update Quantity
+
+
+

<%= @order_item[0].item_name + " - [" + @order_item[0].qty.to_s + "]" %>

+
+ + +
+
+ + +
+
+ + Back + + +
+
+
+
+
+
+ diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 85858a02..ed704dcb 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -29,7 +29,7 @@ -
+
@@ -39,9 +39,11 @@

- - <%= qid.zone %> - - + <%= qid.type %> - + <%= qid.zone %> + <%= qid.order_id %> +

+

<%= qid.item_name %> [x @@ -55,7 +57,7 @@

Order at - <%= qid.created_at.strftime("%Y %m %d") %> + <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> - <%= qid.item_order_by %> @@ -89,15 +91,13 @@

- - <%= qid.zone %> - - - - <%= qid.item_name %> - [x - - <%= qid.qty %> - ] + <%= qid.type %> - + <%= qid.zone %> + <%= qid.order_id %> +

+

+ <%= qid.item_name %> [x + <%= qid.qty %> ]

<%= qid.options == "[]"? "" : qid.options %>

@@ -105,7 +105,7 @@

Order at - <%= qid.created_at.strftime("%Y %m %d") %> + <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> - <%= qid.item_order_by %> @@ -116,8 +116,9 @@

- <% @@ -163,7 +164,7 @@
-
+
diff --git a/app/views/origami/credit_payments/create.json.jbuilder b/app/views/origami/credit_payments/create.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/credit_payments/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/credit_payments/index.html.erb b/app/views/origami/credit_payments/index.html.erb index e4f97119..dc2b5b85 100644 --- a/app/views/origami/credit_payments/index.html.erb +++ b/app/views/origami/credit_payments/index.html.erb @@ -1 +1,166 @@ -hello Credit + +
+ +
+
+
+

CREDIT PAYMENT

+
+
+
+
+
+
+ + +
+
+
+ <% if @creditcount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+ +
+ +
+
+ + diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 0cd7d85b..489487ab 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -41,7 +41,7 @@ <% if @crm_customers.count > 0 %> <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <% if crm_customer.customer_id != "CUS-00000" && crm_customer.customer_id != "CUS-00000000" %> @@ -88,18 +88,14 @@

- - - - + + <%= f.radio_button :salutation,"Mr", :class => "salutation mr", :value=>"Mr", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Mrs", :class => "salutation mrs", :value=>"Mrs", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Miss", :class => "salutation miss", :value=>"Miss", :style=>"width: 30px"%> + + <%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
"> @@ -115,12 +111,10 @@

- - + + <%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male", :style=>"width: 30px"%> + + <%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female", :style=>"width: 30px"%>
@@ -161,10 +155,10 @@ <%= f.input :address, :class => "form-control col-md-6 address" %>
-
+
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> @@ -327,16 +321,4 @@ }) -class CreateDiningQueues < ActiveRecord::Migration[5.1] - def change - create_table :dining_queues do |t| - t.string :name - t.string :contact_no - t.string :queue_no - t.string :status - t.references :dining_facility, foreign_key: true - t.timestamps - end - end -end diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 45ab4b2b..e3cca128 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -199,31 +199,26 @@ $(document).ready(function(){ case 'num': var input_value = $(this).attr("data-value"); if (original_value == "0.0"){ - $('#discount-amount').val(input_value); - // update_balance(); + $('#discount-amount').val(input_value); } else{ - $('#discount-amount').val(original_value + '' + input_value); - // update_balance(); + $('#discount-amount').val(original_value + '' + input_value); } break; case 'add': var input_value = $(this).attr("data-value"); amount = parseInt(input_value); - $('#discount-amount').val(amount); - // update_balance(); + $('#discount-amount').val(amount); break; case 'del' : var discount_text=$('#discount-amount').val(); - $('#discount-amount').val(discount_text.substr(0,discount_text.length-1)); - // update_balance(); + $('#discount-amount').val(discount_text.substr(0,discount_text.length-1)); break; case 'clr': - $('#discount-amount').val("0.0"); - // update_balance(); + $('#discount-amount').val("0.0"); break; } event.handled = true; @@ -254,19 +249,24 @@ $(document).ready(function(){ // Select for account types $(".accounts-type").on('click', function(e){ + var account_id = $(this).attr('id').substr(8); + if($(this).hasClass('selected-account') == true){ $(this).removeClass('selected-account'); + $(".item-row").each(function(i){ + if($(this).children().find("#item-account-type").text() == account_id){ + $(this).removeClass("selected-item"); + } + }); } else { $(this).addClass('selected-account'); - } - - var account_id = $(this).attr('id').substr(8); - $(".item-row").each(function(i){ - if($(this).children().find("#item-account-type").text() == account_id){ - $(this).addClass("selected-item"); - } - }); + $(".item-row").each(function(i){ + if($(this).children().find("#item-account-type").text() == account_id){ + $(this).addClass("selected-item"); + } + }); + } }); // Calculate Net Discount for Payment @@ -332,13 +332,7 @@ $(document).ready(function(){ var sale_id = $('#sale-id').text(); var discount_items = JSON.stringify(get_discount_item_rows()); var overall_discount = $("#order-discount").text(); - var sub_total = $('#order-sub-total').text(); - // var sale_item_id = $('.selected-item').attr('id').substr(0,16); - // var sub_total = $('#order-sub-total').text(); - // var grand_total = $('#order-grand-total').text(); - // var discount_type = $('#discount-type').val(); - // var discount_value = $('#discount-amount').val(); - // var discount_amount = discount_value; + var sub_total = $('#order-sub-total').text(); var ajax_url = "/origami/" + sale_id + "/discount"; var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount }; @@ -354,30 +348,12 @@ $(document).ready(function(){ } else { window.location.href = "/origami/room/" + result.table_id - } - - // window.history.back(); + } } }); }); }); -/* For Receipt - Update Balance */ -function update_balance(){ - var discount_amount = $('#discount-amount').val(); - var sub_total = $('#order-sub-total').text(); - var tax = $('#order-Tax').text(); - - // For Percentage Discount - // if(discount_type == 1){ - // discount_amount=(sub_total*discount_amount)/100; - // } - - var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount; - $('#order-discount').text(discount_amount); - $('#order-grand-total').text(total); -} - /* Remove Selection */ function selection_remove(){ $(".item-row").removeClass("selected-item"); diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 08f53998..5888bb3e 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -38,12 +38,21 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- Zone <%= table.zone_id %>
- Table <%= table.name %> ( <%= table.seater %> Seat ) -
-
+ <% if table.get_booking.nil? %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% else %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% end %> <% else %>
@@ -121,7 +130,7 @@ $(function() { var timer; function start() { - timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 30000); //10000 + timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000 }; function stop() { diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73f298ec..2e852b7c 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -38,16 +38,22 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- <%= table.name %> - <% if table.get_booking.nil? %> - billed - <% else %> - new - <% end %> -
-
+ <% if table.get_booking.nil? %> +
+
+ <%= table.name %> + billed +
+
+
+ <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> <% else %>
@@ -108,9 +114,9 @@
<% if @status_order == 'order' && @status_sale != 'sale' %> -
ORDER DETAILS
+
ORDER DETAILS | Table <%= @dining.name rescue "" %>
<% elsif @status_sale == 'sale' %> -
INVOICE DETAILS
+
INVOICE DETAILS | Table <%= @dining.name rescue "" %>
<% end %>
@@ -126,13 +132,14 @@

Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

- +
- -

Customer : <%= @customer.name %>

+ <%if @customer %> + +

Customer : <%= @customer.name rescue "" %>

+ <%end%>
-
@@ -174,7 +181,7 @@ count = 0 @order_items.each do |order_item | count += 1 - sub_total = sub_total + order_item.price + sub_total = sub_total + (order_item.price * order_item.qty) unless order_item.price == 0 %> @@ -241,18 +248,18 @@ %>
- <% - end - @sale_array.each do |sale| + <% end %> +

+ Pending Payment + <% @sale_array.each do |sale| if @sale_array.size > 1 unless sale.receipt_no == @sale_array[0].receipt_no %> -

- Pending Payment + - +
Receipt No - <%= sale.receipt_no %>
<% @@ -288,16 +295,21 @@ - + <% end %> - + <% end %>
diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 92ffc7f1..d2c065a1 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -189,7 +189,7 @@ <% if @sale_status != 'completed' %> <% end %> - +

diff --git a/app/views/origami/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb new file mode 100644 index 00000000..7ea799ae --- /dev/null +++ b/app/views/origami/room_invoices/show.html.erb @@ -0,0 +1,147 @@ +
+
+ + <% @sale_array.each do |sale| %> +
+ <% if sale.id == @sale.id %> +
+ <%= sale.receipt_no %> +
+ <% else %> +
+ <%= sale.receipt_no %> +
+ <% end %> +
+ <% end %> +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @sale.receipt_no rescue '' %> +

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + +

Customer : <%= @customer.name rescue "" %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 381edb25..584410d6 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -38,16 +38,21 @@
<% @tables.each do |table| %> <% if table.status == 'occupied' %> -
-
- <%= table.name %> - <% if table.get_booking.nil? %> - billed - <% else %> - new - <% end %> -
-
+ <% if table.get_booking.nil? %> +
+
+ <%= table.name %> + billed +
+
+ <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> <% else %>
@@ -108,9 +113,9 @@
<% if @status == 'order' %> -
ORDER DETAILS
+
ORDER DETAILS | Table <%= @room.name rescue "" %>
<% elsif @status_sale == 'sale' %> -
INVOICE DETAILS
+
INVOICE DETAILS | Table <%= @room.name rescue "" %>
<% end %>
@@ -129,8 +134,10 @@
+ <%if @customer %> -

Customer : <%= @customer.name %>

+

Customer : <%= @customer.name %>

+ <%end%>
@@ -148,7 +155,7 @@ sub_total = 0 if @status == "sale" @obj.sale_items.each do |sale_item| - sub_total = sub_total + sale_item.price + sub_total = sub_total + sale_item.price %> <% unless sale_item.price == 0 %> @@ -165,7 +172,7 @@ if @status == 'order' unless @order_items.nil? @order_items.each do |order_item | - sub_total = sub_total + order_item.price + sub_total = sub_total + (order_item.price * order_item.qty) unless order_item.price == 0 %> @@ -250,7 +257,7 @@ - +
diff --git a/app/views/origami/sale_edit/item_void_cancel.json.jbuilder b/app/views/origami/sale_edit/item_void_cancel.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/sale_edit/item_void_cancel.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb new file mode 100644 index 00000000..d5cbe84d --- /dev/null +++ b/app/views/origami/table_invoices/index.html.erb @@ -0,0 +1,82 @@ +
+
+ <% @sale_array.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+ + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @sale.receipt_no rescue '' %> +

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+ + +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb new file mode 100644 index 00000000..ee66f9a3 --- /dev/null +++ b/app/views/origami/table_invoices/show.html.erb @@ -0,0 +1,147 @@ +
+
+ + <% @sale_array.each do |sale| %> +
+ <% if sale.id == @sale.id %> +
+ <%= sale.receipt_no %> +
+ <% else %> +
+ <%= sale.receipt_no %> +
+ <% end %> +
+ <% end %> +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @sale.receipt_no rescue '' %> +

+
+
+

Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + +

Customer : <%= @customer.name rescue "" %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/daily_sale/index.html.erb index a2403045..7c2a8c61 100644 --- a/app/views/reports/daily_sale/index.html.erb +++ b/app/views/reports/daily_sale/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sale_index_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %>
diff --git a/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb b/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..3a5d788c --- /dev/null +++ b/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb @@ -0,0 +1,151 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ + +
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/reports/daily_sales/index.html.erb b/app/views/reports/daily_sales/index.html.erb new file mode 100644 index 00000000..7c2a8c61 --- /dev/null +++ b/app/views/reports/daily_sales/index.html.erb @@ -0,0 +1,190 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + + <% unless @sale_data.empty? %> + + + <% 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 %> + + + + + + + + + + + + + + + + + + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateVoid AmountMpu SalesMaster SalesVisa SalesJcb SalesPaypar SalesCash SalesCredit SalesFOC Sales(Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
+
+ + + \ No newline at end of file diff --git a/app/views/reports/daily_sales/index.xls.erb b/app/views/reports/daily_sales/index.xls.erb new file mode 100644 index 00000000..67e76e3c --- /dev/null +++ b/app/views/reports/daily_sales/index.xls.erb @@ -0,0 +1,116 @@ +
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + + <% unless @sale_data.empty? %> + + + <% 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 %> + + + + + + + + + + + + + + + + + + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateVoid AmountMpu SalesMaster SalesVisa SalesJcb SalesPaypar SalesCash SalesCredit SalesFOC Sales(Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
\ No newline at end of file diff --git a/app/views/reports/sale_item/index.html.erb b/app/views/reports/sale_item/index.html.erb index cce5a210..a3b460fc 100644 --- a/app/views/reports/sale_item/index.html.erb +++ b/app/views/reports/sale_item/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_item_index_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %>
diff --git a/app/views/reports/sale_items/_shift_sale_report_filter.html.erb b/app/views/reports/sale_items/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..7f95b6b9 --- /dev/null +++ b/app/views/reports/sale_items/_shift_sale_report_filter.html.erb @@ -0,0 +1,156 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ + +
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/reports/sale_items/index.html.erb b/app/views/reports/sale_items/index.html.erb new file mode 100644 index 00000000..a3b460fc --- /dev/null +++ b/app/views/reports/sale_items/index.html.erb @@ -0,0 +1,141 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + +
Date
Menu CategoryCodeProductTotal ItemUnit PriceRevenue
+
+
+
+ + \ No newline at end of file diff --git a/app/views/reports/sale_items/index.xls.erb b/app/views/reports/sale_items/index.xls.erb new file mode 100644 index 00000000..2807ec3f --- /dev/null +++ b/app/views/reports/sale_items/index.xls.erb @@ -0,0 +1,136 @@ + + + + + + + +
+<% unless @sale_data.blank? %> + + + + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + + + <% acc_arr = Array.new %> + <% cate_arr = Array.new %> + + <% sub_total = 0.0 %> + <% count = 0%> + <% total_price = 0.0 %> + <% cate_count = 0 %> + <% acc_count = 0%> + <% grand_total = 0%> + <% total_discount = 0.0 %> + + <% @sale_data.order("total_item desc").each do |sale| %> + + <% if !acc_arr.include?(sale.account_id) %> + + + + + + + <% acc_arr.push(sale.account_id) %> + + <% end %> + + + <% if !cate_arr.include?(sale.menu_category_id) %> + + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + + <% end %> + + <% if @item_table == 'sale' %> + <% if sale.item_remark == 'FOC' %> + + <% elsif sale.item_remark == 'FOC ITEM' %> + + <% elsif sale.item_remark == 'DISCOUNT' %> + + <% else %> + + <% end %> + <% if sale.item_remark == 'DISCOUNT' %> + + + + <% total_price += sale.total_price %> + <% else %> + + + + <% end %> + <% else %> + + + + + <% end %> + + + + <% @menu_cate_count.each do |key,value| %> + <% if sale.menu_category_id == key %> + <% count = count + 1 %> + <% sub_total += sale.grand_total %> + <% if count == value %> + + + + + + <% sub_total = 0.0%> + <% total_discount = total_discount + total_price %> + <% total_price = 0.0%> + <% count = 0%> + <% end %> + <% end %> + <% end %> + + <% grand_total += sale.grand_total%> + <% end %> + + + + + + +
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
 Menu CategoryCodeProductTotal ItemUnit PriceRevenue
<%= sale.account_name %> Total Price By <%= sale.account_name %> + <% @totalByAccount.each do |account, total| %> + <% if sale.account_id == account %> + <%= total %> + <% end %> + <% end %> +
 <%= sale.menu_category_name %> <%= sale.code rescue '-' %><%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %><%= sale.product_name.to_s rescue '-' %> - - <%= sale.total_price.abs rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %><%= sale.product_name.to_s rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %>
 Sub Total<%= sub_total + total_price %>
 Grand Total<%= grand_total + total_discount %>
+<% end %> +
+ + \ No newline at end of file diff --git a/app/views/settings/accounts/index.html.erb b/app/views/settings/accounts/index.html.erb index 23cfb7eb..541bc0a1 100644 --- a/app/views/settings/accounts/index.html.erb +++ b/app/views/settings/accounts/index.html.erb @@ -16,9 +16,9 @@ Title Account Type - Can get Discount + Can get Points - Can get Bonus + Can rebate Action @@ -30,9 +30,9 @@ <%= account.title %> <%= account.account_type %> - <%= account.discount %> + <%= account.point %> - <%= account.bonus %> + <%= account.rebate %> <%= link_to 'Edit', edit_settings_account_path(account) %> | diff --git a/app/views/settings/accounts/show.html.erb b/app/views/settings/accounts/show.html.erb index 284bb602..6d28df26 100644 --- a/app/views/settings/accounts/show.html.erb +++ b/app/views/settings/accounts/show.html.erb @@ -1,4 +1,4 @@ - +