From 743b978c446e524ec29ee2d87b1d8a40b5d11bbf Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 4 Jun 2017 15:52:29 +0630 Subject: [PATCH 01/28] update --- app/views/settings/menu_item_instances/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/settings/menu_item_instances/_form.html.erb b/app/views/settings/menu_item_instances/_form.html.erb index c0170245..7d326c95 100644 --- a/app/views/settings/menu_item_instances/_form.html.erb +++ b/app/views/settings/menu_item_instances/_form.html.erb @@ -1,5 +1,5 @@ -<%= simple_form_for([:settings,:menu_item, @settings_menu_item_instance]) do |f| %> +<%= simple_form_for([:settings,@item, @settings_menu_item_instances]) do |f| %> <%= f.error_notification %> From fcd159086818c784e0cf4aeea27f962fb5b5fce4 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 19 Jun 2017 15:51:04 +0630 Subject: [PATCH 02/28] change query --- app/assets/stylesheets/origami.scss | 4 ++++ app/models/order.rb | 4 ++-- app/views/origami/payments/show.html.erb | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 71a9915e..c96237fa 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -95,6 +95,10 @@ background-color:#7a62d3; } +.orange{ + background-color:#FF7F50; +} + .red { background-color:#ff0000; } diff --git a/app/models/order.rb b/app/models/order.rb index f3ae798c..9c65304b 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .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') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -262,7 +262,7 @@ class Order < ApplicationRecord .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') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 995e13e9..91d5b6b2 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -235,9 +235,10 @@
- - - + + + +
From 25b6a893f2168721b5f2d118fa371347dc031c0a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 22 Jun 2017 15:33:55 +0630 Subject: [PATCH 03/28] first cancan --- app/controllers/application_controller.rb | 13 +++++++------ app/controllers/base_origami_controller.rb | 9 +++++++++ app/controllers/origami/customers_controller.rb | 4 +--- app/controllers/origami/request_bills_controller.rb | 1 + app/controllers/settings/employees_controller.rb | 2 +- app/models/ability.rb | 13 +++++++------ 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 50278d71..6a5070f6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,16 +3,17 @@ class ApplicationController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception - helper_method :current_company,:current_login_employee - + helper_method :current_company,:current_login_employee,:current_user + # alias_method :current_user, :current_login_employee,:current_user #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON - # rescue_from CanCan::AccessDenied do |exception| - # flash[:warning] = exception.message - # redirect_to root_path - # end + + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end def current_user @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index b250303d..2af895da 100644 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -5,5 +5,14 @@ class BaseOrigamiController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end + end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 373dc2f5..ef813e26 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -1,8 +1,6 @@ class Origami::CustomersController < BaseOrigamiController - #Form to add customer - + load_and_authorize_resource def index - - end # GET /crm/customers/1 diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 37eef687..1bce60e6 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,4 +1,5 @@ class Origami::RequestBillsController < BaseOrigamiController + load_and_authorize_resource # Print Request Bill and add to sale tables def print @sale = Sale.new diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index dc7093f3..07656470 100644 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -1,5 +1,5 @@ class Settings::EmployeesController < ApplicationController - # load_and_authorize_resource + load_and_authorize_resource before_action :set_employee, only: [:show, :edit, :update, :destroy] diff --git a/app/models/ability.rb b/app/models/ability.rb index 2b28ab61..f48220a8 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -4,20 +4,22 @@ class Ability def initialize(user) user ||= Employee.new - if user.role? :administrator + if user.role == "administrator" can :manage, :all - elsif user.role? :cashier + elsif user.role == "cashier" + can :read, Order can :update, Order - can :completed_order_item, Order can :read, Sale can :update, Sale + can :add_customer, Customer + can :update_sale_by_customer, Customer - elsif user.role? :accountant + elsif user.role == "accountant" can :read, Order can :update, Order @@ -28,6 +30,5 @@ class Ability can :manual_complete_sale, Sale end - end -end \ No newline at end of file +end From 01e5b7ba6c3d849fd464efb3131a13779dfb2473 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 23 Jun 2017 09:41:48 +0630 Subject: [PATCH 04/28] update authorize --- .../javascripts/reports/daily_sales.coffee | 3 + .../javascripts/reports/dailysales.coffee | 3 + .../javascripts/reports/sale_items.coffee | 3 + .../stylesheets/reports/daily_sales.scss | 3 + .../stylesheets/reports/dailysales.scss | 3 + .../stylesheets/reports/sale_items.scss | 3 + app/controllers/base_crm_controller.rb | 12 +- app/controllers/base_oqs_controller.rb | 8 + app/controllers/base_report_controller.rb | 9 + app/controllers/crm/bookings_controller.rb | 2 +- app/controllers/crm/customers_controller.rb | 1 + .../crm/dining_queues_controller.rb | 1 + app/controllers/home_controller.rb | 6 + .../origami/discounts_controller.rb | 1 + .../origami/moveroom_controller.rb | 4 +- .../origami/movetable_controller.rb | 2 + .../origami/payments_controller.rb | 2 +- .../origami/request_bills_controller.rb | 2 +- app/controllers/print_settings_controller.rb | 1 + ...ntroller.rb => bksale_items_controller.rb} | 4 +- .../reports/daily_sales_controller.rb | 17 ++ ...troller.rb => daily_salesbk_controller.rb} | 4 +- .../reports/sale_items_controller.rb | 19 ++ .../settings/accounts_controller.rb | 1 + .../settings/cashier_terminals_controller.rb | 1 + .../settings/membership_actions_controller.rb | 1 + .../membership_settings_controller.rb | 1 + .../settings/menu_categories_controller.rb | 1 + .../menu_item_attributes_controller.rb | 1 + .../menu_item_instances_controller.rb | 1 + .../settings/menu_item_options_controller.rb | 1 + app/controllers/settings/menus_controller.rb | 1 + .../order_queue_stations_controller.rb | 1 + .../payment_method_settings_controller.rb | 1 + .../settings/tax_profiles_controller.rb | 1 + app/controllers/settings/zones_controller.rb | 1 + .../transactions/orders_controller.rb | 1 + .../transactions/sales_controller.rb | 1 + app/helpers/reports/daily_sales_helper.rb | 2 + app/helpers/reports/dailysales_helper.rb | 2 + app/helpers/reports/sale_items_helper.rb | 2 + app/models/ability.rb | 62 ++++-- app/views/layouts/_header.html.erb | 4 +- app/views/origami/home/show.html.erb | 7 + app/views/reports/daily_sale/index.html.erb | 4 +- .../_shift_sale_report_filter.html.erb | 151 ++++++++++++++ app/views/reports/daily_sales/index.html.erb | 190 ++++++++++++++++++ app/views/reports/daily_sales/index.xls.erb | 116 +++++++++++ app/views/reports/sale_item/index.html.erb | 4 +- .../_shift_sale_report_filter.html.erb | 156 ++++++++++++++ app/views/reports/sale_items/index.html.erb | 141 +++++++++++++ app/views/reports/sale_items/index.xls.erb | 136 +++++++++++++ app/views/settings/lookups/index.html.erb | 4 +- config/routes.rb | 6 +- .../reports/daily_sales_controller_spec.rb | 5 + .../reports/dailysales_controller_spec.rb | 5 + .../reports/sale_items_controller_spec.rb | 5 + .../reports/daily_sales_helper_spec.rb | 15 ++ .../helpers/reports/dailysales_helper_spec.rb | 15 ++ .../helpers/reports/sale_items_helper_spec.rb | 15 ++ 60 files changed, 1141 insertions(+), 34 deletions(-) create mode 100644 app/assets/javascripts/reports/daily_sales.coffee create mode 100644 app/assets/javascripts/reports/dailysales.coffee create mode 100644 app/assets/javascripts/reports/sale_items.coffee create mode 100644 app/assets/stylesheets/reports/daily_sales.scss create mode 100644 app/assets/stylesheets/reports/dailysales.scss create mode 100644 app/assets/stylesheets/reports/sale_items.scss rename app/controllers/reports/{sale_item_controller.rb => bksale_items_controller.rb} (74%) create mode 100644 app/controllers/reports/daily_sales_controller.rb rename app/controllers/reports/{daily_sale_controller.rb => daily_salesbk_controller.rb} (72%) create mode 100644 app/controllers/reports/sale_items_controller.rb create mode 100644 app/helpers/reports/daily_sales_helper.rb create mode 100644 app/helpers/reports/dailysales_helper.rb create mode 100644 app/helpers/reports/sale_items_helper.rb create mode 100644 app/views/reports/daily_sales/_shift_sale_report_filter.html.erb create mode 100644 app/views/reports/daily_sales/index.html.erb create mode 100644 app/views/reports/daily_sales/index.xls.erb create mode 100644 app/views/reports/sale_items/_shift_sale_report_filter.html.erb create mode 100644 app/views/reports/sale_items/index.html.erb create mode 100644 app/views/reports/sale_items/index.xls.erb create mode 100644 spec/controllers/reports/daily_sales_controller_spec.rb create mode 100644 spec/controllers/reports/dailysales_controller_spec.rb create mode 100644 spec/controllers/reports/sale_items_controller_spec.rb create mode 100644 spec/helpers/reports/daily_sales_helper_spec.rb create mode 100644 spec/helpers/reports/dailysales_helper_spec.rb create mode 100644 spec/helpers/reports/sale_items_helper_spec.rb diff --git a/app/assets/javascripts/reports/daily_sales.coffee b/app/assets/javascripts/reports/daily_sales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/daily_sales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/reports/dailysales.coffee b/app/assets/javascripts/reports/dailysales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/dailysales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/reports/sale_items.coffee b/app/assets/javascripts/reports/sale_items.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/reports/sale_items.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/reports/daily_sales.scss b/app/assets/stylesheets/reports/daily_sales.scss new file mode 100644 index 00000000..79ed876a --- /dev/null +++ b/app/assets/stylesheets/reports/daily_sales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/daily_sales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/reports/dailysales.scss b/app/assets/stylesheets/reports/dailysales.scss new file mode 100644 index 00000000..cfc48374 --- /dev/null +++ b/app/assets/stylesheets/reports/dailysales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/dailysales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/reports/sale_items.scss b/app/assets/stylesheets/reports/sale_items.scss new file mode 100644 index 00000000..b9692327 --- /dev/null +++ b/app/assets/stylesheets/reports/sale_items.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reports/sale_items controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index a6bf7754..38f0df3d 100644 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,9 +1,17 @@ class BaseCrmController < ActionController::Base - include LoginVerification - layout "CRM" + include LoginVerification + layout "CRM" #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end end diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 16fe9b07..50d7bd55 100644 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -5,5 +5,13 @@ class BaseOqsController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end end diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 0ea51cf5..28ba5c2b 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -5,6 +5,15 @@ class BaseReportController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + redirect_to root_path + end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end + PERIOD = { "today" => 0, "yesterday" => 1, diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb index 65511512..efaa5419 100644 --- a/app/controllers/crm/bookings_controller.rb +++ b/app/controllers/crm/bookings_controller.rb @@ -1,5 +1,5 @@ class Crm::BookingsController < BaseCrmController - + load_and_authorize_resource def update_booking booking = Booking.find(params[:booking_id]) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index ce585686..41d3d6ad 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -1,4 +1,5 @@ class Crm::CustomersController < BaseCrmController + load_and_authorize_resource except: [:create] before_action :set_crm_customer, only: [:show, :edit, :update, :destroy] # GET /crm/customers diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 734793b3..c4d9426b 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -1,4 +1,5 @@ class Crm::DiningQueuesController < BaseCrmController + load_and_authorize_resource before_action :set_dining_queue, only: [:show, :edit, :update, :destroy] # GET /crm/dining_queues diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 29e9082a..f480b95f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,6 +18,12 @@ class HomeController < ApplicationController elsif @employee.role == "cashier" session[:session_token] = @employee.token_session redirect_to origami_root_path + elsif @employee.role == "manager" + session[:session_token] = @employee.token_session + redirect_to dashboard_path + elsif @employee.role == "accountant" + session[:session_token] = @employee.token_session + redirect_to dashboard_path else render :index end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index a195bb6a..0c9971f4 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -1,4 +1,5 @@ class Origami::DiscountsController < BaseOrigamiController + authorize_resource :class => false #discount page show from origami index with selected order def index diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index c51fcbb1..ef1c286a 100644 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -1,5 +1,7 @@ class Origami::MoveroomController < BaseOrigamiController - + + authorize_resource :class => false + def move_dining @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index cc6281ce..fa067976 100644 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -1,4 +1,6 @@ class Origami::MovetableController < BaseOrigamiController + + authorize_resource :class => false def move_dining @tables = Table.all.active.order('status desc') diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 38225fae..d415c965 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -1,6 +1,6 @@ class Origami::PaymentsController < BaseOrigamiController - + authorize_resource :class => false def index end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 1bce60e6..58419abe 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,5 +1,5 @@ class Origami::RequestBillsController < BaseOrigamiController - load_and_authorize_resource + # Print Request Bill and add to sale tables def print @sale = Sale.new diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index fa5af7e8..bdd3061a 100644 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -1,4 +1,5 @@ class PrintSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_print_setting, only: [:show, :edit, :update, :destroy] # GET /print_settings diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/bksale_items_controller.rb similarity index 74% rename from app/controllers/reports/sale_item_controller.rb rename to app/controllers/reports/bksale_items_controller.rb index eb7d3b86..1f349320 100644 --- a/app/controllers/reports/sale_item_controller.rb +++ b/app/controllers/reports/bksale_items_controller.rb @@ -1,5 +1,5 @@ -class Reports::SaleItemController < BaseReportController - +class Reports::SaleItemsController < BaseReportController + authorize_resource :class => false def index from, to, report_type = get_date_range_from_params diff --git a/app/controllers/reports/daily_sales_controller.rb b/app/controllers/reports/daily_sales_controller.rb new file mode 100644 index 00000000..6d99551d --- /dev/null +++ b/app/controllers/reports/daily_sales_controller.rb @@ -0,0 +1,17 @@ +class Reports::DailySalesController < BaseReportController + # authorize_resource :class => false + def index + from, to ,report_type = get_date_range_from_params + @sale_data = Sale.daily_sales_list(from,to) + @tax = SaleTax.get_tax(from,to) + respond_to do |format| + format.html + format.xls + end + end + + def show + + end + +end \ No newline at end of file diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_salesbk_controller.rb similarity index 72% rename from app/controllers/reports/daily_sale_controller.rb rename to app/controllers/reports/daily_salesbk_controller.rb index ba453f55..1a878aaa 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_salesbk_controller.rb @@ -1,5 +1,5 @@ -class Reports::DailySaleController < BaseReportController - +class Reports::DailySalesController < BaseReportController + authorize_resource :class => false def index from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) diff --git a/app/controllers/reports/sale_items_controller.rb b/app/controllers/reports/sale_items_controller.rb new file mode 100644 index 00000000..81f7af01 --- /dev/null +++ b/app/controllers/reports/sale_items_controller.rb @@ -0,0 +1,19 @@ +class Reports::SaleItemsController < BaseReportController + # authorize_resource :class => false + def index + + from, to, report_type = get_date_range_from_params + + @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type) + + respond_to do |format| + format.html + format.xls + end + end + + def show + + end + +end \ No newline at end of file diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index 90e6a304..54f27480 100644 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -1,4 +1,5 @@ class Settings::AccountsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_account, only: [:show, :edit, :update, :destroy] # GET /settings/accounts diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index b397d68d..0808c0a7 100644 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -1,4 +1,5 @@ class Settings::CashierTerminalsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_cashier_terminal, only: [:show, :edit, :update, :destroy] # GET /settings/cashier_terminals diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index ad7311f2..f386aecd 100644 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -1,4 +1,5 @@ class Settings::MembershipActionsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy] # GET /settings/membership_actions diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb index cfd672d0..36bb0092 100644 --- a/app/controllers/settings/membership_settings_controller.rb +++ b/app/controllers/settings/membership_settings_controller.rb @@ -1,4 +1,5 @@ class Settings::MembershipSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_membership_setting, only: [:show, :edit, :update, :destroy] # GET /settings/membership_settings diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb index c2a521ae..8ca9cfb4 100644 --- a/app/controllers/settings/menu_categories_controller.rb +++ b/app/controllers/settings/menu_categories_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuCategoriesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_category, only: [:show, :edit, :update, :destroy] before_action :set_settings_menu, only: [:new] diff --git a/app/controllers/settings/menu_item_attributes_controller.rb b/app/controllers/settings/menu_item_attributes_controller.rb index 1433cf34..162325a2 100644 --- a/app/controllers/settings/menu_item_attributes_controller.rb +++ b/app/controllers/settings/menu_item_attributes_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemAttributesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_attribute, only: [:show, :edit, :update, :destroy] # GET /settings/menu_item_attributes diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index 2b1fcecf..fd651e5e 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemInstancesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy] before_action :set_settings_menu_item, only: [ :show, :edit, :new, :update] diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb index 4a3a44b7..41679796 100644 --- a/app/controllers/settings/menu_item_options_controller.rb +++ b/app/controllers/settings/menu_item_options_controller.rb @@ -1,4 +1,5 @@ class Settings::MenuItemOptionsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu_item_option, only: [:show, :edit, :update, :destroy] # GET /settings/menu_item_options diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index fa6ac158..1a5ada31 100644 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -1,4 +1,5 @@ class Settings::MenusController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_menu, only: [:show, :edit, :update, :destroy] # GET /settings/menus diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index 5a540ddb..9fe78de4 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -1,4 +1,5 @@ class Settings::OrderQueueStationsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy] # GET /settings/order_queue_stations diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb index f3ac595e..ecbbcced 100644 --- a/app/controllers/settings/payment_method_settings_controller.rb +++ b/app/controllers/settings/payment_method_settings_controller.rb @@ -1,4 +1,5 @@ class Settings::PaymentMethodSettingsController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_payment_method_setting, only: [:show, :edit, :update, :destroy] # GET /settings/payment_method_settings diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 1064055b..992f637a 100644 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -1,4 +1,5 @@ class Settings::TaxProfilesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_tax_profile, only: [:show, :edit, :update, :destroy] # GET /settings/tax_profiles diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 08a6f189..49505854 100644 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -1,4 +1,5 @@ class Settings::ZonesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_settings_zone, only: [:show, :edit, :update, :destroy] # GET /settings/zones diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 35cefe6f..8303780f 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -1,4 +1,5 @@ class Transactions::OrdersController < ApplicationController + load_and_authorize_resource except: [:create] def index filter = params[:filter] diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 0a069b1b..29b6cda2 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -1,4 +1,5 @@ class Transactions::SalesController < ApplicationController + load_and_authorize_resource except: [:create] before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] # GET /transactions/sales diff --git a/app/helpers/reports/daily_sales_helper.rb b/app/helpers/reports/daily_sales_helper.rb new file mode 100644 index 00000000..eb04c7b9 --- /dev/null +++ b/app/helpers/reports/daily_sales_helper.rb @@ -0,0 +1,2 @@ +module Reports::DailySalesHelper +end diff --git a/app/helpers/reports/dailysales_helper.rb b/app/helpers/reports/dailysales_helper.rb new file mode 100644 index 00000000..94e34c27 --- /dev/null +++ b/app/helpers/reports/dailysales_helper.rb @@ -0,0 +1,2 @@ +module Reports::DailysalesHelper +end diff --git a/app/helpers/reports/sale_items_helper.rb b/app/helpers/reports/sale_items_helper.rb new file mode 100644 index 00000000..63e884d7 --- /dev/null +++ b/app/helpers/reports/sale_items_helper.rb @@ -0,0 +1,2 @@ +module Reports::SaleItemsHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index f48220a8..f3e8da5c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -8,26 +8,62 @@ class Ability can :manage, :all + elsif user.role == "manager" + + can :manage, Menu + can :manage, MenuCategory + can :manage, MenuItemAttribute + can :manage, MenuItemInstance + can :manage, MenuItemOption + can :manage, SetMenuItem + can :manage, OrderQueueStation + can :manage, Zone + can :manage, CashierTerminal + can :manage, Employee + can :manage, MembershipSetting + can :manage, MembershipAction + can :manage, PaymentMethodSetting + can :manage, TaxProfile + can :manage, PrintSetting + can :manage, Account + + can :manage, Order + can :manage, Sale + + can :index, :dailysale + can :index, :saleitem + elsif user.role == "cashier" - can :read, Order - can :update, Order + can :read, Order + can :update, Order - can :read, Sale - can :update, Sale + can :read, Sale + can :update, Sale - can :add_customer, Customer - can :update_sale_by_customer, Customer + can :add_customer, Customer + can :update_sale_by_customer, Customer + + can :index, :discount + can :create, :discount + + can :show, :payment + can :create, :payment + can :reprint, :payment + + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom elsif user.role == "accountant" - can :read, Order - can :update, Order - can :completed_order_item, Order - - can :read, Sale - can :update, Sale - can :manual_complete_sale, Sale + can :index, :dailysale + can :index, :saleitem + can :index, :receiptno + can :show, :dailysale + can :show, :saleitem + can :show, :receiptno end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index c528003d..24211081 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -38,8 +38,8 @@ diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 2719a758..a56d1266 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -307,6 +307,13 @@ $(document).ready(function(){ window.location.href = '/origami/'+ sale_id + "/customers" }); + $('#re-print').click(function() { + var sale_id = $('#sale_id').val(); + window.location.href = '/origami/'+ sale_id + "/reprint" + + return false; + }); + // Discount for Payment $('#discount').click(function() { var sale = $('#sale_id').val(); diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/daily_sale/index.html.erb index a2403045..7c2a8c61 100644 --- a/app/views/reports/daily_sale/index.html.erb +++ b/app/views/reports/daily_sale/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sale_index_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %>
diff --git a/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb b/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..3a5d788c --- /dev/null +++ b/app/views/reports/daily_sales/_shift_sale_report_filter.html.erb @@ -0,0 +1,151 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ + +
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/reports/daily_sales/index.html.erb b/app/views/reports/daily_sales/index.html.erb new file mode 100644 index 00000000..7c2a8c61 --- /dev/null +++ b/app/views/reports/daily_sales/index.html.erb @@ -0,0 +1,190 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + + <% unless @sale_data.empty? %> + + + <% void = 0 %> + <% mpu = 0 %> + <% master = 0 %> + <% visa = 0 %> + <% jcb = 0 %> + <% paypar = 0 %> + <% cash = 0 %> + <% credit = 0 %> + <% foc = 0 %> + <% discount = 0 %> + <% total = 0 %> + <% grand_total = 0 %> + <% count = 1 %> <% rounding_adj = 0 %> + <% @sale_data.each do |sale| %> + <% void += sale[:void_amount] %> + <% mpu += sale[:mpu_amount] %> + <% master += sale[:master_amount] %> + <% visa += sale[:visa_amount] %> + <% jcb += sale[:jcb_amount] %> + <% paypar += sale[:paypar_amount] %> + <% cash += sale[:cash_amount] %> + <% credit += sale[:credit_amount] %> + <% foc += sale[:foc_amount] %> + <% discount += sale[:total_discount] %> + <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> + <% grand_total += sale[:grand_total].to_f %> + <% rounding_adj += sale[:rounding_adj].to_f %> + + + + + + + + + + + + + + + + + + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateVoid AmountMpu SalesMaster SalesVisa SalesJcb SalesPaypar SalesCash SalesCredit SalesFOC Sales(Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
+
+ + + \ No newline at end of file diff --git a/app/views/reports/daily_sales/index.xls.erb b/app/views/reports/daily_sales/index.xls.erb new file mode 100644 index 00000000..67e76e3c --- /dev/null +++ b/app/views/reports/daily_sales/index.xls.erb @@ -0,0 +1,116 @@ +
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + + <% unless @sale_data.empty? %> + + + <% void = 0 %> + <% mpu = 0 %> + <% master = 0 %> + <% visa = 0 %> + <% jcb = 0 %> + <% paypar = 0 %> + <% cash = 0 %> + <% credit = 0 %> + <% foc = 0 %> + <% discount = 0 %> + <% total = 0 %> + <% grand_total = 0 %> + <% count = 1 %> <% rounding_adj = 0 %> + <% @sale_data.each do |sale| %> + <% void += sale[:void_amount] %> + <% mpu += sale[:mpu_amount] %> + <% master += sale[:master_amount] %> + <% visa += sale[:visa_amount] %> + <% jcb += sale[:jcb_amount] %> + <% paypar += sale[:paypar_amount] %> + <% cash += sale[:cash_amount] %> + <% credit += sale[:credit_amount] %> + <% foc += sale[:foc_amount] %> + <% discount += sale[:total_discount] %> + <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> + <% grand_total += sale[:grand_total].to_f %> + <% rounding_adj += sale[:rounding_adj].to_f %> + + + + + + + + + + + + + + + + + + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateVoid AmountMpu SalesMaster SalesVisa SalesJcb SalesPaypar SalesCash SalesCredit SalesFOC Sales(Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
\ No newline at end of file diff --git a/app/views/reports/sale_item/index.html.erb b/app/views/reports/sale_item/index.html.erb index cce5a210..a3b460fc 100644 --- a/app/views/reports/sale_item/index.html.erb +++ b/app/views/reports/sale_item/index.html.erb @@ -7,14 +7,14 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_item_index_path} %> + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %>
diff --git a/app/views/reports/sale_items/_shift_sale_report_filter.html.erb b/app/views/reports/sale_items/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..7f95b6b9 --- /dev/null +++ b/app/views/reports/sale_items/_shift_sale_report_filter.html.erb @@ -0,0 +1,156 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ + +
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/reports/sale_items/index.html.erb b/app/views/reports/sale_items/index.html.erb new file mode 100644 index 00000000..a3b460fc --- /dev/null +++ b/app/views/reports/sale_items/index.html.erb @@ -0,0 +1,141 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + +
Date
Menu CategoryCodeProductTotal ItemUnit PriceRevenue
+
+
+
+ + \ No newline at end of file diff --git a/app/views/reports/sale_items/index.xls.erb b/app/views/reports/sale_items/index.xls.erb new file mode 100644 index 00000000..2807ec3f --- /dev/null +++ b/app/views/reports/sale_items/index.xls.erb @@ -0,0 +1,136 @@ + + + + + + + +
+<% unless @sale_data.blank? %> + + + + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + + + <% acc_arr = Array.new %> + <% cate_arr = Array.new %> + + <% sub_total = 0.0 %> + <% count = 0%> + <% total_price = 0.0 %> + <% cate_count = 0 %> + <% acc_count = 0%> + <% grand_total = 0%> + <% total_discount = 0.0 %> + + <% @sale_data.order("total_item desc").each do |sale| %> + + <% if !acc_arr.include?(sale.account_id) %> + + + + + + + <% acc_arr.push(sale.account_id) %> + + <% end %> + + + <% if !cate_arr.include?(sale.menu_category_id) %> + + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + + <% end %> + + <% if @item_table == 'sale' %> + <% if sale.item_remark == 'FOC' %> + + <% elsif sale.item_remark == 'FOC ITEM' %> + + <% elsif sale.item_remark == 'DISCOUNT' %> + + <% else %> + + <% end %> + <% if sale.item_remark == 'DISCOUNT' %> + + + + <% total_price += sale.total_price %> + <% else %> + + + + <% end %> + <% else %> + + + + + <% end %> + + + + <% @menu_cate_count.each do |key,value| %> + <% if sale.menu_category_id == key %> + <% count = count + 1 %> + <% sub_total += sale.grand_total %> + <% if count == value %> + + + + + + <% sub_total = 0.0%> + <% total_discount = total_discount + total_price %> + <% total_price = 0.0%> + <% count = 0%> + <% end %> + <% end %> + <% end %> + + <% grand_total += sale.grand_total%> + <% end %> + + + + + + +
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
 Menu CategoryCodeProductTotal ItemUnit PriceRevenue
<%= sale.account_name %> Total Price By <%= sale.account_name %> + <% @totalByAccount.each do |account, total| %> + <% if sale.account_id == account %> + <%= total %> + <% end %> + <% end %> +
 <%= sale.menu_category_name %> <%= sale.code rescue '-' %><%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %><%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %><%= sale.product_name.to_s rescue '-' %> - - <%= sale.total_price.abs rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %><%= sale.product_name.to_s rescue '-' %><%= sale.total_item.abs rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total.abs rescue '-' %>
 Sub Total<%= sub_total + total_price %>
 Grand Total<%= grand_total + total_discount %>
+<% end %> +
+ + \ No newline at end of file diff --git a/app/views/settings/lookups/index.html.erb b/app/views/settings/lookups/index.html.erb index f427b561..9ac392a5 100644 --- a/app/views/settings/lookups/index.html.erb +++ b/app/views/settings/lookups/index.html.erb @@ -18,9 +18,9 @@ <%= settings_lookup.lookup_type %> <%= settings_lookup.name %> <%= settings_lookup.value %> - <%= link_to 'Show', settings_lookup %> + <%= link_to 'Show', settings_lookup_path(settings_lookup) %> <%= link_to 'Edit', edit_settings_lookup_path(settings_lookup) %> - <%= link_to 'Destroy', settings_lookup, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Destroy', settings_lookup_path(settings_lookup), method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 3b647fa9..cfaec2d0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,7 +88,7 @@ Rails.application.routes.draw do get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" - post "/:id/request_bills" => "request_bills#print" ,:defaults => { :format => 'json' } + post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' } get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' @@ -217,8 +217,8 @@ Rails.application.routes.draw do #--------- Reports Controller Sections ------------# namespace :reports do resources :receipt_no, :only => [:index, :show] - resources :daily_sale, :only => [:index, :show] - resources :sale_item, :only => [:index, :show] + resources :daily_sales, :only => [:index, :show] + resources :sale_items, :only => [:index, :show] # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show] diff --git a/spec/controllers/reports/daily_sales_controller_spec.rb b/spec/controllers/reports/daily_sales_controller_spec.rb new file mode 100644 index 00000000..6cc8e9fd --- /dev/null +++ b/spec/controllers/reports/daily_sales_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::DailySalesController, type: :controller do + +end diff --git a/spec/controllers/reports/dailysales_controller_spec.rb b/spec/controllers/reports/dailysales_controller_spec.rb new file mode 100644 index 00000000..83fcb321 --- /dev/null +++ b/spec/controllers/reports/dailysales_controller_spec.rb @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000..546fc874 --- /dev/null +++ b/spec/controllers/reports/sale_items_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Reports::SaleItemsController, type: :controller do + +end diff --git a/spec/helpers/reports/daily_sales_helper_spec.rb b/spec/helpers/reports/daily_sales_helper_spec.rb new file mode 100644 index 00000000..17d70035 --- /dev/null +++ b/spec/helpers/reports/daily_sales_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::DailySalesHelper. For example: +# +# describe Reports::DailySalesHelper 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 + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/reports/dailysales_helper_spec.rb b/spec/helpers/reports/dailysales_helper_spec.rb new file mode 100644 index 00000000..96853812 --- /dev/null +++ b/spec/helpers/reports/dailysales_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::DailysalesHelper. For example: +# +# describe Reports::DailysalesHelper 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 + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/reports/sale_items_helper_spec.rb b/spec/helpers/reports/sale_items_helper_spec.rb new file mode 100644 index 00000000..ea2807c4 --- /dev/null +++ b/spec/helpers/reports/sale_items_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Reports::SaleItemsHelper. For example: +# +# describe Reports::SaleItemsHelper 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 + pending "add some examples to (or delete) #{__FILE__}" +end From 6a6c629da4ad1822e1f8a9e4fa7ca909074482c1 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 23 Jun 2017 17:56:09 +0630 Subject: [PATCH 05/28] update cancan alert message --- app/views/layouts/application.html.erb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1d4991e6..d2b57a7a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,7 +18,16 @@ <%= render 'layouts/header' %>
<% flash.each do |type, message| %> -
+ <% + if type== "warning" + alert = "alert-warning" + elsif type== "notice" + alert = "alert-success" + else + alert = "alert-danger" + end + %> +
<%= message %>
From 05b4dbac7c70bb7987bf52589a4dce7546fcf61a Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 18:45:15 +0630 Subject: [PATCH 06/28] Rebate Redeem add field --- app/models/sale_payment.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 950334cb..65fc96b0 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -54,7 +54,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) - + return true, self.save else #record an payment in sale-audit @@ -94,10 +94,15 @@ class SalePayment < ApplicationRecord sale_data = Sale.find_by_sale_id(sale_id) if sale_data + others = 0 + sale_data.sale_payments.each do |sale_payment| + others = others + sale_payment.payment_amount + end + redeem_prices = sale_data.grand_total -others # Control for Paypar Cloud begin response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :body => { generic_customer_id:membership_id,total_amount: redeem_prices,total_sale_transaction_amount: sale_data.grand_total,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -292,7 +297,7 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', From ecabed5d5d05cc893238a59aaea2f1c8f90a807c Mon Sep 17 00:00:00 2001 From: Phyo Date: Fri, 23 Jun 2017 18:45:46 +0630 Subject: [PATCH 07/28] Account type change --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index fc3e1bde..dced96dd 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -73,8 +73,8 @@ booking_status = Lookup.create([{lookup_type:'booking_status', name: 'Available' {lookup_type:'booking_status', name: 'Moved', value: 'moved'}]) #booking_status -account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: 'income'}, - {lookup_type:'account_type', name: 'Expense', value: 'expense'}]) +account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: '0'}, + {lookup_type:'account_type', name: 'Expense', value: '1'}]) # sale void reason void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manager', value: 'Approve By Manager'}, From e9fb90d8a09443f87268f20d274d5133cc897027 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Jun 2017 19:00:49 +0630 Subject: [PATCH 08/28] updating oqs --- app/assets/javascripts/OQS.js | 4 ++++ app/assets/stylesheets/OQS.scss | 6 ++++++ app/views/oqs/home/index.html.erb | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 4c8300e2..0574148b 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -67,6 +67,10 @@ $(document).ready(function(){ $(this).addClass('selected-item'); }); + $(".order-item-edit").on('click', function(){ + + }); + // complete for queue item $('.order-complete').on('click',function(e){ //e.preventDefault(); diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss index b516836a..57c5a36d 100644 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -19,3 +19,9 @@ color: #fff !important; background-color: blue; } + +.order-item { + width: 49%; + font-size: 18px; + margin: 0px 0px 5px 0px; +} \ No newline at end of file diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 85858a02..ce82cbfa 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -116,8 +116,9 @@
- <% From 9ed6b510c45b127eeea5f57f0bfde471d7d389d9 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Jun 2017 19:01:33 +0630 Subject: [PATCH 09/28] updating oqs --- app/controllers/oqs/edit_controller.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/controllers/oqs/edit_controller.rb diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb new file mode 100644 index 00000000..e69de29b From d9c53e73f85be90df3fea3195c2bb7224f1b5e4d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 24 Jun 2017 11:12:30 +0630 Subject: [PATCH 10/28] update customer --- app/controllers/crm/customers_controller.rb | 2 +- app/controllers/origami/home_controller.rb | 1 + app/pdf/receipt_bill_pdf.rb | 4 ++-- app/views/origami/home/show.html.erb | 2 +- app/views/origami/orders/show.html.erb | 2 +- app/views/origami/rooms/show.html.erb | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index ca1aafb2..43b0618e 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -168,7 +168,7 @@ end 'Content-Type' => 'application/json', 'Accept' => 'application/json' }, - :timeout 10 + :timeout => 10 ) rescue Net::OpenTimeout response = { status: false } diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 4a070788..c4edcc0b 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -30,6 +30,7 @@ class Origami::HomeController < BaseOrigamiController order.order_items.each do |item| @order_items.push(item) end + end end @status_order = 'order' else diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 96e16cf4..5a86ddfb 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -93,10 +93,10 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left + text "Time In: #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right + text "Time Out: #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right end move_down 5 diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73f298ec..06263bed 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -292,7 +292,7 @@ <% end %> - + <% end %>
diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 92ffc7f1..d2c065a1 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -189,7 +189,7 @@ <% if @sale_status != 'completed' %> <% end %> - + -class CreateDiningQueues < ActiveRecord::Migration[5.1] - def change - create_table :dining_queues do |t| - t.string :name - t.string :contact_no - t.string :queue_no - t.string :status - t.references :dining_facility, foreign_key: true - t.timestamps - end - end -end From 6e49f91b89ccb2e3885d27bf484280baeb6e88d3 Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 26 Jun 2017 11:10:49 +0630 Subject: [PATCH 14/28] Multiple Invoices Phase 1 --- .../origami/room_invoices_controller.rb | 40 +++++ .../origami/table_invoices_controller.rb | 40 +++++ app/views/origami/home/show.html.erb | 20 ++- .../origami/room_invoices/index.html.erb | 82 ++++++++++ app/views/origami/room_invoices/show.html.erb | 147 ++++++++++++++++++ .../origami/table_invoices/index.html.erb | 82 ++++++++++ .../origami/table_invoices/show.html.erb | 147 ++++++++++++++++++ config/routes.rb | 6 + 8 files changed, 557 insertions(+), 7 deletions(-) create mode 100644 app/controllers/origami/room_invoices_controller.rb create mode 100644 app/controllers/origami/table_invoices_controller.rb create mode 100644 app/views/origami/room_invoices/index.html.erb create mode 100644 app/views/origami/room_invoices/show.html.erb create mode 100644 app/views/origami/table_invoices/index.html.erb create mode 100644 app/views/origami/table_invoices/show.html.erb diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb new file mode 100644 index 00000000..8d805771 --- /dev/null +++ b/app/controllers/origami/room_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::RoomInvoicesController < BaseOrigamiController + def index + @room = DiningFacility.find(params[:room_id]) + puts "room bookig lenght" + @sale_array = Array.new + @room.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @room = DiningFacility.find(params[:room_id]) + @sale_array = Array.new + @room.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb new file mode 100644 index 00000000..32e0ef7f --- /dev/null +++ b/app/controllers/origami/table_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::TableInvoicesController < BaseOrigamiController + def index + @table = DiningFacility.find(params[:table_id]) + puts "table bookig lenght" + @sale_array = Array.new + @table.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @table = DiningFacility.find(params[:table_id]) + @sale_array = Array.new + @table.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 73f298ec..c25c1b2f 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -126,7 +126,7 @@

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

- +
@@ -241,18 +241,18 @@ %> - <% - end - @sale_array.each do |sale| + <% end %> +

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

- Pending Payment + - +
Receipt No - <%= sale.receipt_no %>
<% @@ -298,6 +298,11 @@
diff --git a/app/views/origami/room_invoices/index.html.erb b/app/views/origami/room_invoices/index.html.erb new file mode 100644 index 00000000..011aff11 --- /dev/null +++ b/app/views/origami/room_invoices/index.html.erb @@ -0,0 +1,82 @@ +
+
+ <% @sale_array.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+ + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

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

+
+
+
+
+

Customer :

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

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

+
+
+

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

+
+
+
+
+ + +

Customer : <%= @customer.name %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb new file mode 100644 index 00000000..d5cbe84d --- /dev/null +++ b/app/views/origami/table_invoices/index.html.erb @@ -0,0 +1,82 @@ +
+
+ <% @sale_array.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+ + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

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

+
+
+

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

+
+
+
+
+

Customer :

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

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

+
+
+

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

+
+
+
+
+ + +

Customer : <%= @customer.name %>

+ +
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/config/routes.rb b/config/routes.rb index c93beb92..6466b664 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,6 +109,12 @@ Rails.application.routes.draw do get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index" get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index" + #---------Multiple Invoices --------------# + get 'table/:table_id/table_invoices' => "table_invoices#index" , :as => "table_invoice_index" + get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show" , :as => "table_invoice_show" + get 'room/:room_id/room_invoices' => "room_invoices#index" , :as => "room_invoice_index" + get 'room/:room_id/room_invoice/:invoice_id' => "room_invoices#show" , :as => "room_invoice_show" + #---------Add Customer --------------# #resources :customers get '/:sale_id/customers', to: "customers#add_customer" From a05fc0f6460a564b4dc179bed817b1058ba2c5dc Mon Sep 17 00:00:00 2001 From: Phyo Date: Mon, 26 Jun 2017 12:55:44 +0630 Subject: [PATCH 15/28] Up to Amount bug fix --- app/views/origami/redeem_payments/index.html.erb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index cbe356b5..a4783010 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -5,7 +5,7 @@
- +

@@ -21,7 +21,7 @@ <% end %>
- +

@@ -98,6 +98,12 @@
diff --git a/app/views/origami/sale_edit/item_void_cancel.json.jbuilder b/app/views/origami/sale_edit/item_void_cancel.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/sale_edit/item_void_cancel.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/config/routes.rb b/config/routes.rb index bf5d6483..c295f6be 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,6 +78,10 @@ Rails.application.routes.draw do post 'moving' => "movetable#moving" get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit" post 'item_void' => "sale_edit#item_void" + post 'item_void_cancel' => "sale_edit#item_void_cancel" + post 'cancel_all_void' => 'sale_edit#cancel_all_void' + post 'apply_void' => 'sale_edit#apply_void' + get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'sale/:sale_id' => 'sales#show' From d3dc2e2dd8a69130ddcba0e9cd20b3c8e715dca9 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 26 Jun 2017 16:39:55 +0630 Subject: [PATCH 24/28] remove pg in gem --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 227cfa72..8f16e924 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' +#gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' From 6e77a71946e0cd2d75c867afcd56a3f7ac590173 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 26 Jun 2017 16:50:04 +0630 Subject: [PATCH 25/28] update customer seed shop and receipt bill --- app/controllers/crm/customers_controller.rb | 3 +- .../origami/customers_controller.rb | 4 + app/pdf/receipt_bill_pdf.rb | 82 +++++++-------- app/views/crm/customers/show.html.erb | 99 +++++++------------ app/views/layouts/_header.html.erb | 3 + db/seeds.rb | 3 +- 6 files changed, 81 insertions(+), 113 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 4984150a..213a6229 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -47,7 +47,8 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) + # @response = "" #end customer amount end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index f15b8545..0859694d 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -54,6 +54,10 @@ class Origami::CustomersController < BaseOrigamiController if(id == "SAL") sale = Sale.find(params[:sale_id]) status = sale.update_attributes(customer_id: params[:customer_id]) + sale.sale_orders.each do |sale_order| + order = Order.find(sale_order.order_id) + status = order.update_attributes(customer_id: params[:customer_id]) + end else @booking = BookingOrder.find_by_order_id(params[:sale_id]) @orders = BookingOrder.where("booking_id = ? ", @booking.booking_id) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 5a86ddfb..4689de9d 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -30,7 +30,6 @@ class ReceiptBillPdf < Prawn::Document cashier_info(sale_data, customer_name) line_items(sale_items) - items_account(item_price_by_accounts) all_total(sale_data) @@ -39,6 +38,8 @@ class ReceiptBillPdf < Prawn::Document end customer(customer_name) + + items_account(item_price_by_accounts) footer end @@ -61,19 +62,10 @@ class ReceiptBillPdf < Prawn::Document text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right end move_down 5 - # y_position = cursor - # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - # text "Customer:", :size => self.item_font_size,:align => :left - # end - # bounding_box([self.label_width,y_position], :width =>self.item_width) do - # text "#{customer_name}" , :size => self.item_font_size,:align => :left - # end - # move_down 5 - y_position = cursor bounding_box([0, y_position], :width =>self.item_width) do text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left @@ -86,27 +78,26 @@ class ReceiptBillPdf < Prawn::Document end move_down 5 - # bounding_box([self.label_width,y_position], :width =>self.item_width) do - # text "#{customer_name}" , :size => self.item_font_size,:align => :left - # end - # move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "Time In: #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left - end - bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "Time Out: #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right + bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do + text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left end + + # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , + # :size => self.item_font_size,:align => :right + # end + move_down 5 stroke_horizontal_rule - move_down 5 end def line_items(sale_items) + move_down 5 y_position = cursor - + move_down 5 pad_top(15) { # @item_width.to_i + @half_qty.to_i text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix @@ -114,10 +105,8 @@ class ReceiptBillPdf < Prawn::Document text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } - - move_down 5 + move_down -5 stroke_horizontal_rule - add_line_item_row(sale_items) end @@ -142,7 +131,7 @@ class ReceiptBillPdf < Prawn::Document text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } - move_down 3 + move_down 1 end stroke_horizontal_rule @@ -158,20 +147,6 @@ class ReceiptBillPdf < Prawn::Document move_down 5 end - def items_account(item_price_by_accounts) - y_position = cursor - item_price_by_accounts.each do |ipa| - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right - end - move_down 5 - end - end - def all_total(sale_data) item_name_width = self.item_width y_position = cursor @@ -267,7 +242,7 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Rebate Amount", :size => self.item_font_size,:align => :left + text "Current Rebate Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right @@ -278,10 +253,10 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Redeem Amount", :size => self.item_font_size,:align => :left + text "Current Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right + text "(#{ res["redeem"] })" , :size => self.item_font_size,:align => :right end end @@ -317,7 +292,23 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ customer_name }" , :size => self.item_font_size,:align => :right - end + end + end + + def items_account(item_price_by_accounts) + move_down 5 + stroke_horizontal_rule + move_down 5 + y_position = cursor + item_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right + end + end end def footer @@ -331,3 +322,4 @@ class ReceiptBillPdf < Prawn::Document end end + diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index c6ec25c2..5c4bf7c8 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -55,7 +55,9 @@
- <% if @response["status"] == true && $response["data"] != "[]"%> + <% puts "'''''''''''''''''''" + puts @response + if @response["status"] == true %> <% if @response["status"] == true %> @@ -101,28 +103,22 @@
Membership Transactions
- - - - - - - - + + + + + - <% @order_items.each do |order_item| %> + <% @orders.each do |order| %> - - - - - - - - + + + + + <% end %> @@ -137,62 +133,33 @@
Order IDMenu ItemQTYUnit Price OptionStatusWaiterCreated at Order ID TypeOrder statusOrder dateItems Count
<%= order_item.order_id %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y") %><%= order.order_id %><%= order.order_type %><%= order.status %><%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %>
- - - - - - + + + + + + + - <% @sale_items.each do |sale_item| %> - - - - - - - - - - <% end %> + <% @sales.each do |sale| %> + + + + + + + + + + <% end %>
Sale ID Menu ItemQTYUnit Price Tax PriceCreated AtSale Id Receipt no Grand totalTax amountCashierSales statusReceipt Date
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
<%= sale.sale_id %><%= sale.receipt_no %><%= sale.grand_total rescue '-' %><%= sale.total_tax %><%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %>
-
-

Sale Details

-
- - - - - - - - - - - - - - <% @sale_items.each do |sale_item| %> - - - - - - - - - - <% end %> - -
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
-
-
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index c528003d..3d723782 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -49,10 +49,13 @@ <% if current_login_employee %>
<% end %> diff --git a/db/seeds.rb b/db/seeds.rb index fc3e1bde..e02ba1d5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -131,7 +131,8 @@ menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size" menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) menu_item_attribute_size_large = MenuItemAttribute.create({attribute_type:"size", name: "Large", value: "large"}) - +shop = Shop.create({id:1, name: "Beauty In the Pot", address:'No.3, 23 street', township:"Yankin",state:"Yangon",city:"Yangon", country:"Myanmar", phone_no:"09 99988888, 0912374734",reservation_no:"111",license:"123", +activated_at:"2017-06-26 08:36:24",license_data:"test",base_currency:"111",id_prefix:"111"}) #Default Order Queue stations # order_queue_station1 = OrderQueueStation.create({station_name: "Queue Station 1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"}) # order_queue_station2 = OrderQueueStation.create({station_name: "Queue Station 2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"}) From c81663003f78f8622f83b37d2459caf40584aebf Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 26 Jun 2017 17:01:25 +0630 Subject: [PATCH 26/28] update in discount --- app/views/origami/discounts/index.html.erb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 5f6b1396..e3cca128 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -249,19 +249,24 @@ $(document).ready(function(){ // Select for account types $(".accounts-type").on('click', function(e){ + var account_id = $(this).attr('id').substr(8); + if($(this).hasClass('selected-account') == true){ $(this).removeClass('selected-account'); + $(".item-row").each(function(i){ + if($(this).children().find("#item-account-type").text() == account_id){ + $(this).removeClass("selected-item"); + } + }); } else { $(this).addClass('selected-account'); - } - - var account_id = $(this).attr('id').substr(8); - $(".item-row").each(function(i){ - if($(this).children().find("#item-account-type").text() == account_id){ - $(this).addClass("selected-item"); - } - }); + $(".item-row").each(function(i){ + if($(this).children().find("#item-account-type").text() == account_id){ + $(this).addClass("selected-item"); + } + }); + } }); // Calculate Net Discount for Payment From d4983fabf59c037be91fc58da5d8fdfb77ff55bd Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 26 Jun 2017 17:07:17 +0630 Subject: [PATCH 27/28] item void --- .../origami/sale_edit_controller.rb | 4 +- app/models/sale.rb | 51 ++++++++++++++----- .../sale_edit/apply_void.json.jbuilder | 1 + 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 app/views/origami/sale_edit/apply_void.json.jbuilder diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 575cc008..70a5a380 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -51,6 +51,8 @@ class Origami::SaleEditController < BaseOrigamiController end def apply_void - + sale_id = params[:sale_id] + saleObj = Sale.find(sale_id) + saleObj.compute_without_void end end diff --git a/app/models/sale.rb b/app/models/sale.rb index f79d8642..791e9369 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -21,9 +21,9 @@ class Sale < ApplicationRecord "daily" => 0, "monthly" => 1, "yearly" => 2 - } + } - SALE_STATUS_COMPLETED = "completed" + SALE_STATUS_COMPLETED = "completed" def generate_invoice_from_booking(booking_id, requested_by) booking = Booking.find(booking_id) @@ -199,6 +199,31 @@ class Sale < ApplicationRecord end + def compute_without_void + sales_items = self.sale_items + + #Computation Fields + subtotal_price = 0 + total_taxable = 0 + rounding_adjustment = 0 + + sales_items.each do |item| + if item.remark != 'void' + #compute each item and added to total + subtotal_price = subtotal_price + item.price + total_taxable = total_taxable + item.taxable_price + end + end + + apply_tax (total_taxable) + self.total_amount = subtotal_price + self.total_discount = total_discount + self.grand_total = (self.total_amount - self.total_discount) + self.total_tax + #compute rounding adjustment + adjust_rounding + + self.save! + end # Tax Calculate def apply_tax(total_taxable) #if tax is not apply create new record @@ -354,28 +379,28 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) mc.name as menu_category_name, mc.id as menu_category_id ") .group('mi.id') - .order("mi.menu_category_id") - - query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id - JOIN menu_items mi ON i.product_code = mi.item_code" + - " JOIN menu_categories mc ON mc.id = mi.menu_category_id + .order("mi.menu_category_id") + + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id + JOIN menu_items mi ON i.product_code = mi.item_code" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id JOIN employees ea ON ea.id = sales.cashier_id") - + query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) - + case report_type.to_i when REPORT_TYPE["daily"] return query when REPORT_TYPE["monthly"] - - return query.group("MONTH(date)") + + return query.group("MONTH(date)") when REPORT_TYPE["yearly"] - return query.group("YEAR(date)") + return query.group("YEAR(date)") end - + end private diff --git a/app/views/origami/sale_edit/apply_void.json.jbuilder b/app/views/origami/sale_edit/apply_void.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/sale_edit/apply_void.json.jbuilder @@ -0,0 +1 @@ +json.status true From 089848ed4a217c026802c8700d39d4e2640bd92b Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 26 Jun 2017 17:49:55 +0630 Subject: [PATCH 28/28] credit note payment --- Gemfile | 2 +- .../origami/credit_payments_controller.rb | 22 +++ .../origami/payments_controller.rb | 3 + app/models/sale_payment.rb | 13 +- .../credit_payments/create.json.jbuilder | 1 + .../origami/credit_payments/index.html.erb | 167 +++++++++++++++++- app/views/origami/payments/show.html.erb | 2 +- config/routes.rb | 3 +- 8 files changed, 200 insertions(+), 13 deletions(-) create mode 100644 app/views/origami/credit_payments/create.json.jbuilder diff --git a/Gemfile b/Gemfile index 8f16e924..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -#gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index a348951e..ff9ae413 100644 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -2,9 +2,31 @@ class Origami::CreditPaymentsController < BaseOrigamiController def index + @sale_id = params[:sale_id] + + # limit visa_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @creditcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "visa" + @creditcount = @creditcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_credit = total - @creditcount - others end def create + cash = params[:amount] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote") + end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 310dfbc5..e3705294 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -39,6 +39,7 @@ class Origami::PaymentsController < BaseOrigamiController @visacount= 0.0 @jcbcount= 0.0 @mastercount = 0.0 + @credit = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount @@ -75,6 +76,8 @@ class Origami::PaymentsController < BaseOrigamiController @jcbcount += spay.payment_amount elsif spay.payment_method == "master" @mastercount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount end end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 65fc96b0..e4ad5364 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -9,7 +9,6 @@ class SalePayment < ApplicationRecord attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status def process_payment(invoice, action_by, cash_amount, payment_method) - self.sale = invoice self.received_amount = cash_amount amount_due = invoice.grand_total @@ -28,7 +27,7 @@ class SalePayment < ApplicationRecord when "cash" payment_status = cash_payment when "creditnote" - if !self.customer_id.nil? + if !self.sale.customer_id.nil? payment_status = creditnote_payment(self.customer_id) end when "visa" @@ -142,7 +141,7 @@ class SalePayment < ApplicationRecord self.payment_method = "creditnote" self.payment_amount = self.received_amount self.customer_id = self.customer_id - self.outstanding_amount = 0 - self.received_amount + self.outstanding_amount = 0 - self.received_amount.to_f self.payment_status = "outstanding" payment_method = self.save! @@ -207,10 +206,7 @@ class SalePayment < ApplicationRecord customer_data = Customer.find_by_customer_id(self.sale.customer_id) membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) - puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm' - puts membership_data.to_json - puts "amountttttttttttttttttttttt" - puts self.received_amount + if membership_data["status"]==true self.payment_method = "paypar" self.payment_amount = self.received_amount @@ -271,8 +267,7 @@ class SalePayment < ApplicationRecord def rebat(sObj) rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) - puts "eeeeeeeeeeeeeeeeeeeeeeee" - puts rebate_prices + generic_customer_id = sObj.customer.membership_id if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments diff --git a/app/views/origami/credit_payments/create.json.jbuilder b/app/views/origami/credit_payments/create.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/credit_payments/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/credit_payments/index.html.erb b/app/views/origami/credit_payments/index.html.erb index e4f97119..dc2b5b85 100644 --- a/app/views/origami/credit_payments/index.html.erb +++ b/app/views/origami/credit_payments/index.html.erb @@ -1 +1,166 @@ -hello Credit + +
+ +
+
+
+

CREDIT PAYMENT

+
+
+
+
+
+
+ + +
+
+
+ <% if @creditcount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+
+ +
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+ +
+ +
+
+ + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 08f833a2..cef27145 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -105,7 +105,7 @@
Credit
-
0.0
+
<%= @credit %>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
diff --git a/config/routes.rb b/config/routes.rb index fea13a34..39b9aca5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -81,7 +81,7 @@ Rails.application.routes.draw do post 'item_void_cancel' => "sale_edit#item_void_cancel" post 'cancel_all_void' => 'sale_edit#cancel_all_void' post 'apply_void' => 'sale_edit#apply_void' - + get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'sale/:sale_id' => 'sales#show' @@ -105,6 +105,7 @@ Rails.application.routes.draw do post 'payment/master' => "master#create" post 'payment/visa' => "visa#create" post 'payment/paypar' => 'paypar_payments#create' + post 'payment/credit' => 'credit_payments#create' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index"