From 54526230aa8f2cec287380e1fdee779f7be7a6bb Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 22 Jun 2017 10:25:40 +0630 Subject: [PATCH 1/3] update customerbind in origami --- .../origami/customers_controller.rb | 19 +++++++++++++++++++ config/routes.rb | 2 +- db/seeds.rb | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 601055e5..878571f1 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -39,5 +39,24 @@ class Origami::CustomersController < BaseOrigamiController end end + def update_sale_by_customer + + id = params[:sale_id][0,3] + if(id == "SAL") + sale = Sale.find(params[:sale_id]) + else + sale = Order.find(params[:sale_id]) + end + + status = sale.update_attributes(customer_id: params[:customer_id]) + + if status == true + render json: JSON.generate({:status => true}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + + end + end + end diff --git a/config/routes.rb b/config/routes.rb index 7ec8b9e5..3b647fa9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -112,7 +112,7 @@ Rails.application.routes.draw do #resources :customers get '/:sale_id/customers', to: "customers#add_customer" get '/:customer_id/get_customer' => 'home#get_customer' - post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table + post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table end #--------- Waiter/Ordering Station ------------# diff --git a/db/seeds.rb b/db/seeds.rb index a646bdad..0e88e336 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -83,8 +83,8 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag {lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}]) #WALK CUSTOMER - Default CUSTOMER (take key 1) -customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000"}) -customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111"}) +customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"000"}) #Default ZOne # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) From 187caa5253c63b5a2f02e6a422eee111d46a58df Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 22 Jun 2017 11:58:16 +0630 Subject: [PATCH 2/3] update customre --- app/assets/stylesheets/origami.scss | 6 ++++++ app/controllers/origami/customers_controller.rb | 13 +++++++++---- app/models/customer.rb | 2 +- app/views/origami/customers/index.html.erb | 2 +- app/views/origami/home/show.html.erb | 2 +- ...ers.rb => 20170622050926_create_customers.rb} | 16 +++++++--------- db/seeds.rb | 2 +- 7 files changed, 26 insertions(+), 17 deletions(-) rename db/migrate/{20170621085729_create_customers.rb => 20170622050926_create_customers.rb} (81%) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 6b350bf1..30e3781d 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -179,3 +179,9 @@ select.form-control { tr.discount-item-row:hover { background-color: #e3e3e3 !important; } + +/* Jquery Confirm */ + +.jconfirm-box-container{ + margin-left:-40px !important +} \ No newline at end of file diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 878571f1..373dc2f5 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -44,17 +44,22 @@ class Origami::CustomersController < BaseOrigamiController id = params[:sale_id][0,3] if(id == "SAL") sale = Sale.find(params[:sale_id]) + status = sale.update_attributes(customer_id: params[:customer_id]) else - sale = Order.find(params[:sale_id]) - end + @booking = BookingOrder.find_by_order_id(params[:sale_id]) + @orders = BookingOrder.where("booking_id = ? ", @booking.booking_id) - status = sale.update_attributes(customer_id: params[:customer_id]) + @orders.each do |bo| + order = Order.find(bo.order_id) + status = order.update_attributes(customer_id: params[:customer_id]) + end + + end if status == true render json: JSON.generate({:status => true}) else render json: JSON.generate({:status => false, :error_message => "Record not found"}) - end end diff --git a/app/models/customer.rb b/app/models/customer.rb index 4e25c9bc..5debec38 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -6,7 +6,7 @@ class Customer < ApplicationRecord has_many :orders has_many :sales - validates_presence_of :name, :contact_no, :email,:company,:card_no + validates_presence_of :name, :contact_no, :email,:card_no validates :contact_no, uniqueness: true validates :email, uniqueness: true validates :card_no, uniqueness: true diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 3b192319..5539b42b 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -246,7 +246,7 @@ $('#update_customer').removeAttr('disabled').val(''); $('#update_customer').attr('value', 'Update'); - $('#submit_customer').attr('disabled','disabled'); + // $('#submit_customer').attr('disabled','disabled'); $("#new_customer").attr('class', 'simple_form edit_customer'); var id = "edit_customer_"+$('#customer_id').val(); diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 22e35765..2719a758 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -298,7 +298,7 @@ $(document).ready(function(){ // bind customer to order or sale $("#customer").on('click', function(){ var sale = $('#sale_id').val(); - if (sale!="") { + if (sale) { var sale_id = sale }else{ var sale_id = $('#save_order_id').attr('data-order'); diff --git a/db/migrate/20170621085729_create_customers.rb b/db/migrate/20170622050926_create_customers.rb similarity index 81% rename from db/migrate/20170621085729_create_customers.rb rename to db/migrate/20170622050926_create_customers.rb index 57553010..07ec136f 100644 --- a/db/migrate/20170621085729_create_customers.rb +++ b/db/migrate/20170622050926_create_customers.rb @@ -1,22 +1,20 @@ class CreateCustomers < ActiveRecord::Migration[5.1] def change - create_table :customers, :id => false do |t| + create_table :customers, :id => false do |t| t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync t.string :name, :null => false t.string :company - t.string :contact_no, :unique => true t.string :email - t.date :date_of_birth - t.string :membership_id - t.string :membership_type - t.string :membership_authentication_code - t.string :salution + t.string :contact_no, :unique => true + t.date :date_of_birth + t.string :salutation t.string :gender t.string :nrc_no t.string :address t.string :card_no, :unique => true - - t.timestamps + t.string :membership_id + t.string :membership_type + t.string :membership_authentication_code end end end diff --git a/db/seeds.rb b/db/seeds.rb index 0e88e336..21268860 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -84,7 +84,7 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag #WALK CUSTOMER - Default CUSTOMER (take key 1) customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) -customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"000"}) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"}) #Default ZOne # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) From 3d838bc989b662793a817c02a99b645f77186e67 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 22 Jun 2017 13:35:20 +0630 Subject: [PATCH 3/3] update report and customer --- app/controllers/crm/customers_controller.rb | 4 +- .../reports/daily_sale_controller.rb | 4 + .../reports/receipt_no_controller.rb | 4 + .../reports/sale_item_controller.rb | 5 + app/views/api/customers/index.json.jbuilder | 2 +- app/views/api/customers/show.json.jbuilder | 2 +- .../crm/customers/_crm_customer.json.jbuilder | 2 +- app/views/crm/customers/index.html.erb | 8 +- app/views/crm/customers/show.json.jbuilder | 3 +- app/views/origami/customers/index.html.erb | 8 +- app/views/reports/sale_item/index.xls.erb | 246 ++++++++++-------- config/initializers/mime_types.rb | 1 + 12 files changed, 161 insertions(+), 128 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 646f6475..ce585686 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -46,7 +46,7 @@ class Crm::CustomersController < BaseCrmController end #get customer amount - @customer = Customer.find(params[:id]) + @customer = Customer.find(params[:id]) @response = Customer.get_membership_transactions(@customer) #end customer amount @@ -201,6 +201,6 @@ end def customer_params params.require(:customer).permit(:name, :company, :contact_no, :email, - :date_of_birth,:salution,:gender,:nrc_no,:address,:card_no) + :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no) end end diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_sale_controller.rb index 6e1eb85a..ba453f55 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_sale_controller.rb @@ -4,6 +4,10 @@ class Reports::DailySaleController < BaseReportController from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) @tax = SaleTax.get_tax(from,to) + respond_to do |format| + format.html + format.xls + end end def show diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 86c8d981..d85c7d57 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -8,6 +8,10 @@ class Reports::ReceiptNoController < BaseReportController puts to @sale_data = Sale.get_receipt_no_list(from,to) @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) + respond_to do |format| + format.html + format.xls + end end def show diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/sale_item_controller.rb index 1da31aff..eb7d3b86 100644 --- a/app/controllers/reports/sale_item_controller.rb +++ b/app/controllers/reports/sale_item_controller.rb @@ -5,6 +5,11 @@ class Reports::SaleItemController < BaseReportController from, to, report_type = get_date_range_from_params @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type) + + respond_to do |format| + format.html + format.xls + end end def show diff --git a/app/views/api/customers/index.json.jbuilder b/app/views/api/customers/index.json.jbuilder index 2c3c07a7..0d1d37e7 100644 --- a/app/views/api/customers/index.json.jbuilder +++ b/app/views/api/customers/index.json.jbuilder @@ -1,3 +1,3 @@ -json.array! @customers, :id, :name, :company, :contact_no,:salution, +json.array! @customers, :id, :name, :company, :contact_no,:salutation, :gender,:nrc_no,:address,:card_no, :membership_type, :membership_id, :created_at diff --git a/app/views/api/customers/show.json.jbuilder b/app/views/api/customers/show.json.jbuilder index db56961b..acf54ac1 100644 --- a/app/views/api/customers/show.json.jbuilder +++ b/app/views/api/customers/show.json.jbuilder @@ -1,4 +1,4 @@ -json.extract! @customer, :id, :name, :company, :contact_no,:salution, +json.extract! @customer, :id, :name, :company, :contact_no,:salutation, :gender,:nrc_no,:address,:card_no, :membership_type, :membership_id, :created_at json.invoices do diff --git a/app/views/crm/customers/_crm_customer.json.jbuilder b/app/views/crm/customers/_crm_customer.json.jbuilder index c80c1716..1b1b237e 100644 --- a/app/views/crm/customers/_crm_customer.json.jbuilder +++ b/app/views/crm/customers/_crm_customer.json.jbuilder @@ -1,2 +1,2 @@ -json.extract! crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at +json.extract! crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at,:salutation, :gender,:nrc_no,:address,:card_no json.url crm_customer_url(crm_customer, format: :json) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index e7b47460..3678008e 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -120,7 +120,7 @@ $(document).on('click',".customer_tr",function(){ $('#customer_company').val(data.company); $('#customer_contact_no').val(data.contact_no); $('#customer_email').val(data.email); - $('#customer_salution').val(data.salution); + $('#customer_salutation').val(data.salutation); $('#customer_nrc_no').val(data.nrc_no); $('#customer_card_no').val(data.card_no); $('#customer_address').val(data.address); @@ -133,11 +133,11 @@ $(document).on('click',".customer_tr",function(){ $('.female').prop( "checked", true ) } - if(data.salution == 'Mr') { + if(data.salutation == 'Mr') { $('.mr').prop( "checked", true ) - }else if(data.salution == 'Miss') { + }else if(data.salutation == 'Miss') { $('.miss').prop( "checked", true ) - }else if(data.salution == 'Mrs'){ + }else if(data.salutation == 'Mrs'){ $('.mrs').prop( "checked", true ) }else{ $('.mdm').prop( "checked", true ) diff --git a/app/views/crm/customers/show.json.jbuilder b/app/views/crm/customers/show.json.jbuilder index d41edb5d..86901801 100644 --- a/app/views/crm/customers/show.json.jbuilder +++ b/app/views/crm/customers/show.json.jbuilder @@ -1,5 +1,4 @@ json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, - :created_at, :updated_at, - :salution, :gender,:nrc_no,:address,:card_no + :salutation, :gender,:nrc_no,:address,:card_no json.url crm_customer_url(@crm_customer, format: :json) diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 5539b42b..8a811073 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -225,7 +225,7 @@ $('.select > option[value="'+data.membership_id+'"]').attr('selected','selected'); $('.membership_authentication_code').val(data.membership_authentication_code); - $('#customer_salution').val(data.salution); + $('#customer_salutation').val(data.salutation); $('#customer_nrc_no').val(data.nrc_no); if (data.gender == 'Male') { @@ -234,11 +234,11 @@ $('.female').prop( "checked", true ) } - if (data.salution == 'Mr') { + if (data.salutation == 'Mr') { $('.mr').prop( "checked", true ) - } else if(data.salution == 'Miss') { + } else if(data.salutation == 'Miss') { $('.miss').prop( "checked", true ) - }else if(data.salution == 'Mrs'){ + }else if(data.salutation == 'Mrs'){ $('.mrs').prop( "checked", true ) }else{ $('.mdm').prop( "checked", true ) diff --git a/app/views/reports/sale_item/index.xls.erb b/app/views/reports/sale_item/index.xls.erb index dfcc18d4..2807ec3f 100644 --- a/app/views/reports/sale_item/index.xls.erb +++ b/app/views/reports/sale_item/index.xls.erb @@ -1,116 +1,136 @@ -
-
- - - <% if params[:from]%> - - - - <% end %> - - - - - - - - - - - - - - - - - - - <% unless @sale_data.empty? %> - - - <% void = 0 %> - <% mpu = 0 %> - <% master = 0 %> - <% visa = 0 %> - <% jcb = 0 %> - <% paypar = 0 %> - <% cash = 0 %> - <% credit = 0 %> - <% foc = 0 %> - <% discount = 0 %> - <% total = 0 %> - <% grand_total = 0 %> - <% count = 1 %> <% rounding_adj = 0 %> - <% @sale_data.each do |sale| %> - <% void += sale[:void_amount] %> - <% mpu += sale[:mpu_amount] %> - <% master += sale[:master_amount] %> - <% visa += sale[:visa_amount] %> - <% jcb += sale[:jcb_amount] %> - <% paypar += sale[:paypar_amount] %> - <% cash += sale[:cash_amount] %> - <% credit += sale[:credit_amount] %> - <% foc += sale[:foc_amount] %> - <% discount += sale[:total_discount] %> - <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> - <% grand_total += sale[:grand_total].to_f %> - <% rounding_adj += sale[:rounding_adj].to_f %> - - - - - - - - - - - - - - - - - - <% count = count + 1 %> - <% end %> + + + + + + + +
+<% unless @sale_data.blank? %> -
- - - - - - - - - - - - - - +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateDaily Void AmountDaily mpu SalesDaily master SalesDaily visa SalesDaily jcb SalesDaily paypar SalesDaily Cash SalesDaily Credit SalesDaily FOC Sales(Daily Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
+ - <% total_tax = 0 %> - <% unless @tax.empty? %> - <% @tax.each do |tax| %> - <% total_tax += tax.tax_amount.to_f %> - - - - - - - <% end %> - <% net = total - total_tax %> - - - - - - <% end %> - + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + + + <% acc_arr = Array.new %> + <% cate_arr = Array.new %> + + <% sub_total = 0.0 %> + <% count = 0%> + <% total_price = 0.0 %> + <% cate_count = 0 %> + <% acc_count = 0%> + <% grand_total = 0%> + <% total_discount = 0.0 %> + + <% @sale_data.order("total_item desc").each do |sale| %> + + <% if !acc_arr.include?(sale.account_id) %> + + + + + + + <% acc_arr.push(sale.account_id) %> + + <% end %> + + + <% if !cate_arr.include?(sale.menu_category_id) %> + + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + <% end %> -
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
 Menu CategoryCodeProductTotal ItemUnit PriceRevenue
<%= sale.account_name %> Total Price By <%= sale.account_name %> + <% @totalByAccount.each do |account, total| %> + <% if sale.account_id == account %> + <%= total %> + <% end %> + <% end %> +
 <%= sale.menu_category_name %> 
-
-
\ No newline at end of file + <%= sale.code rescue '-' %> + <% if @item_table == 'sale' %> + <% if sale.item_remark == 'FOC' %> + <%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %> + <% elsif sale.item_remark == 'FOC ITEM' %> + <%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %> + <% elsif sale.item_remark == 'DISCOUNT' %> + <%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %> + <% else %> + <%= sale.product_name.to_s rescue '-' %> + <% end %> + <% if sale.item_remark == 'DISCOUNT' %> + - + - + <%= sale.total_price.abs rescue '-' %> + <% total_price += sale.total_price %> + <% else %> + <%= sale.total_item.abs rescue '-' %> + <%= sale.unit_price rescue '-' %> + <%= sale.grand_total.abs rescue '-' %> + <% end %> + <% else %> + <%= sale.product_name.to_s rescue '-' %> + <%= sale.total_item.abs rescue '-' %> + <%= sale.unit_price rescue '-' %> + <%= sale.grand_total.abs rescue '-' %> + <% end %> + + + + <% @menu_cate_count.each do |key,value| %> + <% if sale.menu_category_id == key %> + <% count = count + 1 %> + <% sub_total += sale.grand_total %> + <% if count == value %> + +   + Sub Total + <%= sub_total + total_price %> + + <% sub_total = 0.0%> + <% total_discount = total_discount + total_price %> + <% total_price = 0.0%> + <% count = 0%> + <% end %> + <% end %> + <% end %> + + <% grand_total += sale.grand_total%> + <% end %> + +   + Grand Total + <%= grand_total + total_discount %> + + + +<% end %> + + + \ No newline at end of file diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc189968..3859c754 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,3 +2,4 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf +Mime::Type.register 'application/vnd.ms-excel', :xls