diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4d3242d5..34b4f3b1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,16 +2,7 @@ - - - - - - - - - @@ -27,21 +18,111 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -50,33 +131,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -85,8 +141,18 @@ - - + + + + + + + + + + + + @@ -97,6 +163,8 @@ origami + table_invoice + sale_id @@ -105,11 +173,17 @@ @@ -168,6 +242,264 @@ - @@ -672,38 +1026,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -712,22 +1034,6 @@ - - - - - - - - - - - - - - - - @@ -760,16 +1066,27 @@ - + - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -781,34 +1098,162 @@ - + - - + + - + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gemfile b/Gemfile index 227cfa72..4c544ad6 100644 --- a/Gemfile +++ b/Gemfile @@ -9,10 +9,13 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record + +#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'pg' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' + # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/assets/javascripts/reports/dailysales.coffee b/app/assets/javascripts/cash_mgmt.coffee similarity index 100% rename from app/assets/javascripts/reports/dailysales.coffee rename to app/assets/javascripts/cash_mgmt.coffee diff --git a/app/assets/javascripts/reports/sale_items.coffee b/app/assets/javascripts/origami/shifts.coffee similarity index 100% rename from app/assets/javascripts/reports/sale_items.coffee rename to app/assets/javascripts/origami/shifts.coffee diff --git a/app/assets/javascripts/reports/dailysale.coffee b/app/assets/javascripts/reports/dailysale.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/dailysale.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/saleitem.coffee b/app/assets/javascripts/reports/saleitem.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/saleitem.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/shiftsale.coffee b/app/assets/javascripts/reports/shiftsale.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/shiftsale.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/CRM.scss b/app/assets/stylesheets/CRM.scss index 9ab3730c..cf6782dd 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -13,27 +13,43 @@ .selected-item { color: #fff !important; - background-color: #ccc !important; + background-color: #7a62d3 !important; } .assign { color: #fff !important; - background-color: red; + background-color: #009900; } .assign .text-muted{ color: #fff !important; } +.normal{ + color: #fff !important; + background-color: #54A5AF; +} +.cancel { + color: #fff !important; + background-color: #FF0000; +} .red{ color: #fff !important; background-color: red; } .green{ color: #fff !important; - background-color: green; + background-color: #009900; } .required abbr{ color: red !important; } .jconfirm-box-container{ margin-left:-40px !important +} +.card-columns { + @include media-breakpoint-only(lg) { + column-count: 5; + } + @include media-breakpoint-only(xl) { + column-count: 5; + } } \ No newline at end of file diff --git a/app/assets/stylesheets/reports/dailysales.scss b/app/assets/stylesheets/cash_mgmt.scss similarity index 60% rename from app/assets/stylesheets/reports/dailysales.scss rename to app/assets/stylesheets/cash_mgmt.scss index cfc48374..dfec4c04 100644 --- a/app/assets/stylesheets/reports/dailysales.scss +++ b/app/assets/stylesheets/cash_mgmt.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the reports/dailysales controller here. +// Place all the styles related to the cash_mgmt 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/origami.scss b/app/assets/stylesheets/origami.scss index 2ba6fe52..e0a59dc7 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -72,6 +72,7 @@ } .action-btn { + white-space: normal !important; height: 60px; margin-bottom: 5px; } @@ -168,6 +169,8 @@ background-color: blue } +/* End Colors */ + .left{ margin-left:1px; } @@ -175,6 +178,7 @@ .bottom{ margin-bottom: 1px; } + /*----- Reset -----*/ select.form-control { @@ -197,6 +201,7 @@ tr.discount-item-row:hover { .required abbr{ color: red !important; } + /* Jquery Confirm */ .jconfirm-box-container{ diff --git a/app/assets/stylesheets/reports/sale_items.scss b/app/assets/stylesheets/origami/shifts.scss similarity index 60% rename from app/assets/stylesheets/reports/sale_items.scss rename to app/assets/stylesheets/origami/shifts.scss index b9692327..ee1b2c4e 100644 --- a/app/assets/stylesheets/reports/sale_items.scss +++ b/app/assets/stylesheets/origami/shifts.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the reports/sale_items controller here. +// Place all the styles related to the origami/shifts 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/dailysale.scss b/app/assets/stylesheets/reports/dailysale.scss new file mode 100644 index 00000000..516e1b52 --- /dev/null +++ b/app/assets/stylesheets/reports/dailysale.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/dailysale 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/saleitem.scss b/app/assets/stylesheets/reports/saleitem.scss new file mode 100644 index 00000000..3e3460a4 --- /dev/null +++ b/app/assets/stylesheets/reports/saleitem.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/saleitem 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/shiftsale.scss b/app/assets/stylesheets/reports/shiftsale.scss new file mode 100644 index 00000000..0e0a4c32 --- /dev/null +++ b/app/assets/stylesheets/reports/shiftsale.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/shiftsale 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/api/api_controller.rb b/app/controllers/api/api_controller.rb index c61b5bc2..5b60b5df 100644 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,6 +1,6 @@ class Api::ApiController < ActionController::API include TokenVerification - helper_method :current_token, :current_login_employee + helper_method :current_token, :current_login_employee, :get_cashier private @@ -13,6 +13,11 @@ class Api::ApiController < ActionController::API end end + # Get current Cashier + def get_cashier + @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + end + def current_login_employee @employee = Employee.find_by_token_session(current_token) end diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 16ebf256..cc9e2f26 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -13,37 +13,54 @@ class Api::BillController < Api::ApiController if booking if booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) else @status = true @sale_id = booking.sale_id end end - + elsif (params[:order_id]) @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) + @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) end +<<<<<<< HEAD @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) +======= - unique_code = "ReceiptBillPdf" - #shop detail - shop_details = Shop.find(1) +# Not Use for these printed bill cannot give customer + # @sale_data = Sale.find_by_sale_id(@sale_id) + # @sale_items = SaleItem.where("sale_id=?",@sale_id) + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) + + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) + + + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) +>>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff + + # # Calculate Price by accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + +<<<<<<< HEAD customer= Customer.find(@sale_data.customer_id) # get member information member_info = Customer.get_member_account(customer) +======= +>>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) + # printer = Printer::ReceiptPrinter.new(print_settings) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) - # Calculate Price by accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 1eba8c56..8c7d7396 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -67,43 +67,75 @@ class Api::OrdersController < Api::ApiController if booking if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' if !booking.sale_id.nil? - check_order_with_booking(booking) + sale_status = check_order_with_booking(booking) + # puts "WWwwWWWWWWww" + # puts sale_status + if sale_status + return return_json_status_with_code(400, "bill requested") + end else @order.new_booking = false @order.booking_id = params[:booking_id] end else - check_order_with_table(params[:table_id]) + sale_status = check_order_with_table(params[:table_id]) + # puts "OOOOOOOOO" + # puts sale_status + if sale_status + return return_json_status_with_code(400, "bill requested") + end end end #booking exists else - check_order_with_table(params[:table_id]) - end + sale_status = check_order_with_table(params[:table_id]) + # puts "MMMMMMMM" + # puts sale_status + if sale_status + # return false , @message = "bill requested" + return return_json_status_with_code(400, "bill requested") + end + end - @status, @booking = @order.generate + @status, @booking = @order.generate + end + + # render json for http status code + def return_json_status_with_code(code, msg) + render status: code, json: { + message: msg, + booking_id: booking_id + }.to_json end def check_order_with_table(table_id) table = DiningFacility.find(table_id) if table booking = table.get_current_booking + # puts booking if booking - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" @order.new_booking = true - else + return false + end + else @order.new_booking = false @order.booking_id = booking.booking_id + return false end end end end + # this can always true def check_order_with_booking(booking) - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" @order.new_booking = true + return false else @order.new_booking = false @order.booking_id = params[:booking_id] + return false end end # Description diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 2af895da..126b20b0 100644 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -7,12 +7,11 @@ class BaseOrigamiController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| flash[:warning] = exception.message - redirect_to root_path + redirect_to origami_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/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f2846c12..f8a80cb8 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -6,12 +6,12 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers.json def index filter = params[:filter] - + if filter.nil? @crm_customers = Customer.all else - @crm_customers = Customer.search(filter) - + @crm_customers = Customer.search(filter) + end #@crm_customers = Customer.all @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @@ -32,7 +32,7 @@ class Crm::CustomersController < BaseCrmController def show @orders = Order.where("customer_id=?", params[:id]) @sales = Sale.where("customer_id=?", params[:id]) - + if @orders @order_items = [] @orders.each do |order| @@ -70,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] @@ -81,7 +81,7 @@ class Crm::CustomersController < BaseCrmController nrc = customer_params[:nrc_no] card_no = customer_params[:card_no] member_group_id = params[:member_group_id] - + if !member_group_id.nil? membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") @@ -90,7 +90,7 @@ class Crm::CustomersController < BaseCrmController url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + 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, @@ -103,18 +103,24 @@ class Crm::CustomersController < BaseCrmController ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true - + customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) - + if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} - end + end # format.json { render :index, status: :created, location: @crm_customers } else # @crm_customers.destroy @@ -129,7 +135,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors @@ -166,7 +172,7 @@ end url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + 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, @@ -176,16 +182,22 @@ end 'Accept' => 'application/json' }, :timeout => 10 - ) + ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true - + customer = Customer.find(@crm_customer.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) - + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} else format.html { redirect_to crm_customers_path, notice: response["message"] } @@ -199,7 +211,7 @@ end auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + 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, @@ -211,6 +223,12 @@ end ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true @@ -219,8 +237,8 @@ end else format.html { redirect_to crm_customers_path, notice: response["message"] } end - - end + + end else @@ -251,7 +269,7 @@ end # Never trust parameters from the scary internet, only allow the white list through. def customer_params - params.require(:customer).permit(:name, :company, :contact_no, :email, + params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no) end end diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index b4f902fc..9c5f8b73 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -96,6 +96,17 @@ class Crm::DiningQueuesController < BaseCrmController end end + def cancel_queue + queue = DiningQueue.find(params[:id]) + + status = queue.update_attributes(id: params[:id],status:"Cancel") + + if status == true + render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + end + end private # Use callbacks to share common setup or constraints between actions. diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1f93e6aa..3136417f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,7 +2,7 @@ class HomeController < ApplicationController skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] def index - @employees = Employee.all.order("name asc") + @employees = Employee.all_emp_except_waiter.order("name asc") @login_form = LoginForm.new() end @@ -19,7 +19,7 @@ class HomeController < ApplicationController if @employee != nil session[:session_token] = @employee.token_session - redirect_to origami_root_path + route_by_role(@employee) else render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!" end @@ -37,7 +37,7 @@ class HomeController < ApplicationController redirect_to dashboard_path elsif @employee.role == "cashier" session[:session_token] = @employee.token_session - redirect_to origami_root_path + route_by_role(@employee) elsif @employee.role == "manager" session[:session_token] = @employee.token_session redirect_to dashboard_path @@ -74,4 +74,25 @@ class HomeController < ApplicationController def settings_home_params params.require(:login_form).permit(:emp_id, :password) end + + def route_by_role(employee) + if employee.role == "administrator" + redirect_to dashboard_path + elsif employee.role == "cashier" + #check if cashier has existing open cashier + shift = ShiftSale.current_open_shift(employee.id) + if !shift.nil? + redirect_to origami_root_path + else + redirect_to new_origami_shift_path + end + elsif employee.role == "manager" + redirect_to oqs_root_path + elsif employee.role == "waiter" + redirect_to oqs_root_path + elsif employee.role == "crm" + redirect_to crm_root_path + + end + end end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index f3fd5675..52960f52 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -16,7 +16,7 @@ class Oqs::PrintController < ApplicationController # print when complete click print_settings = PrintSetting.find_by_unique_code(unique_code) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status, options ) + order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, assigned_item.item_code, print_status, options ) # update print status for completed same order items assigned_items.each do |ai| @@ -46,7 +46,7 @@ class Oqs::PrintController < ApplicationController # print when complete click print_settings = PrintSetting.find_by_unique_code(unique_code) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status) + order_queue_printer.print_booking_summary(print_settings,oqs, booking.booking_id, print_status) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb new file mode 100644 index 00000000..085f68b8 --- /dev/null +++ b/app/controllers/origami/cash_ins_controller.rb @@ -0,0 +1,18 @@ +class Origami::CashInsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + payment_method = params[:payment_method] + payment_method_reference = params[:payment_method_reference] + p_jour = PaymentJournal.new + p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) + shift = ShiftSale.current_open_shift(current_user.id) + shift.cash_in = shift.cash_in + amount.to_i + shift.save + end +end diff --git a/app/controllers/origami/cash_mgmt_controller.rb b/app/controllers/origami/cash_mgmt_controller.rb new file mode 100644 index 00000000..aaf55c1f --- /dev/null +++ b/app/controllers/origami/cash_mgmt_controller.rb @@ -0,0 +1,10 @@ +class Origami::CashMgmtController < ApplicationController + def index + end + + def new + end + + def create + end +end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb new file mode 100644 index 00000000..95ab97a2 --- /dev/null +++ b/app/controllers/origami/cash_outs_controller.rb @@ -0,0 +1,16 @@ +class Origami::CashOutsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + p_jour = PaymentJournal.new + p_jour.cash_out(reference, remark, amount, current_user.id) + shift = ShiftSale.current_open_shift(current_user.id) + shift.cash_out = shift.cash_out + amount.to_i + shift.save + end +end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 463f6dc6..6c76c27a 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -29,7 +29,6 @@ class Origami::DiscountsController < BaseOrigamiController if discount_items.length > 0 #save sale item for discount discount_items.each do |di| - puts di origin_sale_item = SaleItem.find(di["id"]) sale_item = SaleItem.new @@ -53,6 +52,59 @@ class Origami::DiscountsController < BaseOrigamiController render :json => dining.to_json end + # Remove selected discount Items + def remove_discount_items + sale_id = params[:sale_id] + discount_items = JSON.parse(params[:discount_items]) + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + + if discount_items.length > 0 + #destroy sale item for discount + discount_items.each do |di| + sale_item = SaleItem.find(di["id"]) + sale.total_amount = (sale.total_amount + sale_item.price.abs) + sale_item.destroy + end + end + + sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + sale.save + end + + dining = {:table_id => table_id, :table_type => table_type } + + render :json => dining.to_json + end + + # Remove all discount Items + def remove_all_discount + sale_id = params[:id] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + + #destroy all discount sale item + sale.sale_items.each do |si| + if si.remark == "Discount" && si.price < 0 + sale.total_amount = (sale.total_amount + si.price.abs) + si.destroy + end + end + + sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + sale.save + end + + dining = {:table_id => table_id, :table_type => table_type } + + render :json => dining.to_json + end + #discount for selected order # def create # sale_id = params[:sale_id] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1b0aa491..32f4ab12 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -6,6 +6,7 @@ class Origami::HomeController < BaseOrigamiController @rooms = Room.all.active.order('status desc') @complete = Sale.all @orders = Order.all.order('date desc') + # @shift = ShiftSale.current_open_shift(current_user.id) end # origami table detail diff --git a/app/controllers/origami/home_controller_bk.rb b/app/controllers/origami/home_controller_bk.rb index 1aca9b2d..5496cca5 100644 --- a/app/controllers/origami/home_controller_bk.rb +++ b/app/controllers/origami/home_controller_bk.rb @@ -19,9 +19,9 @@ class Origami::HomeController < BaseOrigamiController @orders = Order.get_orders() end - def item_show - selection(params[:booking_id],1) - end + # def item_show + # selection(params[:booking_id],1) + # end def selection(selected_id, is_ajax) str = [] @@ -37,8 +37,8 @@ class Origami::HomeController < BaseOrigamiController @order_details = OrderItem.get_order_items_details(params[:booking_id]) @order_details.each do |ord_detail| str.push(ord_detail) - end - end + end + end if is_ajax == 1 render :json => str.to_json diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb new file mode 100644 index 00000000..654f539a --- /dev/null +++ b/app/controllers/origami/other_charges_controller.rb @@ -0,0 +1,48 @@ +class Origami::OtherChargesController < BaseOrigamiController + authorize_resource :class => false + + def index + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find(sale_id) + end + end + + def create + sale_id = params[:sale_id] + other_charges_items = JSON.parse(params[:other_charges_items]) + sub_total = params[:sub_total] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + sale.total_amount = sub_total.to_f + sale.grand_total = sub_total.to_f + sale.total_tax; + sale.save + if other_charges_items.length > 0 + #save sale item for discount + other_charges_items.each do |di| + # origin_sale_item = SaleItem.find(di["id"]) + sale_item = SaleItem.new + + sale_item.sale_id = sale_id + sale_item.product_code = "Other Charges" + sale_item.product_name = di["name"] + sale_item.remark = "Other Charges" + + sale_item.qty = 1 + sale_item.unit_price = di["price"] + sale_item.taxable_price = di["price"] + sale_item.is_taxable = 0 + + sale_item.price = di["price"] + sale_item.save + end + end + end + + dining = {:table_id => table_id, :table_type => table_type } + render :json => dining.to_json + end +end \ No newline at end of file diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f5a0023e..0d2d9082 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -4,6 +4,39 @@ class Origami::PaymentsController < BaseOrigamiController def index end + def first_bill + sale_id = params[:sale_id] # sale_id + sale_data = Sale.find_by_sale_id(sale_id) + sale_items = SaleItem.where("sale_id=?",sale_id) + + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + rounding_adj = sale_data.grand_total - new_total + + sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj) + # Print for First Bill to Customer + + unique_code = "ReceiptBillPdf" + #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) + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details) + end + def create cash = params[:cash] sale_id = params[:sale_id] @@ -26,9 +59,10 @@ class Origami::PaymentsController < BaseOrigamiController print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_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,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end end @@ -104,10 +138,9 @@ class Origami::PaymentsController < BaseOrigamiController # Calculate price_by_accounts item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_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,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end - - end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 314835a2..cfea9d37 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -10,9 +10,9 @@ class Origami::RequestBillsController < BaseOrigamiController check_booking = Booking.find_by_booking_id(bk_order.booking_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist - puts "current_login_employee" - puts current_login_employee.name - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee) + # puts "current_login_employee" + # puts current_login_employee.name + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) else @@ -20,26 +20,26 @@ class Origami::RequestBillsController < BaseOrigamiController @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) 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) - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) +# Not Use for these printed bill cannot give customer + # 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) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) - # find order id by sale id - # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + # # find order id by sale id + # # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) - # Calculate price_by_accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + # # Calculate price_by_accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) + # printer = Printer::ReceiptPrinter.new(print_settings) - 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) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 70a5a380..d4fba302 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -1,5 +1,5 @@ class Origami::SaleEditController < BaseOrigamiController - + authorize_resource :class => false # Index for sale item void OR edit def edit sale_id = params[:sale_id] @@ -18,6 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.save @newsaleitem.qty = saleitemObj.qty * -1 @newsaleitem.price = saleitemObj.price * -1 + @newsaleitem.is_taxable = 0 @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb new file mode 100644 index 00000000..3329aa0b --- /dev/null +++ b/app/controllers/origami/shifts_controller.rb @@ -0,0 +1,36 @@ +class Origami::ShiftsController < BaseOrigamiController + + def index + end + + def show + puts current_user.id + @shift = ShiftSale.current_open_shift(current_user.id) + end + + def new + @float = Lookup.where('lookup_type=?','float_value') + @terminal = CashierTerminal.all + end + + def create + opening_balance = params[:opening_balance] + @shift = ShiftSale.new + @shift.create(opening_balance,current_user) + end + + def update_shift + closing_balance = params[:closing_balance] + shift_id = params[:shift_id] + @shift = ShiftSale.find_by_id(shift_id) + if @shift + @shift.shift_closed_at = DateTime.now.utc + @shift.closing_balance = closing_balance.to_f + @shift.save + end + end + + + def edit + end +end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 32e0ef7f..4571ba87 100644 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -25,7 +25,7 @@ class Origami::TableInvoicesController < BaseOrigamiController else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" + if sale.sale_status != "completed" && sale.sale_status != 'void' @sale_array.push(sale) end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index bea37a21..b8972cf2 100644 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -1,5 +1,5 @@ class Origami::VoidController < BaseOrigamiController - + authorize_resource :class => false def overall_void sale_id = params[:sale_id] @@ -9,6 +9,14 @@ class Origami::VoidController < BaseOrigamiController sale.sale_status = 'void' sale.save + bookings = sale.bookings + bookings.each do |booking| + orders = booking.orders + orders.each do |order| + # order.status = 'void' + end + end + table_avaliable = true table = sale.bookings[0].dining_facility table.bookings.each do |booking| diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index bdd3061a..8efb9dd5 100644 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def print_setting_params - params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies) + params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) end end diff --git a/app/controllers/reports/bksale_items_controller.rb b/app/controllers/reports/bksale_items_controller.rb deleted file mode 100644 index 1f349320..00000000 --- a/app/controllers/reports/bksale_items_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -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/reports/daily_sales_controller.rb b/app/controllers/reports/daily_sales_controller.rb deleted file mode 100644 index 6d99551d..00000000 --- a/app/controllers/reports/daily_sales_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -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_salesbk_controller.rb b/app/controllers/reports/dailysale_controller.rb similarity index 70% rename from app/controllers/reports/daily_salesbk_controller.rb rename to app/controllers/reports/dailysale_controller.rb index 1a878aaa..27e812ab 100644 --- a/app/controllers/reports/daily_salesbk_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -1,5 +1,6 @@ -class Reports::DailySalesController < BaseReportController - authorize_resource :class => false +class Reports::DailysaleController < BaseReportController + authorize_resource :class => false + def index from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) @@ -13,5 +14,4 @@ class Reports::DailySalesController < BaseReportController def show end - -end \ No newline at end of file +end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index d85c7d57..e4157c4e 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,5 +1,5 @@ class Reports::ReceiptNoController < BaseReportController - +authorize_resource :class => false def index from, to = get_date_range_from_params puts "from..." diff --git a/app/controllers/reports/sale_items_controller.rb b/app/controllers/reports/saleitem_controller.rb similarity index 73% rename from app/controllers/reports/sale_items_controller.rb rename to app/controllers/reports/saleitem_controller.rb index 81f7af01..0f91681d 100644 --- a/app/controllers/reports/sale_items_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -1,5 +1,5 @@ -class Reports::SaleItemsController < BaseReportController - # authorize_resource :class => false +class Reports::SaleitemController < BaseReportController + authorize_resource :class => false def index from, to, report_type = get_date_range_from_params @@ -16,4 +16,4 @@ class Reports::SaleItemsController < BaseReportController end -end \ No newline at end of file +end diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb new file mode 100644 index 00000000..5f13857d --- /dev/null +++ b/app/controllers/reports/shiftsale_controller.rb @@ -0,0 +1,18 @@ +class Reports::ShiftsaleController < ApplicationController + # authorize_resource :class => false + + def index + + from, to, report_type = get_date_range_from_params + @sale_data = Sale.get_by_shiftsales(from,to) + respond_to do |format| + format.html + format.xls + end + end + + def show + + end +end + diff --git a/app/forms/open_shift_form.rb b/app/forms/open_shift_form.rb new file mode 100644 index 00000000..019e6f3e --- /dev/null +++ b/app/forms/open_shift_form.rb @@ -0,0 +1,16 @@ +class LoginForm + include ActiveModel::Model + include ActiveModel::Validations + + attr_accessor :float_amount + validates_presence_of :float_amount + + def persisted? + false + end + + def initialize(attributes={}) + super + end + +end diff --git a/app/helpers/cash_mgmt_helper.rb b/app/helpers/cash_mgmt_helper.rb new file mode 100644 index 00000000..5c1ad77b --- /dev/null +++ b/app/helpers/cash_mgmt_helper.rb @@ -0,0 +1,2 @@ +module CashMgmtHelper +end diff --git a/app/helpers/origami/request_bills_helper.rb b/app/helpers/origami/request_bills_helper.rb index a33f7c3e..2d1f8313 100644 --- a/app/helpers/origami/request_bills_helper.rb +++ b/app/helpers/origami/request_bills_helper.rb @@ -1,2 +1,3 @@ module Origami::RequestBillsHelper + end diff --git a/app/helpers/origami/shifts_helper.rb b/app/helpers/origami/shifts_helper.rb new file mode 100644 index 00000000..ae63824e --- /dev/null +++ b/app/helpers/origami/shifts_helper.rb @@ -0,0 +1,2 @@ +module Origami::ShiftsHelper +end diff --git a/app/helpers/reports/dailysale_helper.rb b/app/helpers/reports/dailysale_helper.rb new file mode 100644 index 00000000..88ccfd83 --- /dev/null +++ b/app/helpers/reports/dailysale_helper.rb @@ -0,0 +1,2 @@ +module Reports::DailysaleHelper +end diff --git a/app/helpers/reports/dailysales_helper.rb b/app/helpers/reports/dailysales_helper.rb deleted file mode 100644 index 94e34c27..00000000 --- a/app/helpers/reports/dailysales_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Reports::DailysalesHelper -end diff --git a/app/helpers/reports/sale_items_helper.rb b/app/helpers/reports/sale_items_helper.rb deleted file mode 100644 index 63e884d7..00000000 --- a/app/helpers/reports/sale_items_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Reports::SaleItemsHelper -end diff --git a/app/helpers/reports/saleitem_helper.rb b/app/helpers/reports/saleitem_helper.rb new file mode 100644 index 00000000..47544cf9 --- /dev/null +++ b/app/helpers/reports/saleitem_helper.rb @@ -0,0 +1,2 @@ +module Reports::SaleitemHelper +end diff --git a/app/helpers/reports/shiftsale_helper.rb b/app/helpers/reports/shiftsale_helper.rb new file mode 100644 index 00000000..967a8c6b --- /dev/null +++ b/app/helpers/reports/shiftsale_helper.rb @@ -0,0 +1,2 @@ +module Reports::ShiftsaleHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 5e5fb4f3..066311af 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -31,16 +31,23 @@ class Ability can :manage, Sale can :manage, Customer + can :manage, DiningQueue can :index, :dailysale can :index, :saleitem + can :index, :receipt_no can :add_customer, Customer can :update_sale_by_customer, Customer + can :index, :other_charges + can :create, :other_charges can :index, :discount can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount + can :first_bill, :payment can :show, :payment can :create, :payment can :reprint, :payment @@ -50,6 +57,14 @@ class Ability can :move_dining, :moveroom + can :edit, :sale_edit + can :item_void, :sale_edit + can :item_void_cancel, :sale_edit + can :cancel_all_void, :sale_edit + can :apply_void, :sale_edit + + can :overall_void, :void + elsif user.role == "cashier" can :read, Order @@ -63,6 +78,8 @@ class Ability can :index, :discount can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount can :show, :payment can :create, :payment @@ -76,12 +93,17 @@ class Ability elsif user.role == "accountant" can :index, :dailysale - can :index, :saleitem - can :index, :receiptno - can :show, :dailysale - can :show, :saleitem - can :show, :receiptno + can :manage, :saleitem + can :index, :receiptno + + elsif user.role == "supervisour" + + can :index, :dailysale + can :manage, :saleitem + can :index, :receiptno end + end + end diff --git a/app/models/customer.rb b/app/models/customer.rb index e6afca08..a26d857e 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -31,6 +31,12 @@ class Customer < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; @@ -55,6 +61,12 @@ class Customer < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 0e10307b..510da53d 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -39,6 +39,16 @@ class DiningFacility < ApplicationRecord end end + def get_moved_booking + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + + if booking.count > 0 then + return booking[0] + else + return nil + end + end + def get_new_booking # query for new # if status diff --git a/app/models/employee.rb b/app/models/employee.rb index 69eb3fae..2d70768d 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,11 +1,16 @@ class Employee < ApplicationRecord has_secure_password + has_many :shit_sales validates_presence_of :name, :role validates_presence_of :password, :on => [:create] validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true + def self.all_emp_except_waiter + Employee.where('role!=?','waiter') + end + def self.collection Employee.select("id, name").map { |e| [e.name, e.id] } end diff --git a/app/models/order.rb b/app/models/order.rb index b3a70f37..249e82ea 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,9 +25,8 @@ class Order < ApplicationRecord booking = nil if self.new_booking - booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", - :checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name, + :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) table = DiningFacility.find(self.table_id) table.status = "occupied" @@ -39,6 +38,7 @@ class Order < ApplicationRecord booking.save! self.default_values + # cashier already opened? if self.save! self.adding_line_items @@ -301,7 +301,7 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("(orders.status = 'new' or orders.status = 'billed')") + .where("(orders.status = 'new' or orders.status = 'billed') AND orders.date between #{ from } and #{ to }") # orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status, # orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb new file mode 100644 index 00000000..0f0c3ce5 --- /dev/null +++ b/app/models/payment_journal.rb @@ -0,0 +1,43 @@ +class PaymentJournal < ApplicationRecord + + def cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) + self.payment_references = reference + self.remark = remark + self.credit_amount = amount + self.payment_method = payment_method + self.payment_status = 'paid' + self.payment_method_references = payment_method_reference + self.created_by = current_user + self.save + end + + def cash_out(payment_reference, remark, amount, current_user) + self.payment_references = payment_reference + self.remark = remark + self.debit_amount = amount + self.payment_status = 'paid' + self.created_by = current_user + self.save + end + + # def self.today_cash_in(current_user) + # credit = 0.0 + # today_date = DateTime.now.strftime("%Y-%m-%d") + # pj_credit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) + # pj_credit.each do |obj| + # credit += obj.credit_amount + # end + # return credit + # end + # + # def self.today_cash_out(current_user) + # debit = 0.0 + # today_date = DateTime.now.strftime("%Y-%m-%d") + # pj_debit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) + # pj_debit.each do |obj| + # debit += obj.debit_amount + # end + # return debit + # end + +end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index f80ee72d..6c8ba7e2 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,6 +1,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(oqs,order_id, item_code, print_status, options="") + def print_order_item(print_settings,oqs,order_id, item_code, print_status, options="") #Use CUPS service #Generate PDF #Print @@ -10,7 +10,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # check for item not to show if order_item[0].price != 0 - pdf = OrderItemPdf.new(order_item[0], print_status, options) + pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -26,21 +26,22 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Query for per order - def print_order_summary(oqs, order_id, order_items, print_status) + def print_order_summary(print_settings,oqs, order_id, order_items, print_status) #Use CUPS service #Generate PDF #Print order=print_query('order_summary', order_id) + # For Print Per Item if oqs.cut_per_item - order_items.each do|odi| + order.each do|odi| filename = "tmp/order_item_#{odi.item_name}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options # check for item not to show - if odi.price != 0 || odi.price != 10 - pdf = OrderItemPdf.new(odi, print_status, options) + if odi.price != 0 + pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name) # pdf.render_file "tmp/order_item.pdf" pdf.render_file filename if oqs.print_copy @@ -54,7 +55,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Order Summary else filename = "tmp/order_summary_#{ order_id }" + ".pdf" - pdf = OrderSummaryPdf.new(order, print_status, order_items) + pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy self.print(filename, oqs.printer_name) @@ -69,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Print for orders in booking - def print_booking_summary(oqs, booking_id, print_status) + def print_booking_summary(print_settings,oqs, booking_id, print_status) order=print_query('booking_summary', booking_id) # For Print Per Item if oqs.cut_per_item @@ -80,7 +81,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # check for item not to show if odi.price != 0 - pdf = OrderItemPdf.new(odi, print_status, options) + pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -97,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Order Summary else filename = "tmp/booking_summary_#{ booking_id }" + ".pdf" - pdf = OrderSummaryPdf.new(order, print_status) + pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy self.print(filename, oqs.printer_name) @@ -114,31 +115,34 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) if type == "order_item" - 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") + 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,item.alt_name as alt_name") .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 left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("order_items.item_code = '#{ id }' AND order_items.price != 0") .group("order_items.item_code") elsif type == "order_summary" - 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") + 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,item.alt_name as alt_name") .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 left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("orders.order_id = '#{ id }' AND order_items.price != 0") .group("order_items.order_items_id") else # order summary for booking - 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") + 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,item.alt_name as alt_name") .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 left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("b.booking_id = '#{ id }' AND order_items.price != 0") end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 8e389e79..f8eb46d6 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,14 +65,19 @@ 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,shop_details) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_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,shop_details) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) - pdf.render_file "tmp/receipt_bill.pdf" - self.print("tmp/receipt_bill.pdf") + # print as print copies in printer setting + count = printer_settings.print_copies + begin + pdf.render_file "tmp/receipt_bill.pdf" + self.print("tmp/receipt_bill.pdf") + count -= 1 + end until count == 0 end #Queue No Print diff --git a/app/models/sale.rb b/app/models/sale.rb index 8f7f17d8..693f6874 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -25,7 +25,7 @@ class Sale < ApplicationRecord SALE_STATUS_OUTSTANDING = "outstanding" SALE_STATUS_COMPLETED = "completed" - def generate_invoice_from_booking(booking_id, requested_by) + def generate_invoice_from_booking(booking_id, requested_by, cashier) booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -35,9 +35,9 @@ class Sale < ApplicationRecord booking.booking_orders.each do |order| if booking.sale_id - status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier) else - status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier) end booking.sale_id = sale_id end @@ -47,7 +47,7 @@ class Sale < ApplicationRecord end end - def generate_invoice_from_order (order_id, sale_id, booking, requested_by) + def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil) taxable = true #if sale_id is exsit and validate #add order to that invoice @@ -66,12 +66,19 @@ class Sale < ApplicationRecord #Default Tax - Values self.tax_type = "exclusive" - # set cashier by current login - self.cashier_id = requested_by.id - self.cashier_name = requested_by.name + # set cashier + if cashier != nil + self.cashier_id = cashier[0].id + self.cashier_name = cashier[0].name + else + self.cashier_id = requested_by.id + self.cashier_name = requested_by.name + end + + # set waiter self.requested_by = requested_by.name - self.requested_at = DateTime.now.utc + self.requested_at = DateTime.now.utc.getlocal Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}" if order @@ -263,9 +270,6 @@ class Sale < ApplicationRecord end - - private - def product_get_unit_price(item_code) menu_item_hash =MenuItem.search_by_item_code(item_code) if (menu_instance_code) @@ -316,6 +320,41 @@ class Sale < ApplicationRecord end end + def self.get_rounding_adjustment(num) + ## 0 -- 25 -- 50 -- 75 -- 100 + # if get_rounded_amt == true + value = 0 + + num = num.to_f.round + get_last_no = num.to_s.last(2).to_f + if get_last_no.between?(0,25) + ## down to 0 + num -= get_last_no + else + if get_last_no.between?(26,50) + ## up to 50 + value = 50 - get_last_no.to_f + num += value + puts 'up to 50' + else + if get_last_no.between?(51, 75) + ## down to 50 + value = get_last_no.to_f - 50 + num -= value + puts 'down to 50' + else + ## up to 100 + value = 100 - get_last_no.to_f + num += value + puts 'up to 100' + end + end + end + # end + return num + end + + def self.daily_sales_list(from,to) payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, @@ -381,13 +420,13 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) .group('mi.id') .order("mi.menu_category_id") - query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_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) + query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) @@ -403,6 +442,51 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) end + +def self.get_by_shiftsales(from,to) + return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) +end + + def get_cash_amount + cash = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method == 'cash' + cash = pay.payment_amount + end + end + return cash + end + + def get_credit_amount + credit = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method == 'creditnote' + credit = pay.payment_amount + end + end + return credit + end + + def get_other_amount + other = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method != 'cash' && pay.payment_method != 'creditnote' + other += pay.payment_amount + end + end + return other + end + + def get_commerical_tax + tax = 0.0 + self.sale_taxes.each do |tax| + if tax.tax_name == "Commerical Tax" + tax += tax.tax_payable_amount + end + end + end + + private def generate_custom_id diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 8881efea..3cc0eb43 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,15 +30,17 @@ class SaleItem < ApplicationRecord # end end + # Get Prices for each accounts (eg: food, beverage) def self.calculate_price_by_accounts(sale_items) price_accounts = [] Account.all.each do |a| account_price = {:name => a.title, :price => 0} + # Check for actual sale items sale_items.each do |si| if si.account_id == a.id - account_price[:price] = account_price[:price] + si.price - end + account_price[:price] = account_price[:price] + si.price + end end price_accounts.push(account_price) end @@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord return price_accounts end + # Get discount Prices for each accounts (eg: food, beverage) + def self.get_discount_price_by_accounts(sale_items) + discount_accounts = [] + Account.all.each do |a| + discount_account = {:name => a.title, :price => 0} + + # Check for actual sale items + sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si| + if si.account_id == a.id + discount_account[:price] = (discount_account[:price] + si.price) * -1 + end + end + discount_accounts.push(discount_account) + end + + return discount_accounts + end + # Calculate rebate_by_account def self.calculate_rebate_by_account(sale_items) rebateacc = Account.where("rebate=?",true) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 8b28c946..c78b6cd8 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -77,6 +77,12 @@ class SalePayment < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; end @@ -110,6 +116,12 @@ class SalePayment < ApplicationRecord ) rescue Net::OpenTimeout response = false + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end else response = false; @@ -131,7 +143,6 @@ class SalePayment < ApplicationRecord self.payment_status = "paid" payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -146,7 +157,6 @@ class SalePayment < ApplicationRecord payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -161,7 +171,6 @@ class SalePayment < ApplicationRecord payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -175,7 +184,6 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total- self.received_amount self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) return payment_status @@ -192,7 +200,6 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total- self.received_amount self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) return payment_status @@ -220,7 +227,6 @@ class SalePayment < ApplicationRecord else sale_update_payment_status(0) end - return payment_status end @@ -249,10 +255,20 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) rebat(sObj) + if paid_amount != "0.0" + update_shift + end end end + def update_shift + shift = ShiftSale.current_open_shift(self.sale.cashier_id) + if !shift.nil? + shift.update(self.sale) + end + end + def table_update_status(sale_obj) status = true booking = Booking.find_by_sale_id(sale_obj.id) @@ -308,6 +324,12 @@ class SalePayment < ApplicationRecord }, :timeout => 10) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response # puts response.to_json @@ -315,6 +337,8 @@ class SalePayment < ApplicationRecord end end + + private def generate_custom_id self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb new file mode 100644 index 00000000..a897de2b --- /dev/null +++ b/app/models/shift_sale.rb @@ -0,0 +1,62 @@ + +#Description +#total_revenue = sum of all sub-total from sales table +#total_discounts = sum of all discount (overall) from sales tables +#total_taxes = sum of all taxes from sales table (Service + Goverment Tax (commercial_taxes)) +#grand_total = total_revenue - total_discounts + total_taxes +#nett_sales = grand_total - commercial_taxes +#cash_sales = cash payment total revenue +#credit_sales = credit payment total revenue +#others_sales = [Sum of each of other payment type --- mpu, jcb, visa,master, rebate, vochure] +#commercial_taxes = Total Goverment tax due +#cash_in = Payment receive +#Cash_out = Payment issues for misc payments + +class ShiftSale < ApplicationRecord + belongs_to :cashier_terminal + belongs_to :employee, :foreign_key => 'employee_id' + + def self.current_open_shift(current_user) + #if current_user + #find open shift where is open today and is not closed and login by current cashier + today_date = DateTime.now.strftime("%Y-%m-%d") + puts today_date + shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}", today_date).take + + return shift + #end + end + + def create(opening_balance,current_user) + self.cashier_terminal_id = CashierTerminal.first.id + self.shift_started_at = DateTime.now + self.employee_id = current_user.id + self.opening_balance = opening_balance + self.save + end + + def update(sale) + saleobj = Sale.find_by_sale_id(sale) + cash = saleobj.get_cash_amount + credit = saleobj.get_credit_amount + other_sales = saleobj.get_other_amount + tax = saleobj.get_commerical_tax + self.total_revenue = self.total_revenue.to_f + saleobj.total_amount.to_f + self.total_discounts = self.total_discounts + saleobj.total_discount + self.total_taxes = self.total_taxes + saleobj.total_tax + self.grand_total = self.grand_total + saleobj.grand_total + self.cash_sales = self.cash_sales.to_f + cash.to_f + self.credit_sales = self.credit_sales.to_i + credit.to_f + self.other_sales = self.other_sales.to_i + other_sales.to_f + self.nett_sales = self.grand_total.to_i - self.commercial_taxes + self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f + self.save + + end + + def get_closing_balance(shift) + shiftobj = ShiftSale.find(shift) + closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash + return closing_balance + end +end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index b6c821fc..12d51c53 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,6 +1,6 @@ class OrderItemPdf < 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_item, print_status, options) + def initialize(print_settings,order_item, print_status, options, alt_name) self.page_width = 210 self.page_height = 1450 self.margin = 5 @@ -12,12 +12,13 @@ class OrderItemPdf < Prawn::Document self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) self.label_width=100 - super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) - # font "public/fonts/#{font_name}".to_s + ".ttf".to_s - # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" + # font "public/fonts/#{font_name}".to_s + ".ttf".to_s + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" self.header_font_size = 12 self.item_font_size = 10 @@ -29,7 +30,7 @@ class OrderItemPdf < Prawn::Document order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items - order_items(order_item, options) + order_items(order_item, options, alt_name) end # Write Order Information to PDF @@ -57,11 +58,11 @@ class OrderItemPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item, options) + def order_items(order_item, options, alt_name) y_position = cursor #Add Order Item - add_order_items(order_item, options) + add_order_items(order_item, options, alt_name) dash(1, :space => 1, :phase => 1) stroke_horizontal_line 0, (self.page_width - self.margin) @@ -69,19 +70,31 @@ class OrderItemPdf < Prawn::Document end # Add order items under order info - def add_order_items(order_item, options) + def add_order_items(order_item, options, alt_name) y_position = cursor move_down 5 - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + bounding_box([0,y_position], :width => self.item_width) do text "#{order_item.item_name}", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do + bounding_box([self.item_width,y_position], :width => self.qty_width) do text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left end + bounding_box([0,y_position], :width => self.item_width) do + text "#{order_item.item_name}", :size => self.item_font_size,:align => :left + + end + + if alt_name + move_down 4 + font("public/fonts/Chinese.ttf") do + text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end + end + move_down 5 # add option diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 89eac43c..9e8ad10b 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, order_items = nil) + def initialize(print_settings,order, print_status, order_items = nil,alt_name) self.page_width = 210 self.page_height = 1450 self.margin = 5 @@ -12,11 +12,11 @@ class OrderSummaryPdf < Prawn::Document self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) self.label_width=100 - super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" + font "public/fonts/padauk.ttf" self.header_font_size = 12 self.item_font_size = 10 @@ -29,9 +29,9 @@ class OrderSummaryPdf < Prawn::Document # order items if order_items == nil - order_items(order) + order_items(order, alt_name) else - order_items(order_items) + order_items(order_items, alt_name) end end @@ -60,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item) + def order_items(order_item, alt_name) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do @@ -75,12 +75,12 @@ class OrderSummaryPdf < Prawn::Document move_down 5 #Add Order Item - add_order_items(order_item) + add_order_items(order_item, alt_name) end # Add order items under order info - def add_order_items(order_item) + def add_order_items(order_item, alt_name) y_position = cursor move_down 5 @@ -92,12 +92,26 @@ class OrderSummaryPdf < Prawn::Document bounding_box([0,y_position], :width => self.item_width) do 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 end + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_name}", :size => self.item_font_size,:align => :left + + end + + if alt_name + move_down 4 + font("public/fonts/Chinese.ttf") do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end + + end + move_down 5 # add option diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 4ae0a67d..3817c509 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,7 @@ class ReceiptBillPdf < Prawn::Document + include ActionView::Helpers::NumberHelper 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,shop_details) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) self.page_width = 210 self.page_height = 7000 self.margin = 5 @@ -16,7 +17,7 @@ class ReceiptBillPdf < Prawn::Document # @double = @qty_width * 1.3 # @half_qty = @qty_width / 2 #setting page margin and width - super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" @@ -24,22 +25,33 @@ class ReceiptBillPdf < Prawn::Document self.header_font_size = 10 self.item_font_size = 8 + if printer_settings.delimiter + delimiter = "," + else + delimiter = "" + end + header( shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name) - line_items(sale_items) - all_total(sale_data) + line_items(sale_items,printer_settings.precision,delimiter) + all_total(sale_data,printer_settings.precision,delimiter) if member_info != nil - member_info(member_info,customer_name,rebate_amount,sale_data) + member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter) end customer(customer_name) - items_account(item_price_by_accounts) + if discount_price_by_accounts.length > 0 + discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + end + + items_account(item_price_by_accounts,printer_settings.precision,delimiter) + footer end @@ -83,7 +95,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do - text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left + text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left end @@ -97,7 +109,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule end - def line_items(sale_items) + def line_items(sale_items,precision,delimiter) move_down 5 y_position = cursor move_down 5 @@ -110,10 +122,10 @@ class ReceiptBillPdf < Prawn::Document } move_down -5 stroke_horizontal_rule - add_line_item_row(sale_items) + add_line_item_row(sale_items,precision,delimiter) end - def add_line_item_row(sale_items) + def add_line_item_row(sale_items,precision,delimiter) item_name_width = (self.item_width+self.price_width) y_position = cursor move_down 5 @@ -132,9 +144,9 @@ class ReceiptBillPdf < Prawn::Document pad_top(15) { text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix 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 + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :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 1 end @@ -148,20 +160,20 @@ class ReceiptBillPdf < Prawn::Document text "Sub Total", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ sub_total }" , :size => self.item_font_size,:align => :right - end + text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right + end move_down 5 end - def all_total(sale_data) + def all_total(sale_data,precision,delimiter) item_name_width = self.item_width y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Discount", :size => self.item_font_size,:align => :left + text "Overall Discount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right + text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end if sale_data.sale_taxes.length > 0 @@ -173,7 +185,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ st.tax_name }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ st.tax_payable_amount }" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end else @@ -194,18 +206,18 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor move_down 5 bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Grand Total", :size => self.header_font_size,:align => :left + text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{sale_data.grand_total}" , :size => self.header_font_size,:align => :right + text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down 5 - sale_payment(sale_data) + sale_payment(sale_data,precision,delimiter) end - def sale_payment(sale_data) + def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule move_down 5 @@ -216,7 +228,7 @@ class ReceiptBillPdf < Prawn::Document text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ payment.payment_amount }" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down 5 end @@ -227,7 +239,7 @@ class ReceiptBillPdf < Prawn::Document text "Change Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{sale_data.amount_changed}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down 5 end @@ -235,7 +247,7 @@ class ReceiptBillPdf < Prawn::Document end # show member information - def member_info(member_info,customer_name,rebate_amount,sale_data) + def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter) if rebate_amount != nil @@ -251,7 +263,7 @@ class ReceiptBillPdf < Prawn::Document 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 + text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" @@ -262,15 +274,15 @@ class ReceiptBillPdf < Prawn::Document 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 "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end end end end - if member_info["status"] == true - balance = 0.0 + if member_info["status"] == true && member_info["data"].present? + balance = 0 member_info["data"].each do |res| if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" @@ -285,7 +297,7 @@ class ReceiptBillPdf < Prawn::Document 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 + text "#{number_with_precision(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end @@ -301,8 +313,23 @@ class ReceiptBillPdf < Prawn::Document text "#{ customer_name }" , :size => self.item_font_size,:align => :right end end + def discount_account(discount_price_by_accounts,precision,delimiter) + move_down 5 + stroke_horizontal_rule + move_down 5 + y_position = cursor + discount_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 "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + end + end + end - def items_account(item_price_by_accounts) + def items_account(item_price_by_accounts,precision,delimiter) move_down 5 stroke_horizontal_rule move_down 5 @@ -313,7 +340,7 @@ class ReceiptBillPdf < Prawn::Document 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 + text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end end diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index 813be2cf..4f39147f 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -18,19 +18,25 @@
- <% @i =0 %> + <% @dining_queues.each do |queue| %> -
" data-id="<%= queue.id %>"> + <% if queue.status == "Assign" + @bg_color = "assign" + elsif queue.status == "Cancel" + @bg_color = "cancel" + else + @bg_color = "normal" + end + %> +
- - <%= @i += 1 %> . Queue No - Seater : <%= queue.seater %> -

- <%= queue.queue_no %> -

- + Queue No : <%= queue.queue_no %> + Seater : <%= queue.seater %>
+ Name : <%= queue.name %>
+ Contact No : <%= queue.contact_no %> + Remark : <%= queue.remark %>
@@ -43,7 +49,7 @@
- +
\ No newline at end of file diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 84b6f199..b9418d22 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -1,14 +1,24 @@ @@ -23,21 +33,29 @@ <%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
-
- - - - - - - - - - - - - +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
CLR
+
0
+
ENT
+
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 05b74b7a..558d35dd 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -33,15 +33,16 @@ diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb index 1f519d2b..d6bbf436 100644 --- a/app/views/layouts/origami.html.erb +++ b/app/views/layouts/origami.html.erb @@ -19,14 +19,14 @@ <%= render 'layouts/header_orgiami' %>
<% flash.each do |type, message| %> - <% if !flash["errors"]%> -
- - <%=message%> -
- <% end %> + <% if !flash["errors"]%> +
+ + <%=message%> +
+ <% end %> - <% end %> + <% end %> <%= yield %>
diff --git a/app/views/origami/cash_ins/new.html.erb b/app/views/origami/cash_ins/new.html.erb new file mode 100644 index 00000000..1c513895 --- /dev/null +++ b/app/views/origami/cash_ins/new.html.erb @@ -0,0 +1,79 @@ + +
+
+

Payment Credit

+
+ + + + + + + + + + + + + +
Payment Reference +
Remark +
Payment Method + + + + + +
+
+
+
Reference Number
+
+
+
+
+
+
Amount
+
+
+

+
+
+
+
+
+
+ +
+
+ + diff --git a/app/views/origami/cash_mgmt/create.html.erb b/app/views/origami/cash_mgmt/create.html.erb new file mode 100644 index 00000000..1b4805a2 --- /dev/null +++ b/app/views/origami/cash_mgmt/create.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#create

+

Find me in app/views/cash_mgmt/create.html.erb

diff --git a/app/views/origami/cash_mgmt/index.html.erb b/app/views/origami/cash_mgmt/index.html.erb new file mode 100644 index 00000000..1f64a3df --- /dev/null +++ b/app/views/origami/cash_mgmt/index.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#index

+

Find me in app/views/cash_mgmt/index.html.erb

diff --git a/app/views/origami/cash_mgmt/new.html.erb b/app/views/origami/cash_mgmt/new.html.erb new file mode 100644 index 00000000..9f22e0c3 --- /dev/null +++ b/app/views/origami/cash_mgmt/new.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#new

+

Find me in app/views/cash_mgmt/new.html.erb

diff --git a/app/views/origami/cash_outs/new.html.erb b/app/views/origami/cash_outs/new.html.erb new file mode 100644 index 00000000..17f9bdf8 --- /dev/null +++ b/app/views/origami/cash_outs/new.html.erb @@ -0,0 +1,44 @@ +

Payment Debit

+
+
+ + + + + + + + + + + + + +
Payment Reference +
Remark +
Amount +
+ +
+ +
+

+
+
+
+
+ diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 9979c32f..fbbff065 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -138,7 +138,7 @@
-
20%
+
15%
7
@@ -149,7 +149,7 @@
-
30%
+
20%
0
@@ -160,7 +160,7 @@
-
50%
+
30%
@@ -172,7 +172,7 @@
- +
@@ -187,6 +187,8 @@
+ +
@@ -358,6 +360,64 @@ $(document).ready(function(){ } }); }); + + // Remove selected given discount item + $("#remove-item-discount").on('click', function(e){ + e.preventDefault(); + var sale_id = $('#sale-id').text(); + var discount_items = []; + + // Selected Items + var sale_items = get_selected_sale_items(); + if(sale_items.length == 0){ + alert("You have no selected item!"); + return; + } + + for(var i=0;i < sale_items.length;i++){ + if(sale_items[i].price < 0){ + discount_items.push(sale_items[i]); + } + else { + alert("You have selected no discount item!"); + return; + } + } + + var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) }; + $.ajax({ + type: "POST", + url: "/origami/" + sale_id + "/remove_discount_items", + data: params, + success: function(result){ + alert('Removed Discount'); + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + } + }); + }); + + $("#remove-all").on('click', function(e){ + e.preventDefault(); + var sale_id = $('#sale-id').text(); + $.ajax({ + type: "GET", + url: "/origami/" + sale_id + "/remove_all_discount", + success: function(result){ + alert('Removed All Discount'); + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + } + }); + }); }); /* Remove Selection */ diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 5888bb3e..99fa713e 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,6 +1,6 @@
-
+
-
+
+ + +
@@ -192,4 +196,16 @@ $(function() { } } }); + +$('#cash_in').on('click',function(){ + window.location.href = '/origami/cash_ins/new'; +}) + +$('#cash_out').on('click',function(){ + window.location.href = '/origami/cash_outs/new'; +}) + +$('#close_cashier').on('click',function(){ + window.location.href = '/origami/shift/close'; +}) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index be13b58c..f89560f3 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -3,9 +3,11 @@
-
- - \ No newline at end of file diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/dailysale/index.html.erb similarity index 97% rename from app/views/reports/daily_sale/index.html.erb rename to app/views/reports/dailysale/index.html.erb index 7b790148..5c42d6dc 100644 --- a/app/views/reports/daily_sale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_dailysale_index_path} %>
diff --git a/app/views/reports/daily_sale/index.xls.erb b/app/views/reports/dailysale/index.xls.erb similarity index 100% rename from app/views/reports/daily_sale/index.xls.erb rename to app/views/reports/dailysale/index.xls.erb diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index 8bdee23c..5befb18a 100644 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -1,135 +1,43 @@
-<% unless @sale_data.empty? %> -

<%=current_active_location.name%>

-

Sales Summary Report (BreadTalk)

-<% if params[:from]%> -

From Date : <%= params[:from] %> , To Date : <%= params[:to] %>

-<% end %> - - - - - - - - - - - - - - - - - - - - - <% void = 0 %> - <% card = 0 %> - <% credit_payment = 0 %> - <% cash = 0 %> - <% credit = 0 %> - <% foc = 0 %> - <% discount = 0 %> - <% total = 0 %> - <% count = 1 %> - <% discount_rev = 0 %> - <% total_rev = 0 %> - <% grand_rev = 0 %> - <% total_other_charges=0 %> - <% total_tax=0 %> - <% cash_received = 0 %> - <% total_cash_received = 0 %> - <% today_credit_payment_amount = 0 %> - <% old_location_id = 0%> - <% sub_total = 0 %> - <% count_of_void = 0 %> - <% flag = false %> - <% @sale_data.each do |sale| %> - <% credit_payment += sale[:credit_payment].to_f %> - <% card += sale[:card_amount].to_f %> - <% cash += sale[:cash_amount].to_f %> - <% credit += sale[:credit_amount].to_f %> - <% foc += sale[:foc_amount].to_f %> - <% discount += sale[:total_discount].to_f %> - <% total += sale[:grand_total].to_f %> - <% total_other_charges +=sale[:other_charges].to_f %> - <% total_tax +=sale[:total_tax].to_f %> +
Location NameDateCash SalesCredit SalesCredit ReceivedCard PaymentTotal DiscountTotal TaxesTotal Other ChargesFOC SalesVoid SalesGrand Total
+ + + + + + + + + <% TaxProfile.all.each do |r|%> + + <% end %> + + + - <% cash_received = sale[:cash_amount].to_f + sale[:credit_payment].to_f%> - <% total_cash_received = cash.to_f + credit_payment.to_f%> - <% today_credit_payment_amount += sale[:today_credit_payment].to_f %> - - - - - - - - - - - - - - - <% total_void_amount = 0 %> - <% if !@daily_void.nil? %> - <% @daily_void.each do |d_v|%> - - <% if d_v[:daily_void_amt].to_i > 0 %> - <% if d_v[:location_id] == sale[:location_id] %> - <% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%> - <%count_of_void+=1%> - - <%total_void_amount += d_v[:daily_void_amt].to_f%> - <% flag = true %> - - - - <%end %> - <% end%> - <% end%> - <% end%> - <% end%> - <% if flag == true%> - <% void += total_void_amount.to_f %> - - <% flag = false %> - <% end%> - <%if count_of_void == 0%> - - <%end %> - - - - -<%count_of_void= 0%> - <% count = count + 1 %> - <% end %> - - - - - - - - - - - - - - - - - -<% end %> -
DateReceipt NoCashier NameGross SalesDiscountTotal Sales<%=r.name%>Nett Sales
<%= sale[:location].to_s rescue '-' %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:total_discount].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:total_tax].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:other_charges].to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %> - <%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %> -
Grand Total<%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_tax ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_other_charges ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",foc ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %>
+ + <% total_sales = 0 %> + <% net_sales = 0 %> + <% @sale_data.each do |sale| %> + <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> + <% net_sales = total_sales.to_f + sale.total_tax.to_f%> + + <%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %> + <%=sale.receipt_no.to_s rescue ''%> + <%=Employee.find(sale.cashier_id).name rescue ''%> + <%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %> + <%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %> + <%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %> + <% sale.sale_taxes.each do |sale|%> + <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %> + <% end %> + + <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %> + + <% end %> + +
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 deleted file mode 100644 index 7f95b6b9..00000000 --- a/app/views/reports/sale_items/_shift_sale_report_filter.html.erb +++ /dev/null @@ -1,156 +0,0 @@ -
-
- <%= 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 deleted file mode 100644 index 26ad560e..00000000 --- a/app/views/reports/sale_items/index.html.erb +++ /dev/null @@ -1,141 +0,0 @@ - - -
- <%= 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 deleted file mode 100644 index 2807ec3f..00000000 --- a/app/views/reports/sale_items/index.xls.erb +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - -
-<% 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/reports/sale_item/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb similarity index 100% rename from app/views/reports/sale_item/_shift_sale_report_filter.html.erb rename to app/views/reports/saleitem/_shift_sale_report_filter.html.erb diff --git a/app/views/reports/sale_item/index.html.erb b/app/views/reports/saleitem/index.html.erb similarity index 95% rename from app/views/reports/sale_item/index.html.erb rename to app/views/reports/saleitem/index.html.erb index 7b0d6f38..b6482271 100644 --- a/app/views/reports/sale_item/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_saleitem_index_path} %>
diff --git a/app/views/reports/sale_item/index.xls.erb b/app/views/reports/saleitem/index.xls.erb similarity index 75% rename from app/views/reports/sale_item/index.xls.erb rename to app/views/reports/saleitem/index.xls.erb index 2807ec3f..3773619b 100644 --- a/app/views/reports/sale_item/index.xls.erb +++ b/app/views/reports/saleitem/index.xls.erb @@ -49,22 +49,6 @@ <% @sale_data.order("total_item desc").each do |sale| %> - <% if !acc_arr.include?(sale.account_id) %> - - <%= sale.account_name %> -   - Total Price By <%= sale.account_name %> - - <% @totalByAccount.each do |account, total| %> - <% if sale.account_id == account %> - <%= total %> - <% end %> - <% end %> - - - <% acc_arr.push(sale.account_id) %> - - <% end %>   <% if !cate_arr.include?(sale.menu_category_id) %> @@ -103,23 +87,7 @@ - <% @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 - <%= sub_total + total_price %> - - <% 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 %> diff --git a/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..34173d99 --- /dev/null +++ b/app/views/reports/shiftsale/_shift_sale_report_filter.html.erb @@ -0,0 +1,127 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ + +
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + <% end %> +
+
+ + \ No newline at end of file diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb new file mode 100644 index 00000000..8582a578 --- /dev/null +++ b/app/views/reports/shiftsale/index.html.erb @@ -0,0 +1,160 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_shiftsale_index_path} %> +
+
+ +
+
+ +
+
+ +
+ +
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + <% void = 0%> + <% cash = 0%> + <% credit = 0%> + <% accept_credit = 0%> + <% foc = 0%> + <% card = 0%> + <% total = 0%> + <% rounding_adj = 0%> + <% g_total = 0 %> + + <% @sale_data.each do |result| %> + + + + + + + + + + + + <% grand_total = result[:grand_total].to_f - result[:rounding_adj].to_f %> + + + <% void += result[:void_amount].to_f %> + <% cash += result[:cash_amount].to_f %> + <% credit += result[:credit_amount].to_f %> + <% accept_credit += result[:accept_credit_amount].to_f %> + <% foc += result[:foc_amount].to_f %> + <% card += result[:card_amount].to_f %> + <% total += result[:grand_total].to_f %> + <% rounding_adj += result[:rounding_adj].to_f %> + <% g_total += grand_total.to_f %> + + <% end %> + + + + + + + + + + + + + + +
From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%>
Cashier StationShift NameVoid AmountCash PaymentCredit ChargesCredit PaymentFOC PaymentCard PaymentGrand Total + +
Rounding Adj
Rounding AdjGrand Total
+ <%= result[:cashier_station_name] rescue '-'%> + <%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> - + <%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %> + <%= sprintf "%.2f",result[:cash_amount].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:credit_amount].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:accept_credit_amount].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:foc_amount].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:card_amount].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%><%= sprintf "%.2f",grand_total.to_f.to_d rescue '-'%>
(<%= sprintf("%.2f",void) rescue '-'%>)<%= sprintf("%.2f",cash) rescue '-'%><%= sprintf("%.2f",credit) rescue '-'%><%= sprintf("%.2f",accept_credit) rescue '-'%><%= sprintf("%.2f",foc) rescue '-'%><%= sprintf("%.2f",card) rescue '-'%><%= sprintf("%.2f",total) rescue '-'%><%= sprintf("%.2f",rounding_adj) rescue '-'%><%= sprintf("%.2f",g_total) rescue '-'%>
+
+
+
+ + + \ No newline at end of file diff --git a/app/views/reports/daily_sales/index.xls.erb b/app/views/reports/shiftsale/index.xls.erb similarity index 100% rename from app/views/reports/daily_sales/index.xls.erb rename to app/views/reports/shiftsale/index.xls.erb diff --git a/config/application.rb b/config/application.rb index 5ce0a92a..7e16975c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,7 +13,6 @@ module SXRestaurants # -- all .rb files in that directory are automatically loaded. config.active_record.time_zone_aware_types = [:datetime, :time] config.active_job.queue_adapter = :sidekiq - # config.time_zone = 'Asia/Rangoon' - + config.time_zone = 'Asia/Rangoon' end end diff --git a/config/routes.rb b/config/routes.rb index b6535034..35669703 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,8 @@ Rails.application.routes.draw do #--------- Cashier ------------# namespace :origami do + resources :cash_ins, only:[:new, :create] + resources :cash_outs, only:[:new, :create] root "home#index" get "table/:dining_id" => "home#show" do #origami/:booking_id will show # resources :discounts, only: [:index,:new, :create ] #add discount type @@ -89,14 +91,37 @@ Rails.application.routes.draw do get 'room/:room_id' => 'rooms#show' get 'order/:order_id' => "orders#show" - post '/:booking_id' => 'home#item_show' + # post '/:booking_id' => 'home#item_show' + # Other Charges + get "/:sale_id/other_charges" => "other_charges#index" + post "/:sale_id/other_charges" => "other_charges#create" + + # Discount get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" + get "/:id/remove_all_discount" => "discounts#remove_all_discount" + post "/:id/remove_discount_items" => "discounts#remove_discount_items" - post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' } + get "/:id/request_bills" => "request_bills#print",:as => "request_bill" get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } + + #---------Shift ---------------# + resources :shifts, only: [:index, :new, :create, :edit] + post 'close_shift' => 'shifts#update_shift' + get 'shift/close' => 'shifts#show' + #shift - index (open/close shift landing page) + #shift - show (sales summary display) + #shift - new (open shift) + #shift - edit (close shift) + + resources :cash_mgmt, only: [:new, :create] + #payment - accepting or expending money from cashier - [Cash Journal] + #payment - Incoming payments - [accept all payment types (cash, other payments (except rebate)) + #payment - Outing payments - Cash only [ *Misc expeness tracking] + #--------- Payment ------------# + get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' } get 'sale/:sale_id/payment' => 'payments#show' post 'payment/cash' => 'payments#create' @@ -148,6 +173,7 @@ Rails.application.routes.draw do get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign" post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table" + post "/dining_queues/cancel_queue" =>"dining_queues#cancel_queue", :as => "cancel_queue" end @@ -241,8 +267,9 @@ Rails.application.routes.draw do #--------- Reports Controller Sections ------------# namespace :reports do resources :receipt_no, :only => [:index, :show] - resources :daily_sales, :only => [:index, :show] - resources :sale_items, :only => [:index, :show] + resources :dailysale, :only => [:index, :show] + resources :saleitem, :only => [:index, :show] + resources :shiftsale, :only => [:index, :show] # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show] diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170403160742_create_sales.rb index 7e4850f1..ae806472 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170403160742_create_sales.rb @@ -20,7 +20,7 @@ class CreateSales < ActiveRecord::Migration[5.1] t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00 - + t.integer :shift_sale_id, :null => false t.timestamps end end diff --git a/db/migrate/20170626191519_create_shift_sales.rb b/db/migrate/20170626191519_create_shift_sales.rb new file mode 100644 index 00000000..18323c9d --- /dev/null +++ b/db/migrate/20170626191519_create_shift_sales.rb @@ -0,0 +1,27 @@ +class CreateShiftSales < ActiveRecord::Migration[5.1] + def change + create_table :shift_sales do |t| + t.references :cashier_terminal, foreign_key: true, :null => false + t.datetime :shift_started_at + t.datetime :shift_closed_at + t.references :employee, foreign_key: true #cashier + t.decimal :opening_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :closing_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :total_revenue, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :total_discounts, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :total_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :grand_total, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :nett_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :cash_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :credit_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.json :other_sales + t.decimal :commercial_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :cash_in, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :cash_out, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.integer :dining_count, :default => 0 + t.integer :takeaway_count, :default => 0 + t.integer :member_count, :default => 0 + t.timestamps + end + end +end diff --git a/db/migrate/20170627035218_create_payment_journals.rb b/db/migrate/20170627035218_create_payment_journals.rb new file mode 100644 index 00000000..e82dd788 --- /dev/null +++ b/db/migrate/20170627035218_create_payment_journals.rb @@ -0,0 +1,15 @@ +class CreatePaymentJournals < ActiveRecord::Migration[5.1] + def change + create_table :payment_journals do |t| + t.string :payment_references,:null => false + t.string :remark + t.decimal :credit_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :debit_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.string :payment_method,:null => false, :default => "CASH" + t.string :payment_status,:null => false, :default => "NEW" + t.string :payment_method_references + t.integer :created_by, :null => false + t.timestamps + end + end +end diff --git a/db/migrate/20170623101708_create_dining_queues.rb b/db/migrate/20170627085117_dining_queues.rb similarity index 69% rename from db/migrate/20170623101708_create_dining_queues.rb rename to db/migrate/20170627085117_dining_queues.rb index dd2ea134..a4977f8c 100644 --- a/db/migrate/20170623101708_create_dining_queues.rb +++ b/db/migrate/20170627085117_dining_queues.rb @@ -1,6 +1,6 @@ -class CreateDiningQueues < ActiveRecord::Migration[5.1] +class DiningQueues < ActiveRecord::Migration[5.1] def change - create_table :dining_queues do |t| + create_table :dining_queues do |t| t.string :name t.string :contact_no t.string :queue_no @@ -9,6 +9,6 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1] t.integer :seater t.string :remark t.timestamps - end + end end end diff --git a/db/migrate/20170602093159_create_print_settings.rb b/db/migrate/20170628103624_create_print_settings.rb similarity index 88% rename from db/migrate/20170602093159_create_print_settings.rb rename to db/migrate/20170628103624_create_print_settings.rb index e9ea5e83..aca49a0d 100644 --- a/db/migrate/20170602093159_create_print_settings.rb +++ b/db/migrate/20170628103624_create_print_settings.rb @@ -13,6 +13,9 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1] t.decimal :page_width, :null => false, :default => 200 t.decimal :page_height, :null => false, :default => 800 t.integer :print_copies, :null => false, :default => 1 + t.string :precision + t.boolean :delimiter + t.integer :heading_space t.timestamps end diff --git a/db/scaffold_structure b/db/scaffold_structure index 064f62d4..cd8a52c0 100644 --- a/db/scaffold_structure +++ b/db/scaffold_structure @@ -22,3 +22,5 @@ rails generate scaffold_controller Setup/CashierTerminal name:string is_active:b rails generate scaffold_controller Settings/OrderQueueStation station_name:string is_active:boolean processing_items:json print_copy:boolean printer_name:string font_size:integer cut_per_item:boolean use_alternate_name:boolean created_by:string --no-migration rails generate scaffold_controller transactions/Sale cashier:references cashier_name:string requested_by:string requested_at:datetime receipt_no:string receipt_date:datetime customer:references payment_status:string sale_status:string total_amount:decimal total_discount:decimal total_tax:decimal tax_type:string grand_total:decimal rounding_adjustment:decimal amount_received:decimal amount_changed:decimal --no-migration + +rails g model shift_sale cashier_terminal:references shift_started_at:datetime shift_closed_at:datetime employee:references opening_balance:decimal closing_balance:decimal total_revenue:decimal total_discounts:decimal total_taxes:decimal grand_total:decimal nett_sales:decimal cash_sales:decimal credit_sales:decimal other_sales:decimal commercial_taxes:decimal cash_in:decimal cash_out:decimal diff --git a/db/seeds.rb b/db/seeds.rb index 841495d4..2635ab4f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -63,6 +63,7 @@ employee_roles = Lookup.create([{lookup_type:'employee_roles', name: 'Cashier', {lookup_type:'employee_roles', name: 'Waiter', value: 'waiter'}, {lookup_type:'employee_roles', name: 'Supervisour', value: 'supervisour'}, {lookup_type:'employee_roles', name: 'Manager', value: 'manager'}, + {lookup_type:'employee_roles', name: 'Accountant', value: 'account'}, {lookup_type:'employee_roles', name: 'Administrator', value: 'administrator'}]) #booking_status @@ -82,6 +83,12 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag {lookup_type:'void_reason', name: 'Cashier Mistake', value: 'Cashier Mistake'}, {lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}]) + # sale void reason + float_value = Lookup.create([{lookup_type:'float_value', name: '500', value: '500'}, + {lookup_type:'float_value', name: '1000', value: '1000'}, + {lookup_type:'float_value', name: '5000', value: '5000'}, + {lookup_type:'float_value', name: '10000', value: '10000'}]) + #WALK CUSTOMER - Default CUSTOMER (take key 1) customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"}) @@ -149,11 +156,11 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111 admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) -order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) -order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) -request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) -crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) -queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"}) +order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"}) +order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"}) +request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"}) +crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"}) +queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"}) member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) @@ -173,4 +180,7 @@ payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +cashier_terminal = CashierTerminal.create({name:"Terminal 1"}) +cashier_terminal2 = CashierTerminal.create({name:"Terminal 2"}) +cashier_terminal3 = CashierTerminal.create({name:"Terminal 3"}) puts " Finished System Default Set Up Data " diff --git a/dump.rdb b/dump.rdb index acef6aa7..e6612cd4 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 9d4e0ddd..affe76ff 100644 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -11,7 +11,9 @@ namespace :clear do Sale.delete_all SaleAudit.delete_all SalePayment.delete_all - DiningFacility.update_all(status:'available') + ShiftSale.delete_all + PaymentJournal.delete_all + DiningFacility.update_all(status:'available') puts "Clear Data Done." end end diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 1979d364..47b84ef5 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -60,8 +60,8 @@ menu_category2 = MenuCategory.create({menu: menu, code:"C002", name: "Specialty menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 3,created_by: "SYSTEM DEFAULT"}) # Australia Angus Boneless Short Rib menu_category1_menu_item6 = SimpleMenuItem.create({item_code:"01007", name: "Australia Angus Boneless Short Rib", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0142", menu_item: menu_category1_menu_item5, price:12500.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0141", menu_item: menu_category1_menu_item5, price:25000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0142", menu_item: menu_category1_menu_item6, price:12500.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0141", menu_item: menu_category1_menu_item6, price:25000.00, is_on_promotion:false}]) # Spain Beef menu_category1_menu_item7 = SimpleMenuItem.create({item_code:"01008", name: "Spain Beef", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0152", menu_item: menu_category1_menu_item7, price:8000.00, is_on_promotion:false}]) @@ -83,10 +83,13 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0192", menu_item: menu_category1_menu_item11, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0191", menu_item: menu_category1_menu_item11, price:14000.00, is_on_promotion:false}]) # Sliced Lamb - menu_category1_menu_item11 = SimpleMenuItem.create({item_code:"01012", name: "Sliced Lamb", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item11, price:7000.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item11, price:14000.00, is_on_promotion:false}]) - + menu_category1_menu_item12 = SimpleMenuItem.create({item_code:"01013", name: "Sliced Lamb", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item12, price:7000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item12, price:14000.00, is_on_promotion:false}]) + # Sliced Beef ( Think ) + menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Think )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1432", menu_item: menu_category1_menu_item13, price:7000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1431", menu_item: menu_category1_menu_item13, price:14000.00, is_on_promotion:false}]) # Pork menu_category4 = MenuCategory.create({menu: menu, code:"C004", name: "Pork", alt_name: "Pork", order_by: 4,created_by: "SYSTEM DEFAULT"}) # Sliced Tenderloin Pork @@ -282,7 +285,7 @@ menu_category8 = MenuCategory.create({menu: menu, code:"C008", name: "Seafood", menu_category1_menu_item61 = SimpleMenuItem.create({item_code:"01062", name: "Live Lobster", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0681", menu_item: menu_category1_menu_item61, price:10.00, is_on_promotion:false}]) # Live Mantis - menu_category1_menu_item62 = SimpleMenuItem.create({item_code:"01063", name: "Live Mantis", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item62 = SimpleMenuItem.create({item_code:"01063", name: "Live Mantis Prawn", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:" ",item_instance_code:"II0691", menu_item: menu_category1_menu_item62, price:10.00, is_on_promotion:false}]) # Dumpling menu_category9 = MenuCategory.create({menu: menu, code:"C009", name: "Dumpling", alt_name: "Chicken", order_by: 9, created_by: "SYSTEM DEFAULT"}) @@ -567,20 +570,20 @@ menu_category19 = MenuCategory.create({menu: menu, code:"C0018", name: "Beer", a menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1392", menu_item: menu_category1_menu_item132, price:1500.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1391", menu_item: menu_category1_menu_item132, price:3000.00, is_on_promotion:false}]) # # Tiger Beer -# menu_category1_menu_item133 = SimpleMenuItem.create({item_code:"01134", name: "Tiger Beer ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1402", menu_item: menu_category1_menu_item133, price:1500.00, is_on_promotion:false}]) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1401", menu_item: menu_category1_menu_item133, price:3000.00, is_on_promotion:false}]) + menu_category1_menu_item133 = SimpleMenuItem.create({item_code:"01134", name: "Tiger Beer ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1442", menu_item: menu_category1_menu_item133, price:1500.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1441", menu_item: menu_category1_menu_item133, price:3000.00, is_on_promotion:false}]) # Heineken Beer menu_category1_menu_item134 = SimpleMenuItem.create({item_code:"01135", name: "Heineken Beer", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1402", menu_item: menu_category1_menu_item134, price:1800.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1401", menu_item: menu_category1_menu_item134, price:3600.00, is_on_promotion:false}]) # Tsing Tao Beer menu_category1_menu_item135 = SimpleMenuItem.create({item_code:"01136", name: "Tsing Tao Beer", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II141", menu_item: menu_category1_menu_item135, price:2800.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II1411", menu_item: menu_category1_menu_item135, price:2800.00, is_on_promotion:false}]) # ABC Stout menu_category1_menu_item136 = SimpleMenuItem.create({item_code:"01137", name: "ABC Stout ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1432", menu_item: menu_category1_menu_item136, price:2000.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1431", menu_item: menu_category1_menu_item136, price:4000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1422", menu_item: menu_category1_menu_item136, price:2000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1421", menu_item: menu_category1_menu_item136, price:4000.00, is_on_promotion:false}]) # Signature Hot Tea" menu_category20 = MenuCategory.create({menu: menu, code:"C0019", name: "Signature Hot Tea", alt_name: "Chicken", order_by: 19, created_by: "SYSTEM DEFAULT"}) puts "Beauty in the pot's menu setup" diff --git a/public/fonts/Chinese.ttf b/public/fonts/Chinese.ttf new file mode 100755 index 00000000..6d26dd75 Binary files /dev/null and b/public/fonts/Chinese.ttf differ diff --git a/public/fonts/Zawgyi-One.ttf b/public/fonts/Zawgyi-One.ttf new file mode 100755 index 00000000..a1cd1739 Binary files /dev/null and b/public/fonts/Zawgyi-One.ttf differ diff --git a/public/fonts/padauk.ttf b/public/fonts/padauk.ttf new file mode 100755 index 00000000..68958e98 Binary files /dev/null and b/public/fonts/padauk.ttf differ diff --git a/spec/controllers/cash_mgmt_controller_spec.rb b/spec/controllers/cash_mgmt_controller_spec.rb new file mode 100644 index 00000000..0772e07e --- /dev/null +++ b/spec/controllers/cash_mgmt_controller_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe CashMgmtController, type: :controller do + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to have_http_status(:success) + end + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to have_http_status(:success) + end + end + + describe "GET #create" do + it "returns http success" do + get :create + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/controllers/origami/shifts_controller_spec.rb b/spec/controllers/origami/shifts_controller_spec.rb new file mode 100644 index 00000000..6bc402b9 --- /dev/null +++ b/spec/controllers/origami/shifts_controller_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +RSpec.describe Origami::ShiftsController, type: :controller do + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to have_http_status(:success) + end + end + + describe "GET #show" do + it "returns http success" do + get :show + expect(response).to have_http_status(:success) + end + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to have_http_status(:success) + end + end + + describe "GET #edit" do + it "returns http success" do + get :edit + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/controllers/reports/dailysale_controller_spec.rb b/spec/controllers/reports/dailysale_controller_spec.rb new file mode 100644 index 00000000..b80d898e --- /dev/null +++ b/spec/controllers/reports/dailysale_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::DailysaleController, type: :controller do + +end diff --git a/spec/controllers/reports/dailysales_controller_spec.rb b/spec/controllers/reports/dailysales_controller_spec.rb deleted file mode 100644 index 83fcb321..00000000 --- a/spec/controllers/reports/dailysales_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Reports::DailysalesController, type: :controller do - -end diff --git a/spec/controllers/reports/sale_items_controller_spec.rb b/spec/controllers/reports/sale_items_controller_spec.rb deleted file mode 100644 index 546fc874..00000000 --- a/spec/controllers/reports/sale_items_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Reports::SaleItemsController, type: :controller do - -end diff --git a/spec/controllers/reports/saleitem_controller_spec.rb b/spec/controllers/reports/saleitem_controller_spec.rb new file mode 100644 index 00000000..3e431a45 --- /dev/null +++ b/spec/controllers/reports/saleitem_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::SaleitemController, type: :controller do + +end diff --git a/spec/controllers/reports/shiftsale_controller_spec.rb b/spec/controllers/reports/shiftsale_controller_spec.rb new file mode 100644 index 00000000..ed90f941 --- /dev/null +++ b/spec/controllers/reports/shiftsale_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::ShiftsaleController, type: :controller do + +end diff --git a/spec/helpers/reports/sale_items_helper_spec.rb b/spec/helpers/cash_mgmt_helper_spec.rb similarity index 69% rename from spec/helpers/reports/sale_items_helper_spec.rb rename to spec/helpers/cash_mgmt_helper_spec.rb index ea2807c4..c1b99e8f 100644 --- a/spec/helpers/reports/sale_items_helper_spec.rb +++ b/spec/helpers/cash_mgmt_helper_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' # Specs in this file have access to a helper object that includes -# the Reports::SaleItemsHelper. For example: +# the CashMgmtHelper. For example: # -# describe Reports::SaleItemsHelper do +# describe CashMgmtHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end # end -RSpec.describe Reports::SaleItemsHelper, type: :helper do +RSpec.describe CashMgmtHelper, type: :helper do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/helpers/reports/dailysales_helper_spec.rb b/spec/helpers/origami/shifts_helper_spec.rb similarity index 69% rename from spec/helpers/reports/dailysales_helper_spec.rb rename to spec/helpers/origami/shifts_helper_spec.rb index 96853812..52cd53cc 100644 --- a/spec/helpers/reports/dailysales_helper_spec.rb +++ b/spec/helpers/origami/shifts_helper_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' # Specs in this file have access to a helper object that includes -# the Reports::DailysalesHelper. For example: +# the Origami::ShiftsHelper. For example: # -# describe Reports::DailysalesHelper do +# describe Origami::ShiftsHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end # end -RSpec.describe Reports::DailysalesHelper, type: :helper do +RSpec.describe Origami::ShiftsHelper, type: :helper do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/helpers/reports/dailysale_helper_spec.rb b/spec/helpers/reports/dailysale_helper_spec.rb new file mode 100644 index 00000000..2b1e1ddc --- /dev/null +++ b/spec/helpers/reports/dailysale_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::DailysaleHelper. For example: +# +# describe Reports::DailysaleHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Reports::DailysaleHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/reports/saleitem_helper_spec.rb b/spec/helpers/reports/saleitem_helper_spec.rb new file mode 100644 index 00000000..2c579f0e --- /dev/null +++ b/spec/helpers/reports/saleitem_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::SaleitemHelper. For example: +# +# describe Reports::SaleitemHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Reports::SaleitemHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/reports/shiftsale_helper_spec.rb b/spec/helpers/reports/shiftsale_helper_spec.rb new file mode 100644 index 00000000..3555ce0c --- /dev/null +++ b/spec/helpers/reports/shiftsale_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::ShiftsaleHelper. For example: +# +# describe Reports::ShiftsaleHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Reports::ShiftsaleHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/payment_journal_spec.rb b/spec/models/payment_journal_spec.rb new file mode 100644 index 00000000..1d69ec1b --- /dev/null +++ b/spec/models/payment_journal_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe PaymentJournal, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/shift_sale_spec.rb b/spec/models/shift_sale_spec.rb new file mode 100644 index 00000000..18b726dc --- /dev/null +++ b/spec/models/shift_sale_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ShiftSale, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/cash_mgmt/create.html.erb_spec.rb b/spec/views/cash_mgmt/create.html.erb_spec.rb new file mode 100644 index 00000000..99f19970 --- /dev/null +++ b/spec/views/cash_mgmt/create.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "cash_mgmt/create.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/cash_mgmt/index.html.erb_spec.rb b/spec/views/cash_mgmt/index.html.erb_spec.rb new file mode 100644 index 00000000..47aac0d1 --- /dev/null +++ b/spec/views/cash_mgmt/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "cash_mgmt/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/cash_mgmt/new.html.erb_spec.rb b/spec/views/cash_mgmt/new.html.erb_spec.rb new file mode 100644 index 00000000..75ceeb52 --- /dev/null +++ b/spec/views/cash_mgmt/new.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "cash_mgmt/new.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/origami/shifts/edit.html.erb_spec.rb b/spec/views/origami/shifts/edit.html.erb_spec.rb new file mode 100644 index 00000000..3e38121f --- /dev/null +++ b/spec/views/origami/shifts/edit.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "shifts/edit.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/origami/shifts/index.html.erb_spec.rb b/spec/views/origami/shifts/index.html.erb_spec.rb new file mode 100644 index 00000000..6a148d25 --- /dev/null +++ b/spec/views/origami/shifts/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "shifts/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/origami/shifts/new.html.erb_spec.rb b/spec/views/origami/shifts/new.html.erb_spec.rb new file mode 100644 index 00000000..60e9a23c --- /dev/null +++ b/spec/views/origami/shifts/new.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "shifts/new.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/origami/shifts/show.html.erb_spec.rb b/spec/views/origami/shifts/show.html.erb_spec.rb new file mode 100644 index 00000000..372203e3 --- /dev/null +++ b/spec/views/origami/shifts/show.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "shifts/show.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end