diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index a8e2818c..759cb1b6 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -95,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c31dd44d..0a1ea0db 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -113,8 +113,6 @@ class Origami::PaymentsController < BaseOrigamiController end end #end rounding adjustment - puts "sale" - puts saleObj.to_json sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 11a7f93d..5c0cd454 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -79,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' - puts "enter" + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 74e495ca..83dce707 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -48,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController table.bookings.each do |booking| if booking.booking_status != 'moved' if booking.sale_id - if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' table_avaliable = false table_count += 1 else diff --git a/app/controllers/origami/waste_spoile_controller .rb b/app/controllers/origami/waste_spoile_controller.rb similarity index 83% rename from app/controllers/origami/waste_spoile_controller .rb rename to app/controllers/origami/waste_spoile_controller.rb index 72180786..c94b33bb 100755 --- a/app/controllers/origami/waste_spoile_controller .rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -1,29 +1,28 @@ class Origami::WasteSpoileController < BaseOrigamiController - def index - - end - def waste_and_spoile + def waste_and_spoilage sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] #tax profile source if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) - - if sale.discount_type == "member_discount" - sale.update_attributes(total_discount: 0) - sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) + SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax| + existing_tax.delete end - + sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0) sale.payment_status = remark sale.sale_status = remark sale.save + # sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) # add to sale item with foc - sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null") + # sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null") - sale_items.each do|item| - SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price) + sale.sale_items.each do|item| + # SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price) + item.status = remark + item.remark = remark + item.save end if sale.bookings[0].dining_facility_id.to_i > 0 @@ -33,7 +32,7 @@ class Origami::WasteSpoileController < BaseOrigamiController table.bookings.each do |booking| if booking.booking_status != 'moved' if booking.sale_id - if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' table_avaliable = false table_count += 1 else @@ -45,7 +44,6 @@ class Origami::WasteSpoileController < BaseOrigamiController end end end - if table_avaliable && table_count == 0 table.status = 'available' table.save @@ -104,7 +102,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/reports/waste_and_spoilage_controller.rb b/app/controllers/reports/waste_and_spoilage_controller.rb new file mode 100755 index 00000000..369c6860 --- /dev/null +++ b/app/controllers/reports/waste_and_spoilage_controller.rb @@ -0,0 +1,19 @@ +class Reports::WasteAndSpoilageController < BaseReportController +authorize_resource :class => false + def index + from, to = get_date_range_from_params + @sale_type = params[:sale_type] + @sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type) + @from = from + @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + + respond_to do |format| + format.html + format.xls + end + end + + +end \ No newline at end of file diff --git a/app/models/sale.rb b/app/models/sale.rb index ebb32ec3..883fbad4 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1109,6 +1109,16 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type return all_total,sale_type end +def self.get_wastes_and_spoilages(from,to,status) + if status == "spoile" + type = "and sales.sale_status = 'spoile'" + else + type = "and sales.sale_status = 'waste'" + end + query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to) + .group("sales.receipt_no") +end + # def self.get_separate_tax(from,to,payment_method=nil) # query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 6b08a9fa..cceee884 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -420,7 +420,7 @@ class SalePayment < ApplicationRecord bookings.each do |tablebooking| if tablebooking.booking_status != 'moved' if tablebooking.sale_id - if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' + if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' status = false sale_count += 1 else diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index 63067ec0..ea3a7b61 100644 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -144,6 +144,9 @@
  • Void Sales
  • +
  • + Wastes & Spoilages +
  • Payment Method
  • diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 2600f3fe..f36ca636 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -26,7 +26,7 @@ <% end %> --> - <% path ="/origami/#{@sale_id}/customers" %> + <% path ="/origami/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %> <%= form_tag path, :id => "filter_form", :method => :get do %>
    diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8ffe8964..4810cf13 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -598,8 +598,6 @@
    @@ -1059,8 +1057,6 @@ if (isConfirm) { var sale_id = "<%= @obj_sale.sale_id rescue "" %>" var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage'; - -console.log(url) $.ajax({ type: 'POST', url: url, @@ -1068,10 +1064,10 @@ console.log(url) success: function (result) { console.log(result) // For Server Print - from jade - // if ($("#server_mode").val() == "cloud") { - // code2lab.printFile(result.filepath.substr(6), result.printer_url); - // } - // window.location.href = '/origami/'; + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + window.location.href = '/origami/'; } }); } diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 424690ff..e2f04018 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -450,10 +450,11 @@ <% if current_login_employee.role != "waiter" %> - - - + +
    + +
    +
    + +
    + + + + + + + diff --git a/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb b/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb new file mode 100755 index 00000000..1c403afc --- /dev/null +++ b/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb @@ -0,0 +1,73 @@ +
    + <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
    +
    + + +
    +
    + + +
    + +
    + + + +
    +
    + + +
    + +
    +
    + +
    +
    + <% end %> + + <% end %> +
    + + diff --git a/app/views/reports/waste_and_spoilage/index.html.erb b/app/views/reports/waste_and_spoilage/index.html.erb new file mode 100755 index 00000000..f74f99e0 --- /dev/null +++ b/app/views/reports/waste_and_spoilage/index.html.erb @@ -0,0 +1,75 @@ +
    + +
    +
    + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %> +
    + +
    +
    + + +
    Report For <%= @sale_type? @sale_type : 'Waste' %>
    + <% @sale_data.each do |sale| %> + <% waste_and_spoil_item_count = 0%> + + + + + + + + + + + + + + + + + <% sale.sale_items.each do |item| %> + <% if !item.item_instance_code.nil?%> + <% waste_and_spoil_item_count += item.qty.to_i%> + + + + + + + + <% end %> + <% end %> + + + + + + + + <% end %> +
    + Receipt No :<%= sale.receipt_no %> + Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
    Item NameItem CodeQtyPriceTotal Price
    <%= item.product_name %><%= item.product_code %><%= item.qty %><%= item.price %><%= item.price %>
    Total Qty: + <%= waste_and_spoil_item_count %> + Grand Total: + + <%= sale.grand_total %> + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/reports/waste_and_spoilage/index.xls.erb b/app/views/reports/waste_and_spoilage/index.xls.erb new file mode 100755 index 00000000..4b4fa0a3 --- /dev/null +++ b/app/views/reports/waste_and_spoilage/index.xls.erb @@ -0,0 +1,58 @@ +
    +
    +
    +
    + + +
    Report For <%= @sale_type? @sale_type : 'Waste' %>
    + <% @sale_data.each do |sale| %> + <% waste_and_spoil_item_count = 0%> + + + + + + + + + + + + + + + + + <% sale.sale_items.each do |item| %> + <% if !item.item_instance_code.nil?%> + <% waste_and_spoil_item_count += item.qty.to_i%> + + + + + + + + <% end %> + <% end %> + + + + + + + + <% end %> +
    + Receipt No :<%= sale.receipt_no %> + Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
    Item NameItem CodeQtyPriceTotal Price
    <%= item.product_name %><%= item.product_code %><%= item.qty %><%= item.price %><%= item.price %>
    Total Qty: + <%= waste_and_spoil_item_count %> + Grand Total: + + <%= sale.grand_total %> + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6416f236..43c3d885 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,15 +78,13 @@ scope "(:locale)", locale: /en|mm/ do post "check_in" => "check_in_process#check_in_process" post "request_time" => "check_in_process#request_time" post "call_waiter" => "call_waiters#index" - #---------Waste and Spoile --------------# - post 'sale/:sale_id/:type/waste_and_spoilage' => 'waste_spoile#waste_and_spoilage' end end #--------- Cashier ------------# - namespace :origami do + namespace :origami do get "dashboard" => "dashboard#index" @@ -199,7 +197,7 @@ scope "(:locale)", locale: /en|mm/ do #---------Void --------------# post 'sale/:sale_id/:type/void' => 'void#overall_void' - + post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage" #---------Multiple Invoices --------------# get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index" @@ -408,6 +406,7 @@ scope "(:locale)", locale: /en|mm/ do resources :shiftsale, :only => [:index, :show] resources :credit_payment, :only => [:index, :show] resources :void_sale, :only => [:index, :show] + resources :waste_and_spoilage, :only => [:index, :show] resources :commission, :only => [:index, :show] resources :stock_check, :only => [:index, :show] resources :payment_method diff --git a/db/migrate/20170403183755_create_tax_profiles.rb b/db/migrate/20170403183755_create_tax_profiles.rb index f5210bbb..2c96fd0d 100755 --- a/db/migrate/20170403183755_create_tax_profiles.rb +++ b/db/migrate/20170403183755_create_tax_profiles.rb @@ -2,7 +2,7 @@ class CreateTaxProfiles < ActiveRecord::Migration[5.1] def change create_table :tax_profiles do |t| t.string :name, :null => false - t.string :group_type, :null => false + t.string :group_type t.decimal :rate, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.boolean :inclusive, :null => false, :default => false t.integer :order_by, :null => false, :default => 1