From c589f11758779cd6f3ce54829d5f510840179a0c Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 1 Jul 2017 09:46:14 +0630 Subject: [PATCH 01/21] shift sale --- app/controllers/origami/shifts_controller.rb | 6 +++--- app/models/sale.rb | 11 ++++++----- app/models/sale_payment.rb | 4 +++- app/models/shift_sale.rb | 4 ++-- app/views/origami/shifts/new.html.erb | 19 ++++++++++++++----- db/migrate/20170403160742_create_sales.rb | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 3329aa0b..35af84b6 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,7 +4,6 @@ class Origami::ShiftsController < BaseOrigamiController end def show - puts current_user.id @shift = ShiftSale.current_open_shift(current_user.id) end @@ -15,8 +14,9 @@ class Origami::ShiftsController < BaseOrigamiController def create opening_balance = params[:opening_balance] + cashier_terminal = params[:cashier_terminal] @shift = ShiftSale.new - @shift.create(opening_balance,current_user) + @shift.create(opening_balance,cashier_terminal, current_user) end def update_shift @@ -30,7 +30,7 @@ class Origami::ShiftsController < BaseOrigamiController end end - def edit end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 693f6874..1df94034 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -345,8 +345,8 @@ class Sale < ApplicationRecord else ## up to 100 value = 100 - get_last_no.to_f - num += value - puts 'up to 100' + num += value + puts 'up to 100' end end end @@ -479,11 +479,12 @@ end def get_commerical_tax tax = 0.0 - self.sale_taxes.each do |tax| - if tax.tax_name == "Commerical Tax" - tax += tax.tax_payable_amount + self.sale_taxes.each do |taxobj| + if taxobj.tax_name == "Commerical Tax" + tax += taxobj.tax_payable_amount end end + return tax end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index c78b6cd8..741abfc2 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -266,6 +266,8 @@ class SalePayment < ApplicationRecord shift = ShiftSale.current_open_shift(self.sale.cashier_id) if !shift.nil? shift.update(self.sale) + self.sale.shift_sale_id = shift.id + self.sale.save end end @@ -324,7 +326,7 @@ class SalePayment < ApplicationRecord }, :timeout => 10) rescue Net::OpenTimeout response = { status: false } - + rescue OpenURI::HTTPError response = { status: false} diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index a897de2b..ae4c93a8 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -27,8 +27,8 @@ class ShiftSale < ApplicationRecord #end end - def create(opening_balance,current_user) - self.cashier_terminal_id = CashierTerminal.first.id + def create(opening_balance,cashier_terminal, current_user) + self.cashier_terminal_id = cashier_terminal self.shift_started_at = DateTime.now self.employee_id = current_user.id self.opening_balance = opening_balance diff --git a/app/views/origami/shifts/new.html.erb b/app/views/origami/shifts/new.html.erb index 2903a8ae..f5f032bc 100644 --- a/app/views/origami/shifts/new.html.erb +++ b/app/views/origami/shifts/new.html.erb @@ -1,12 +1,19 @@

Open Cashier


-
-
-
-
+
+ + + + <% @float.each do |float| %> @@ -69,10 +76,12 @@ $(document).on('focusout', '.float-value', function(event){ }) $('#open_cashier').on('click',function(){ + var cashier_terminal = $('#cashier_terminal').val(); + alert(cashier_terminal) var amount = $('#total').text(); $.ajax({type: "POST", url: "<%= origami_shifts_path %>", - data: "opening_balance=" + amount, + data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal, success:function(result){ if(result){ window.location.href = '/origami'; diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170403160742_create_sales.rb index ae806472..9deeb9b8 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170403160742_create_sales.rb @@ -20,7 +20,7 @@ class CreateSales < ActiveRecord::Migration[5.1] t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00 - t.integer :shift_sale_id, :null => false + t.integer :shift_sale_id t.timestamps end end From 40a2347c1ba69a3539013265235a069f8828958c Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 1 Jul 2017 11:10:08 +0630 Subject: [PATCH 02/21] update report --- app/controllers/base_report_controller.rb | 9 +- app/controllers/crm/customers_controller.rb | 4 +- .../transactions/orders_controller.rb | 1 + .../_shift_sale_report_filter.html.erb | 86 +++++++++++++------ 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 28ba5c2b..12eeccd2 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -34,7 +34,7 @@ class BaseReportController < ActionController::Base to = params[:to] day_ref = Time.now.utc.getlocal - if params[:report_type] == "daily_sale" + if params[:report_type] == "daily_sale" || params[:report_type] == "sale_item" if from != "" && to != "" @@ -86,9 +86,7 @@ class BaseReportController < ActionController::Base else # end daily sale report if period_type.to_i == 1 - if params[:from] && params[:to] - - if params[:from] != "" && params[:to] !="" + if params[:from] != "" && params[:to] !="" f_date = DateTime.parse(params[:from]) t_date = DateTime.parse(params[:to]) @@ -99,8 +97,7 @@ class BaseReportController < ActionController::Base else from = day_ref.beginning_of_day.utc to = day_ref.end_of_day.utc - end - end + end else case period.to_i when PERIOD["today"] diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index d31ee280..2f5b25d2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -125,9 +125,9 @@ class Crm::CustomersController < BaseCrmController else # @crm_customers.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. But '} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. But ' } + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end end else diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 8303780f..de4be3c3 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -20,6 +20,7 @@ class Transactions::OrdersController < ApplicationController format.json { render json: @orders } end end + def show @order = Order.find(params[:id]) diff --git a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb index 7f95b6b9..c57c8be9 100644 --- a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb +++ b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb @@ -116,24 +116,6 @@ <% end %> - - - \ No newline at end of file From abefd1f8f26d110c89f8d95ff2ec3147fead5c0d Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 1 Jul 2017 14:55:37 +0630 Subject: [PATCH 03/21] Update --- app/models/order_item.rb | 8 ++-- app/models/shift_sale.rb | 2 +- app/views/origami/shifts/new.html.erb | 66 ++++++++++++++++++++------- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/app/models/order_item.rb b/app/models/order_item.rb index f4f3efba..109665d0 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -43,10 +43,10 @@ class OrderItem < ApplicationRecord def self.get_order_items_details(booking_id) # booking_orders = BookingOrder.where("booking_id=?",booking.booking_id) # if booking_orders - # booking_orders.each do |book_order| + # booking_orders.each do |book_order| # order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") # .joins("left join orders on orders.order_id = order_items.order_id") - # .where("order_items.order_id=?",book_order.order) + # .where("order_items.order_id=?",book_order.order) # return order_details # end # else @@ -57,9 +57,9 @@ class OrderItem < ApplicationRecord .joins("left join orders on orders.order_id = order_items.order_id") .joins("left join booking_orders on booking_orders.order_id = order_items.order_id") .joins("left join bookings on bookings.booking_id = booking_orders.booking_id") - .where("bookings.booking_id=?",booking_id) + .where("bookings.booking_id=?",booking_id) - return order_details + return order_details end private diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index aa471972..f59c2797 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -21,7 +21,7 @@ class ShiftSale < ApplicationRecord #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take return shift #end diff --git a/app/views/origami/shifts/new.html.erb b/app/views/origami/shifts/new.html.erb index f5f032bc..83f4df55 100644 --- a/app/views/origami/shifts/new.html.erb +++ b/app/views/origami/shifts/new.html.erb @@ -17,7 +17,7 @@ <% @float.each do |float| %> - + <% end %> @@ -25,12 +25,7 @@
Cashier Terminal + +
<%= float.name %>
<%= float.name %>
-
-
-
- -
-
+
@@ -56,9 +51,9 @@
00
-
Del
-
Clr
-
Ent
+
Clr
+
Calculate
+
Open Cashier
@@ -67,17 +62,54 @@
diff --git a/app/views/origami/cash_outs/new.html.erb b/app/views/origami/cash_outs/new.html.erb index 17f9bdf8..9d628f24 100644 --- a/app/views/origami/cash_outs/new.html.erb +++ b/app/views/origami/cash_outs/new.html.erb @@ -1,6 +1,8 @@ -

Payment Debit

+ +
-
+
+

Payment Debit

Payment Reference @@ -20,13 +22,12 @@
+
+ + +
+
-
-

-
-
-
-
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 4004e9cf..860633a4 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -188,10 +188,10 @@
0.0
<% end %> -
+
-
Balance
-
<%= @sale_data.grand_total %>
+
Balance
+
<%= @sale_data.grand_total %>

From 99986b1fb9afdd0c7cda7cb938552e7a24aead5f Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 1 Jul 2017 15:30:06 +0630 Subject: [PATCH 05/21] open cashier clear --- app/views/origami/cash_ins/new.html.erb | 3 --- app/views/origami/shifts/new.html.erb | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/origami/cash_ins/new.html.erb b/app/views/origami/cash_ins/new.html.erb index 41330fc5..efc8a22b 100644 --- a/app/views/origami/cash_ins/new.html.erb +++ b/app/views/origami/cash_ins/new.html.erb @@ -24,7 +24,6 @@ - Reference Number @@ -36,8 +35,6 @@ - -
diff --git a/app/views/origami/shifts/new.html.erb b/app/views/origami/shifts/new.html.erb index 83f4df55..8d3ca457 100644 --- a/app/views/origami/shifts/new.html.erb +++ b/app/views/origami/shifts/new.html.erb @@ -82,7 +82,7 @@ $(document).on('focusout', '.float-value', function(event){ } break; case 'clr': - $('#cash').text("0"); + $('#'+float_value).val("0"); break; case 'ent': var sum = 0 From 5f3708e11d5249737826b0aa9d4c21546c5f97d8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 1 Jul 2017 17:15:12 +0630 Subject: [PATCH 06/21] menu updated | edit qty updated --- app/controllers/home_controller.rb | 8 +++++++- .../origami/sale_edit_controller.rb | 20 +++++++++++++++++++ app/views/origami/sale_edit/edit.html.erb | 17 +++++++++------- config/routes.rb | 3 ++- lib/tasks/menu_import.rake | 8 ++++---- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3136417f..f2a8676c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -77,7 +77,13 @@ class HomeController < ApplicationController def route_by_role(employee) if employee.role == "administrator" - redirect_to dashboard_path + # redirect_to dashboard_path + shift = ShiftSale.current_open_shift(employee.id) + if !shift.nil? + redirect_to origami_root_path + else + redirect_to new_origami_shift_path + end elsif employee.role == "cashier" #check if cashier has existing open cashier shift = ShiftSale.current_open_shift(employee.id) diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index d4fba302..f0d57679 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -23,6 +23,26 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.save end + def item_edit + saleitemId = params[:sale_item_id] + update_qty = params[:update_qty] + update_price = params[:update_price] + saleitemObj = SaleItem.find(saleitemId) + saleitemObj.remark = 'void' + saleitemObj.save + @newsaleitem = SaleItem.new + @newsaleitem = saleitemObj.dup + @newsaleitem.save + @newsaleitem.qty = update_qty + @newsaleitem.price = update_price + @newsaleitem.unit_price = update_price + @newsaleitem.taxable_price = update_price + @newsaleitem.is_taxable = 0 + @newsaleitem.remark = 'edit' + @newsaleitem.product_name = saleitemObj.product_name + " - updated" + @newsaleitem.save + end + # make cancel void item def item_void_cancel saleitemId = params[:sale_item_id] diff --git a/app/views/origami/sale_edit/edit.html.erb b/app/views/origami/sale_edit/edit.html.erb index 76bbeb08..13812e59 100644 --- a/app/views/origami/sale_edit/edit.html.erb +++ b/app/views/origami/sale_edit/edit.html.erb @@ -49,18 +49,18 @@ <%= count %> <%= sale_item.product_name %> - <% if sale_item.remark != 'void' %> - - + <% if sale_item.remark != 'void' && sale_item.remark != 'edit' %> + + - <% elsif sale_item.qty.to_i < 0 %> + <% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %> - + <% else %> @@ -101,11 +101,14 @@ $(document).ready(function(){ $(".update").on('click',function() { var sale_item_id = $(this).attr('data-id'); - var ajax_url = "/origami/item_void"; + var qty = $('#'+sale_item_id + "_qty").val(); + var price = $('#'+ sale_item_id + "_price").val(); + console.log(qty + "|" + price) + var ajax_url = "/origami/item_edit"; $.ajax({ type: "POST", url: ajax_url, - data: 'order_id='+ order_id, + data: 'sale_item_id='+ sale_item_id + "&update_qty="+qty + "&update_price="+ price, success:function(result){ location.reload(); } diff --git a/config/routes.rb b/config/routes.rb index 35669703..544f67f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -80,6 +80,7 @@ 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_edit' => "sale_edit#item_edit" 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' @@ -109,7 +110,7 @@ Rails.application.routes.draw do #---------Shift ---------------# resources :shifts, only: [:index, :new, :create, :edit] post 'close_shift' => 'shifts#update_shift' - get 'shift/close' => 'shifts#show' + get 'shift/close' => 'shifts#show' #shift - index (open/close shift landing page) #shift - show (sales summary display) #shift - new (open shift) diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index f229df94..9a287a2d 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -93,9 +93,9 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut # Pork menu_category4 = MenuCategory.create({menu: menu, code:"C004", name: "Pork", alt_name: "Pork", order_by: 4,created_by: "SYSTEM DEFAULT"}) # Sliced Tenderloin Pork - menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Tenderloin Pork", alt_name: "Twin Pot",menu_category: menu_category4 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0212", menu_item: menu_category1_menu_item13, price:4000.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0211", menu_item: menu_category1_menu_item13, price:8000.00, is_on_promotion:false}]) + menu_category1_menu_item137 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Tenderloin Pork", alt_name: "Twin Pot",menu_category: menu_category4 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0212", menu_item: menu_category1_menu_item137, price:4000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0211", menu_item: menu_category1_menu_item137, price:8000.00, is_on_promotion:false}]) # Sliced Pork Belly menu_category1_menu_item14 = SimpleMenuItem.create({item_code:"01015", name: "Sliced Pork Belly", alt_name: "Twin Pot",menu_category: menu_category4 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0222", menu_item: menu_category1_menu_item14, price:4000.00, is_on_promotion:false}]) @@ -475,7 +475,7 @@ menu_category14 = MenuCategory.create({menu: menu, code:"C0013", name: "Others", menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1142", menu_item: menu_category1_menu_item106, price:1500.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1141", menu_item: menu_category1_menu_item106, price:3000.00, is_on_promotion:false}]) # Sliced Kelp - menu_category1_menu_item107 = SimpleMenuItem.create({item_code:"01108", name: "Sliced Kelp", alt_name: "Twin Pot",menu_category: menu_category14 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item107 = SimpleMenuItem.create({item_code:"01108", name: "Shredded Kelp", alt_name: "Twin Pot",menu_category: menu_category14 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1152", menu_item: menu_category1_menu_item107, price:1800.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1151", menu_item: menu_category1_menu_item107, price:3600.00, is_on_promotion:false}]) # Crystal Vermicelli From b0ec03f5911925222e9087ae980ddfe144e949c8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 1 Jul 2017 18:12:48 +0630 Subject: [PATCH 07/21] Update --- lib/tasks/menu_import.rake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 9a287a2d..5db6231f 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -207,7 +207,7 @@ menu_category7 = MenuCategory.create({menu: menu, code:"C007", name: "Specialty # Seafood menu_category8 = MenuCategory.create({menu: menu, code:"C008", name: "Seafood", alt_name: "Seafood", order_by: 8,created_by: "SYSTEM DEFAULT"}) # Promfret - menu_category1_menu_item41 = SimpleMenuItem.create({item_code:"01042", name: "Promfret", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item41 = SimpleMenuItem.create({item_code:"01042", name: "Pomfret", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0492", menu_item: menu_category1_menu_item41, price:30.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0491", menu_item: menu_category1_menu_item41, price:30.00, is_on_promotion:false}]) # Garoupa @@ -280,13 +280,13 @@ menu_category8 = MenuCategory.create({menu: menu, code:"C008", name: "Seafood", menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0661", menu_item: menu_category1_menu_item59, price:10.00, is_on_promotion:false}]) # Fresh Flower Crabs menu_category1_menu_item60 = SimpleMenuItem.create({item_code:"01061", name: "Fresh Flower Crabs", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0671", menu_item: menu_category1_menu_item60, price:10.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0671", menu_item: menu_category1_menu_item60, price:60.00, is_on_promotion:false}]) # Live Lobster menu_category1_menu_item61 = SimpleMenuItem.create({item_code:"01062", name: "Live Lobster", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0681", menu_item: menu_category1_menu_item61, price:10.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0681", menu_item: menu_category1_menu_item61, price:150.00, is_on_promotion:false}]) # Live Mantis menu_category1_menu_item62 = SimpleMenuItem.create({item_code:"01063", name: "Live Mantis Prawn", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:" ",item_instance_code:"II0691", menu_item: menu_category1_menu_item62, price:10.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:" ",item_instance_code:"II0691", menu_item: menu_category1_menu_item62, price:150.00, is_on_promotion:false}]) # Dumpling menu_category9 = MenuCategory.create({menu: menu, code:"C009", name: "Dumpling", alt_name: "Chicken", order_by: 9, created_by: "SYSTEM DEFAULT"}) # Pork and Chives Dumpling From 740f585a315c47c76a18deb96542ec0ae12b6654 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 1 Jul 2017 18:19:41 +0630 Subject: [PATCH 08/21] update rounding adj --- .../origami/payments_controller.rb | 16 ++- app/models/ability.rb | 2 + app/models/printer/receipt_printer.rb | 10 ++ app/models/sale.rb | 4 +- app/pdf/close_cashier_pdf.rb | 109 ++++++++++++++++++ app/views/origami/home/show.html.erb | 11 +- app/views/origami/orders/show.html.erb | 11 +- app/views/origami/payments/show.html.erb | 8 +- .../origami/room_invoices/index.html.erb | 4 + app/views/origami/room_invoices/show.html.erb | 16 ++- app/views/origami/rooms/show.html.erb | 17 ++- app/views/origami/sales/show.html.erb | 4 + .../origami/table_invoices/index.html.erb | 4 + .../origami/table_invoices/show.html.erb | 21 +++- app/views/reports/dailysale/index.html.erb | 4 +- config/routes.rb | 1 + ...ales.rb => 20170701101420_create_sales.rb} | 3 +- 17 files changed, 230 insertions(+), 15 deletions(-) create mode 100644 app/pdf/close_cashier_pdf.rb rename db/migrate/{20170403160742_create_sales.rb => 20170701101420_create_sales.rb} (95%) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 2cdd44b5..80b7eb20 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -41,10 +41,10 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) - rounding_adj = saleObj.grand_total - new_total + # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + # rounding_adj = saleObj.grand_total - new_total - saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj) + # saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj) rebate_amount = nil @@ -144,4 +144,14 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end + + def rounding_adj + + saleObj = Sale.find(params[:sale_id]) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 9a7b5f6f..3e5fc8b6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -52,6 +52,7 @@ class Ability can :show, :payment can :create, :payment can :reprint, :payment + can :rounding_adj, :payment can :move_dining, :movetable can :moving, :movetable @@ -88,6 +89,7 @@ class Ability can :show, :payment can :create, :payment can :reprint, :payment + can :rounding_adj, :payment can :move_dining, :movetable can :moving, :movetable diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index f8eb46d6..373e05ae 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -80,6 +80,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end until count == 0 end + #Bill Receipt Print + def print_close_cashier(printer_settings,shift_sale,shop_details) + #Use CUPS service + #Generate PDF + #Print + pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details) + pdf.render_file "tmp/print_close_cashier.pdf" + self.print("tmp/print_close_cashier.pdf") + end + #Queue No Print def print_queue_no(printer_settings,queue) #Use CUPS service diff --git a/app/models/sale.rb b/app/models/sale.rb index 25a2d714..60b471dd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -92,7 +92,6 @@ class Sale < ApplicationRecord link_order_sale(order.id) end - self.save! #compute sales summary @@ -379,6 +378,7 @@ class Sale < ApplicationRecord to_date = sale_date.end_of_day.utc - diff total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, + IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total, IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount, IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj") @@ -386,6 +386,7 @@ class Sale < ApplicationRecord total_sale.each do |sale| grand_total = sale.grand_total + old_grand_total = sale.old_grand_total total_discount = sale.total_discount void_amount = sale.void_amount total = {:sale_date => pay.sale_date, @@ -399,6 +400,7 @@ class Sale < ApplicationRecord :foc_amount => pay.foc_amount, :total_discount => total_discount, :grand_total => grand_total, + :old_grand_total => old_grand_total, :void_amount => void_amount, :rounding_adj => sale.rounding_adj} daily_total.push(total) diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb new file mode 100644 index 00000000..3223c4b3 --- /dev/null +++ b/app/pdf/close_cashier_pdf.rb @@ -0,0 +1,109 @@ +class CloseCashierPdf < Prawn::Document + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(printer_settings, shift_sale,shop_details) + self.page_width = 210 + self.page_height = 7000 + self.margin = 5 + self.price_width = 40 + self.qty_width = 20 + self.total_width = 40 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.item_height = 15 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 + # @item_width = self.page_width.to_i / 2 + # @qty_width = @item_width.to_i / 3 + # @double = @qty_width * 1.3 + # @half_qty = @qty_width / 2 + #setting page margin and width + super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # font "public/fonts/#{font_name}".to_s + ".ttf".to_s + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + self.header_font_size = 10 + self.item_font_size = 8 + + + + header( shop_details) + + stroke_horizontal_rule + + cashier_info(shift_sale) + + footer + + + end + + def header (shop_details) + move_down 7 + text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center + move_down 5 + text "#{shop_details.address}", :size => self.item_font_size,:align => :center + # move_down self.item_height + move_down 5 + text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center + move_down 5 + + stroke_horizontal_rule + end + + def cashier_info(shift_sale) + move_down 7 + # move_down 2 + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Cashier: #{shift_sale.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 "#{ shift_sale.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 "Cashier Station Sta: #{shift_sale.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 "#{ shift_sale.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 "Opening Date", :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 "#{ shift_sale.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 "Closing Date: #{shift_sale.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 "#{ shift_sale.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right + end + + + move_down 5 + + end + + + + def footer + move_down 5 + stroke_horizontal_rule + move_down 5 + + text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center + + move_down 5 + end + +end + diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index f89560f3..a8670e12 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -447,7 +447,16 @@ $("#first_bill").on('click', function(){ $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; + + $.ajax({ + type: "POST", + url: '/origami/sale/'+ sale_id + "/rounding_adj", + success:function(result){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + }); + }); // Bill Request diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 3a34c1df..e0448009 100644 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -215,7 +215,16 @@ $(document).ready(function(){ }); $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; + alert(url) + $.ajax({ + type: "POST", + url: '/origami/sale/'+ sale_id + "/rounding_adj", + success:function(result){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + }); + }); $('#back').on('click',function(){ window.location.href = '/origami/'; diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 4004e9cf..a9a542b6 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -70,14 +70,20 @@ (Discount) (<%=@sale_data.total_discount rescue 0%>) + Tax <%=@sale_data.total_tax rescue 0%> + + Rounding Adj: + <%=@sale_data.rounding_adjustment rescue 0%> + + Grand Total <%=@sale_data.grand_total rescue 0%> <%if @balance > 0%> - + <%= @accountable_type %> <%=@balance%> diff --git a/app/views/origami/room_invoices/index.html.erb b/app/views/origami/room_invoices/index.html.erb index 011aff11..71b9bee7 100644 --- a/app/views/origami/room_invoices/index.html.erb +++ b/app/views/origami/room_invoices/index.html.erb @@ -46,6 +46,10 @@ Tax: <%= @sale.total_tax rescue 0%> + + + Rounding Adj: + <%= @sale.rounding_adjustment rescue 0%> Grand Total: diff --git a/app/views/origami/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb index 7ea799ae..4b507526 100644 --- a/app/views/origami/room_invoices/show.html.erb +++ b/app/views/origami/room_invoices/show.html.erb @@ -112,6 +112,10 @@ Tax: <%= @sale.total_tax rescue 0%> + + + Rounding Adj: + <%= @sale.rounding_adjustment rescue 0%> Grand Total: @@ -139,7 +143,17 @@ $(document).ready(function(){ }); $('#pay').on('click',function() { - window.location.href = '/origami/sale/<%= @sale.id %>/payment'; + var sale_id = '<%= @sale.id %>'; + var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; + alert(url) + $.ajax({ + type: "POST", + url: '/origami/sale/'+ sale_id + "/rounding_adj", + success:function(result){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + }); + }); $('#back').on('click',function(){ window.location.href = '/origami/table/<%= @room.id %>'; diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 36ae77c5..76c4da71 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -203,6 +203,10 @@ Tax: <%= @obj.total_tax rescue 0%> + + + Rounding Adj: + <%= @obj.rounding_adjustment rescue 0%> Grand Total: @@ -424,12 +428,19 @@ $("#first_bill").on('click', function(){ }); }); - $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; + alert(url) + $.ajax({ + type: "POST", + url: '/origami/sale/'+ sale_id + "/rounding_adj", + success:function(result){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + }); + }); - // Bill Request $('#request_bills').click(function() { var order_id = $('#save_order_id').attr('data-order'); diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index d768240c..86a82053 100644 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -171,6 +171,10 @@ Tax: <%= @sale.total_tax rescue 0%> + + Rounding Adj: + <%= @sale.rounding_adjustment rescue 0%> + Grand Total: <%= @sale.grand_total rescue 0%> diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb index d5cbe84d..95a6ee33 100644 --- a/app/views/origami/table_invoices/index.html.erb +++ b/app/views/origami/table_invoices/index.html.erb @@ -46,6 +46,10 @@ Tax: <%= @sale.total_tax rescue 0%> + + + Rounding Adj: + <%= @obj_sale.rounding_adjustment rescue 0%> Grand Total: diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index ade1f021..de43e654 100644 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -112,6 +112,10 @@ Tax: <%= @sale.total_tax rescue 0%> + + + Rounding Adj: + <%= @obj_sale.rounding_adjustment rescue 0%> Grand Total: @@ -139,8 +143,23 @@ $(document).ready(function(){ }) }); +// $('#pay').on('click',function() { +// window.location.href = '/origami/sale/<%= @sale.id %>/payment'; +// }); + $('#pay').on('click',function() { - window.location.href = '/origami/sale/<%= @sale.id %>/payment'; + var sale_id = '<%= @sale.id %>'; + + var url = '<%= @calculate_rouding_adj_path %>'; + + $.ajax({ + type: "GET", + url: url, + success:function(result){ + // location.reload(); + } + }); + window.location.href = '/origami/sale/'+ sale_id + "/payment"; }); $('#back').on('click',function(){ window.location.href = '/origami/table/<%= @table.id %>'; diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index 5c42d6dc..64565fb5 100644 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -74,7 +74,7 @@ <% credit += sale[:credit_amount] %> <% foc += sale[:foc_amount] %> <% discount += sale[:total_discount] %> - <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> + <% total += sale[:old_grand_total].to_f + sale[:rounding_adj].to_f %> <% grand_total += sale[:grand_total].to_f %> <% rounding_adj += sale[:rounding_adj].to_f %> @@ -90,7 +90,7 @@ <%= 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[:old_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 '-'%> diff --git a/config/routes.rb b/config/routes.rb index 35669703..a432c761 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -121,6 +121,7 @@ Rails.application.routes.draw do #payment - Outing payments - Cash only [ *Misc expeness tracking] #--------- Payment ------------# + post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj',:as => "calculate_rouding_adjs" get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' } get 'sale/:sale_id/payment' => 'payments#show' diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170701101420_create_sales.rb similarity index 95% rename from db/migrate/20170403160742_create_sales.rb rename to db/migrate/20170701101420_create_sales.rb index ae806472..fc261826 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170701101420_create_sales.rb @@ -20,7 +20,8 @@ class CreateSales < ActiveRecord::Migration[5.1] t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00 - t.integer :shift_sale_id, :null => false + t.integer :shift_sale_id + t.decimal :old_grand_total t.timestamps end end From 51a779cbeec3a8d55de22f2697d9d95d36c3c0a7 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 1 Jul 2017 19:11:04 +0630 Subject: [PATCH 09/21] add zone with oqs and tax calculte method update --- app/controllers/oqs/home_controller.rb | 65 +++++++++---------- .../origami/discounts_controller.rb | 14 ++-- app/models/sale.rb | 15 +++-- app/views/oqs/home/index.html.erb | 13 ++-- 4 files changed, 58 insertions(+), 49 deletions(-) diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 0d4d07dc..d551a766 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -6,19 +6,24 @@ class Oqs::HomeController < BaseOqsController @queue_items_details = queue_items_query(false) # Query for OQS with delivery status true - @queue_completed_item = queue_items_query(true) + @queue_completed_item = completed_order @queue_stations_items=Array.new # Calculate Count for each station tab queue_stations.each do |que| - i=0 + i = 0 + zone_id = 0 @queue_items_details.each do |qid| - if qid.station_name == que.station_name - i=i+1 - end + dining = DiningFacility.find_by_name(qid.zone) + que.order_queue_process_by_zones.each do |qz| + if qid.station_id == qz.order_queue_station_id && qid.zone_id == dining.zone_id + zone_id = qid.zone_id + i=i+1 + end + end end - @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) + @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i }) end @queue_stations_items @@ -83,34 +88,9 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with delivery status def queue_items_query(status) - # queue_items = [] - # AssignedOrderItem.all.each do |aoi| - # oqs = OrderQueueStation.find(aoi.order_queue_station_id) - # order = Order.find(aoi.order_id) - # order_items = OrderItem.find_by_order_id(aoi.order_id) - # booking_orders = BookingOrder.find_by_order_id(aoi.order_id) - # booking = Booking.find(booking_orders.booking_id) - # dining = DiningFacility.find(booking.dining_facility_id) - # customer = Customer.find_by_customer_id(order.customer_id) - # queue_item = { - # :assigned_order_item_id => aoi.assigned_order_item_id, - # :station_name => oqs.station_name, - # :is_active => oqs.is_active, - # :zone => dining.name, - # :item_code => aoi.item_code, - # :item_name => order_items.item_name, - # :price => order_items.price, - # :qty => order_items.qty, - # :item_order_by => order_items.item_order_by, - # :options => order_items.options, - # :customer_name => customer.name, - # :created_at => order_items.created_at - # } - # queue_items.push(queue_item) - # end - # return queue_items - AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") + AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id + left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id left join customers as cus ON cus.customer_id = od.customer_id @@ -120,4 +100,23 @@ class Oqs::HomeController < BaseOqsController .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0") .group("assigned_order_items.assigned_order_item_id") end + + # Completed Order + def completed_order + AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") + .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id + left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id + left join orders as od ON od.order_id = assigned_order_items.order_id + left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id + left join customers as cus ON cus.customer_id = od.customer_id + left join booking_orders as bo on bo.order_id = assigned_order_items.order_id + left join bookings as bk on bk.booking_id = bo.booking_id + left join dining_facilities as df on df.id = bk.dining_facility_id") + .where("assigned_order_items.delivery_status = true AND odt.price <> 0") + .group("assigned_order_items.order_id") + + + # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); + end + end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 02a85f91..16590320 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -74,8 +74,10 @@ class Origami::DiscountsController < BaseOrigamiController end end - sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; - sale.save + # sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + # sale.save + # Re-calc All Amount in Sale + sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) end dining = {:table_id => table_id, :table_type => table_type } @@ -100,8 +102,12 @@ class Origami::DiscountsController < BaseOrigamiController end end - sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; - sale.save + # sale.total_discount = 0 + # sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + # sale.save + + # Re-calc All Amount in Sale + sale.compute_by_sale_items(sale_id, sale.sale_items, 0) end dining = {:table_id => table_id, :table_type => table_type } diff --git a/app/models/sale.rb b/app/models/sale.rb index 2578221d..d1cd63d0 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -224,7 +224,7 @@ class Sale < ApplicationRecord total_taxable = total_taxable + (item.taxable_price * item.qty) end - compute_tax(sale, total_taxable) + compute_tax(sale, total_taxable, total_discount) sale.total_amount = subtotal_price sale.total_discount = total_discount sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax @@ -262,7 +262,7 @@ class Sale < ApplicationRecord end # Tax Re-Calculte - def compute_tax(sale, total_taxable) + def compute_tax(sale, total_taxable, total_discount = 0) #if tax is not apply create new record SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax| #delete existing and create new @@ -280,9 +280,12 @@ class Sale < ApplicationRecord sale_tax.tax_rate = tax.rate #include or execulive # sale_tax.tax_payable_amount = total_taxable * tax.rate + + # substract , to give after discount + total_taxable = total_taxable - total_discount sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 - #new taxable amount - total_taxable = total_taxable + sale_tax.tax_payable_amount + #new taxable amount is standard rule for step by step + # total_taxable = total_taxable + sale_tax.tax_payable_amount sale_tax.inclusive = tax.inclusive sale_tax.save @@ -319,8 +322,8 @@ class Sale < ApplicationRecord #include or execulive # sale_tax.tax_payable_amount = total_taxable * tax.rate sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 - #new taxable amount - total_taxable = total_taxable + sale_tax.tax_payable_amount + #new taxable amount is standard rule for step by step + # total_taxable = total_taxable + sale_tax.tax_payable_amount sale_tax.inclusive = tax.inclusive sale_tax.save diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 0f387dad..571de1a2 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -22,7 +22,10 @@ <%= qsi[:station_name] %> > <%= qsi[:item_count] %> - + + <% if qsi[:is_ap] %> + (ap) + <% end %> <% end %> @@ -34,8 +37,7 @@
<% - @queue_completed_item.each do |qid| - if qid.price != 0 + @queue_completed_item.each do |qid| %>
@@ -70,8 +72,7 @@
- <% - end + <% end %>
@@ -89,7 +90,7 @@ <% @queue_items_details.each do |qid| if qid.price != 0 - if qid.station_name == qsi[:station_name] + if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name] %>
From e9b1845ed2bde11b765d92cac49d25d7dff36fee Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 1 Jul 2017 20:02:14 +0630 Subject: [PATCH 10/21] saturday fixed --- .../origami/other_charges_controller.rb | 2 +- .../origami/payments_controller.rb | 6 ++-- .../origami/sale_edit_controller.rb | 2 +- app/controllers/origami/void_controller.rb | 7 +++++ app/models/printer/receipt_printer.rb | 5 ++-- app/pdf/receipt_bill_pdf.rb | 29 ++++++++++--------- app/views/origami/discounts/index.html.erb | 4 +-- 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index a23ebd16..bb0d9e42 100644 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -29,7 +29,7 @@ class Origami::OtherChargesController < BaseOrigamiController sale_item.sale_id = sale_id sale_item.product_code = "Other Charges" - sale_item.product_name = di["name"] + sale_item.product_name = "*" + di["name"] sale_item.product_alt_name = "" sale_item.remark = "Other Charges" diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 2cdd44b5..1a757282 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -30,7 +30,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details) + printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt") end def create @@ -63,7 +63,7 @@ class Origami::PaymentsController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid") end end @@ -142,6 +142,6 @@ class Origami::PaymentsController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print") end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index d4fba302..0e2c6cff 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -18,7 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.save @newsaleitem.qty = saleitemObj.qty * -1 @newsaleitem.price = saleitemObj.price * -1 - @newsaleitem.is_taxable = 0 + @newsaleitem.is_taxable = 1 @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index b8972cf2..687d9fa5 100644 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -30,6 +30,13 @@ class Origami::VoidController < BaseOrigamiController table.save end + # update complete order items in oqs + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| + aoi.delivery_status = 1 + aoi.save + end + end end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index f8eb46d6..652339b9 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) + + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status) # print as print copies in printer setting count = printer_settings.print_copies diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index bff0852d..60e1203c 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,7 +1,7 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status) self.page_width = 210 self.page_height = 7000 self.margin = 5 @@ -53,7 +53,7 @@ class ReceiptBillPdf < Prawn::Document items_account(item_price_by_accounts,printer_settings.precision,delimiter) - footer + footer(printed_status) end def header (shop_details) @@ -82,14 +82,11 @@ class ReceiptBillPdf < Prawn::Document 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 - end - move_down 5 - - y_position = cursor - bounding_box([0,y_position], :width =>self.item_width, :height => self.item_height) do - text "Cashier: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :left + bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do + text "W: #{sale_data.requested_by}" , :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 "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end move_down 5 @@ -182,7 +179,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ st.tax_name }", :size => self.item_font_size,:align => :left + text "#{ st.tax_name } ( #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right @@ -360,12 +357,18 @@ class ReceiptBillPdf < Prawn::Document end end - def footer + def footer(printed_status) move_down 5 stroke_horizontal_rule move_down 5 - text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center + y_position = cursor + bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do + text "#{printed_status}", :size => self.header_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width =>self.label_width, :height => self.item_height) do + text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :right + end move_down 5 end diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index fbbff065..faa48c05 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -174,7 +174,7 @@
- +
@@ -187,7 +187,7 @@
- +
From 6fe2de877c6e9eb109bc02d5d9714f0d0cc5f534 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 1 Jul 2017 20:08:57 +0630 Subject: [PATCH 11/21] remove add order --- app/views/origami/home/show.html.erb | 4 ++-- app/views/origami/rooms/show.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index f89560f3..34093cb5 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -301,7 +301,7 @@ <% if @status_order == 'order' && @status_sale != 'sale' %> - + @@ -311,7 +311,7 @@ <% else %> - + diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 36ae77c5..2cde86c9 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -272,7 +272,7 @@ <% if @status_order == 'order' && @status_sale != 'sale' %> - + @@ -281,7 +281,7 @@ <% else %> - + From 78adf564e1f91c2ca0ced51c4dc85abe44263b29 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 09:37:19 +0630 Subject: [PATCH 12/21] crong job and close cashier --- Gemfile | 1 + Gemfile.lock | 4 ++ app/controllers/crm/customers_controller.rb | 8 +++- app/models/customer.rb | 42 +++++++++++++++++++++ app/pdf/close_cashier_pdf.rb | 3 ++ config/schedule.rb | 7 ++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 config/schedule.rb diff --git a/Gemfile b/Gemfile index 4c544ad6..5344bdc5 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,7 @@ gem 'jbuilder', '~> 2.5' gem 'bcrypt', '~> 3.1.7' gem 'sidekiq' +gem 'whenever', :require => false # XML parser #gem 'nokogiri', '~> 1.6' diff --git a/Gemfile.lock b/Gemfile.lock index 7e27774a..affb7b95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,6 +51,7 @@ GEM builder (3.2.3) byebug (9.0.6) cancancan (1.17.0) + chronic (0.10.2) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -237,6 +238,8 @@ GEM websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) + whenever (0.9.7) + chronic (>= 0.6.3) PLATFORMS ruby @@ -282,6 +285,7 @@ DEPENDENCIES tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) + whenever BUNDLED WITH 1.15.1 diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 2f5b25d2..6d875a98 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -123,7 +123,8 @@ class Crm::CustomersController < BaseCrmController end # format.json { render :index, status: :created, location: @crm_customers } else - # @crm_customers.destroy + customer = Customer.find(@crm_customers.customer_id) + status = customer.update_attributes(membership_type:member_group_id ) if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} else @@ -207,7 +208,12 @@ end status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} + else + + customer = Customer.find(@crm_customer.customer_id) + status = customer.update_attributes(membership_type:member_group_id ) + format.html { redirect_to crm_customers_path, notice: response["error"] } end diff --git a/app/models/customer.rb b/app/models/customer.rb index a26d857e..16d70db7 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -73,6 +73,48 @@ class Customer < ApplicationRecord end + def self.update_membership + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("create_membership_customer") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + @customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL") + + @customers.each do |customer| + begin + response = HTTParty.post(url, + :body => + { name: customer.name,phone: customer.contact_no, + email: customer.email,dob: customer.date_of_birth, + address: customer.address,nrc:customer.nrc_no, + card_no:customer.card_no,member_group_id: customer.membership_type, + merchant_uid:merchant_uid,auth_token:auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }) + rescue Net::OpenTimeout + response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} + end + + puts response.to_json + + if response["status"] == true + status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) + end + + end + end + def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index b3b29914..fc04b6cc 100644 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -168,7 +168,10 @@ class CloseCashierPdf < Prawn::Document text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right end + move_down 5 + stroke_horizontal_rule move_down 5 + move_down 5 end diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 00000000..b21a46e3 --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,7 @@ +set :environment, "development" +env :PATH, ENV['PATH'] +set :output, 'log/whenever.log' + +every 30.minutes do + runner "Customer.update_membership" +end \ No newline at end of file From 972a7173619a8298c7748a985447595288053168 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 10:04:06 +0630 Subject: [PATCH 13/21] update payper and redeem --- app/models/sale_payment.rb | 4 ++-- app/pdf/receipt_bill_pdf.rb | 32 +++++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 59cee9a6..5424e3d5 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -223,7 +223,7 @@ class SalePayment < ApplicationRecord membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) if membership_data["status"]==true - self.payment_method = "paypar" + self.payment_method = "redeem" self.payment_amount = self.received_amount self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f @@ -307,7 +307,7 @@ class SalePayment < ApplicationRecord paypar = sObj.sale_payments payparcost = 0 paypar.each do |pp| - if pp.payment_method == "paypar" + if pp.payment_method == "redeem" payparcost = payparcost + pp.payment_amount end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 60e1203c..a2f3827b 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -265,32 +265,34 @@ class ReceiptBillPdf < Prawn::Document rebate = 0 rebate_amount["data"].each do |res| - if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" - - rebate = rebate + res["rebate"] - - end if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Redeem Amount", :size => self.item_font_size,:align => :left + text "Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + rebate = rebate + res["rebate"] + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Earn", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end end - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Rebate Amount", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(rebate, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + end end if member_info["status"] == true && member_info["data"].present? @@ -306,7 +308,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 "Current Balance", :size => self.item_font_size,:align => :left + text "Total Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right From 678c37c6b01fe7e5be8aadc1bd1f72dee5a0f679 Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 11:00:01 +0630 Subject: [PATCH 14/21] Rebate Bug Fix --- app/models/sale_payment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 59cee9a6..0bf80955 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -55,7 +55,7 @@ class SalePayment < ApplicationRecord sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) # update complete order items in oqs - SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr| + SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr| AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| aoi.delivery_status = 1 aoi.save @@ -314,7 +314,7 @@ class SalePayment < ApplicationRecord # overall_dis = SaleItem.get_overall_discount(sObj.id) overall_dis = sObj.total_discount - total_amount = rebate_prices - payparcost + overall_dis + total_amount = rebate_prices - payparcost - overall_dis if total_amount > 0 receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") From acca5b5a1d47a0cd86ce056ac1998b16bb16dcc9 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 2 Jul 2017 11:22:49 +0630 Subject: [PATCH 15/21] Update --- app/controllers/api/bill_controller.rb | 33 +++++++++++--------- app/controllers/origami/shifts_controller.rb | 2 ++ app/models/shift_sale.rb | 8 ++++- app/views/origami/home/show.html.erb | 12 +++---- app/views/origami/payments/show.html.erb | 2 ++ 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index cb3b9cc2..bcd9d62b 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -5,26 +5,29 @@ class Api::BillController < Api::ApiController def create @status = false @error_message = "Order ID or Booking ID is require to request for a bill." - + if ShiftSale.current_shift #create Bill by Booking ID - if (params[:booking_id]) - booking = Booking.find(params[:booking_id]) + if (params[:booking_id]) + booking = Booking.find(params[:booking_id]) - if booking - if booking.sale_id.nil? - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) - else - @status = true - @sale_id = booking.sale_id + if booking + if booking.sale_id.nil? + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) + else + @status = true + @sale_id = booking.sale_id + end end - end - elsif (params[:order_id]) - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) + elsif (params[:order_id]) + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) + end + else + @status = false + @error_message = "No Current Open Shift" end - # Not Use for these printed bill cannot give customer # @sale_data = Sale.find_by_sale_id(@sale_id) # @sale_items = SaleItem.where("sale_id=?",@sale_id) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 07d10cf7..e527da46 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,6 +4,8 @@ class Origami::ShiftsController < BaseOrigamiController end def show + puts ">>>>>" + puts current_user.id @shift = ShiftSale.current_open_shift(current_user.id) end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index acf3149c..b9c5aa28 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -16,11 +16,17 @@ class ShiftSale < ApplicationRecord belongs_to :cashier_terminal belongs_to :employee, :foreign_key => 'employee_id' + def self.current_shift + today_date = DateTime.now.strftime("%Y-%m-%d") + shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null",today_date).take + return shift + end + def self.current_open_shift(current_user) #if current_user #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take return shift #end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 0d3de391..baad1a0a 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -163,18 +163,18 @@ <% - count = 0 sub_total = 0 if @status_sale == "sale" @sale_array[0].sale_items.each do |sale_item| - count += 1 - sub_total = sub_total + sale_item.price + + sub_total = sub_total + sale_item.price %> <% # Can't check for discount unless sale_item.price == 0 + count += 1 %> <%= count %> @@ -439,7 +439,7 @@ $("#first_bill").on('click', function(){ $.ajax({ type: "GET", url: ajax_url, - success:function(result){ + success:function(result){ location.reload(); } }); @@ -452,11 +452,11 @@ $('#pay').on('click',function() { $.ajax({ type: "POST", url: '/origami/sale/'+ sale_id + "/rounding_adj", - success:function(result){ + success:function(result){ window.location.href = '/origami/sale/'+ sale_id + "/payment"; } }); - + }); // Bill Request diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 292ae5e1..86738c22 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -334,6 +334,7 @@ $( document ).ready(function() { }); $('#pay').click(function() { + $('#pay').text("Processing, Please wait!") if($('#balance').text() > 0){ alert(" Insufficient Amount!") }else{ @@ -351,6 +352,7 @@ $( document ).ready(function() { if($('#balance').text() < 0){ alert("Changed amount " + $('#balance').text() * (-1) ) }else{ + $('#pay').text("Pay") alert("Thank you") } From b78119f848a38c9adfbb06e7e636708a0cf040d8 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 11:41:47 +0630 Subject: [PATCH 16/21] update print --- app/controllers/origami/customers_controller.rb | 1 + app/pdf/receipt_bill_pdf.rb | 4 ++-- app/views/crm/customers/index.html.erb | 10 +++++++--- app/views/origami/customers/index.html.erb | 13 ++++++++----- db/seeds.rb | 1 + 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index e8376fc4..203e5600 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -34,6 +34,7 @@ class Origami::CustomersController < BaseOrigamiController #@crm_customers = Customer.all @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new + @count_customer = Customer.count_customer # if flash["errors"] # @crm_customer.valid? diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index a2f3827b..db913c4a 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -366,10 +366,10 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do - text "#{printed_status}", :size => self.header_font_size,:align => :left + text "#{printed_status}", :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 "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :right + text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :right end move_down 5 diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index b3c1fce7..a44aed2f 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -47,11 +47,15 @@ <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-00001" && crm_customer.customer_id != "CUS-000000000" %> + - <%= @i += 1 %> + + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <% end %> + <%= crm_customer.name %> <%= crm_customer.card_no rescue '-' %> <%= crm_customer.contact_no %> @@ -59,7 +63,7 @@ <%= link_to 'Show', crm_customer_path(crm_customer) %> - <% end %> + <% end %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 489487ab..72e402e8 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -41,11 +41,15 @@ <% if @crm_customers.count > 0 %> <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-00000" && crm_customer.customer_id != "CUS-00000000" %> + - <%= @i += 1 %> + + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <% end %> + <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> @@ -53,7 +57,6 @@ - <% end %> <% end %> <%else%>

There are no record for your search

@@ -155,10 +158,10 @@ <%= f.input :address, :class => "form-control col-md-6 address" %>
- +
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> diff --git a/db/seeds.rb b/db/seeds.rb index b71418a9..3bff75a0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -159,6 +159,7 @@ admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "3 order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) +close_cashier_printer=PrintSetting.create({name: "Close Cashier", unique_code: "CloseCashierPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) From 58f2ff28e598800da964619f9e99a388d628f8bf Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 2 Jul 2017 11:53:33 +0630 Subject: [PATCH 17/21] update void --- app/models/sale_payment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 0bf80955..1d8a0e99 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -287,7 +287,7 @@ class SalePayment < ApplicationRecord bookings = table.bookings bookings.each do |tablebooking| if tablebooking.booking_status != 'moved' - if tablebooking.sale.sale_status != 'completed' + if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' status = false end end From 7994fcc0c301fa86337306f7cf5192c21d37702a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 12:06:28 +0630 Subject: [PATCH 18/21] update --- app/models/sale_payment.rb | 4 ++-- app/pdf/receipt_bill_pdf.rb | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5424e3d5..59cee9a6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -223,7 +223,7 @@ class SalePayment < ApplicationRecord membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) if membership_data["status"]==true - self.payment_method = "redeem" + self.payment_method = "paypar" self.payment_amount = self.received_amount self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f @@ -307,7 +307,7 @@ class SalePayment < ApplicationRecord paypar = sObj.sale_payments payparcost = 0 paypar.each do |pp| - if pp.payment_method == "redeem" + if pp.payment_method == "paypar" payparcost = payparcost + pp.payment_amount end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index db913c4a..4557eadd 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -233,9 +233,16 @@ class ReceiptBillPdf < Prawn::Document SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment| y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + if payment.payment_method == "paypar" + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Payment", :size => self.item_font_size,:align => :left + end + else + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end @@ -368,8 +375,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do text "#{printed_status}", :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 "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :right + bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left end move_down 5 From a86ac10e833157cf22582ca7de6239b86a9d1a5c Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 13:39:36 +0630 Subject: [PATCH 19/21] Zone OQS bug fix --- app/controllers/settings/order_queue_stations_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index 9fe78de4..dea66941 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -74,10 +74,10 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params # <<<<<<< HEAD - params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) +# params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) # ======= # Don't Know { zone_ids: [] } -# params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) + params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) # >>>>>>> b093a993ba002c92659bbb34338c55c031c11d87 end end From a0e16bd48544e2725a3103e98c89144129aa17d2 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 14:06:21 +0630 Subject: [PATCH 20/21] update crm and bill --- app/controllers/crm/customers_controller.rb | 17 ++++++++- app/pdf/receipt_bill_pdf.rb | 42 +++++++++++++++------ app/views/crm/customers/show.html.erb | 25 +++++++----- app/views/transactions/sales/show.html.erb | 37 +++++++++++------- 4 files changed, 87 insertions(+), 34 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 6d875a98..f67d413c 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -48,7 +48,22 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) + # get member information + total = Customer.get_member_account(@customer) + + + @balance = 0.00 + @accountable_type = '' + if total["status"]==true + total["data"].each do |res| + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + @balance += res["balance"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" + end + end + end # @response = "" #end customer amount diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 4557eadd..52cdf586 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -270,21 +270,17 @@ class ReceiptBillPdf < Prawn::Document if rebate_amount["status"] == true stroke_horizontal_rule rebate = 0 + redeem = 0 rebate_amount["data"].each do |res| if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" - - 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 - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + redeem = redeem + res["redeem"] + end - if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate" rebate = rebate + res["rebate"] @@ -294,11 +290,35 @@ class ReceiptBillPdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate" + + rebate = rebate + res["rebate"] + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end end + + 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 + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end end end diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 5d36f5c3..21a05d9c 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -32,6 +32,7 @@ NRC/Passport No Address DOB + Membership Type @@ -45,8 +46,16 @@ <%= @customer.nrc_no %> <%= @customer.address%> <%= @customer.date_of_birth %> + <% if @customer.membership_type.to_f > 0%> + <%lookup= Lookup.find_by_value(@customer.membership_type) %> + <%= lookup.name %> + + <%else%> + - + <%end%> + - + @@ -55,21 +64,19 @@
- <% - if @response["data"].present? %> + - <% if @response["status"] == true %> - - <% end %> + + + - <% end %> - + @@ -82,7 +89,7 @@ - + diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index b62289b1..4dd15755 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -39,6 +39,9 @@ + @@ -235,23 +238,31 @@ +
+
+
+
Membership TransactionsCurrent Balance : <%= @response["data"].last["balance"]%>Current Balance : <%= @balance%>
Date Redeem Rebate BalanceFrom Account Status Receipt No
<%= transaction["redeem"]%> <%= transaction["rebate"] %> <%= transaction["balance"] %><%= transaction["account_status"] %> <%= transaction["status"] %> <%= transaction["receipt_no"] %>
+ + + + + + + + + + + + + +
StatusAction AtApproved ByRemark
+
+
+ - From 70668e4264911a57710cb0358cb4c547730fa4ab Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 14:20:23 +0630 Subject: [PATCH 21/21] Credit note Rebate Prevent --- app/models/sale_payment.rb | 8 +++++++- lib/tasks/menu_import.rake | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 1d8a0e99..936bc08a 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -306,16 +306,22 @@ class SalePayment < ApplicationRecord if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments payparcost = 0 + credit = 0 paypar.each do |pp| if pp.payment_method == "paypar" payparcost = payparcost + pp.payment_amount + elsif pp.payment_method == "creditnote" + credit = 1 end end # overall_dis = SaleItem.get_overall_discount(sObj.id) overall_dis = sObj.total_discount total_amount = rebate_prices - payparcost - overall_dis - if total_amount > 0 + if credit == 1 + total_amount = 0 + end + if total_amount >= 0 receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("rebate") diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 5db6231f..11f4fad2 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -67,7 +67,7 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0152", menu_item: menu_category1_menu_item7, price:8000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0151", menu_item: menu_category1_menu_item7, price:16000.00, is_on_promotion:false}]) # Sliced Beef (Thin) - menu_category1_menu_item8 = SimpleMenuItem.create({item_code:"01009", name: "Sliced Beef (Thin)", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item8 = SimpleMenuItem.create({item_code:"01009", name: "Sliced Beef ( Thin )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0162", menu_item: menu_category1_menu_item8, price:6000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0161", menu_item: menu_category1_menu_item8, price:12000.00, is_on_promotion:false}]) # Tender Sliced Beef @@ -87,7 +87,7 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item12, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item12, price:14000.00, is_on_promotion:false}]) # Sliced Beef ( Think ) - menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Think )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Thick )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1432", menu_item: menu_category1_menu_item13, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1431", menu_item: menu_category1_menu_item13, price:14000.00, is_on_promotion:false}]) # Pork