diff --git a/Gemfile b/Gemfile index 4ca47865..c20dec66 100755 --- a/Gemfile +++ b/Gemfile @@ -46,8 +46,11 @@ gem 'mini_magick' gem 'cups' gem 'prawn' gem 'prawn-table' -gem 'spreadsheet' gem 'to_xls-rails' +gem 'rubyzip', '= 1.0.0' +gem 'axlsx', '= 2.0.1' +gem 'axlsx_rails' +gem 'roo' #Reporting gem #gem 'compendium' #gem "cancan" diff --git a/Gemfile.lock b/Gemfile.lock index 1c7e6534..254ff760 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,13 @@ GEM airbrussh (1.3.0) sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) + axlsx (2.0.1) + htmlentities (~> 4.3.1) + nokogiri (>= 1.4.1) + rubyzip (~> 1.0.0) + axlsx_rails (0.5.1) + actionpack (>= 3.1) + axlsx (>= 2.0.1) bcrypt (3.1.11) bindex (0.5.0) builder (3.2.3) @@ -100,6 +107,7 @@ GEM railties (>= 3.2, < 5.2) globalid (0.4.1) activesupport (>= 4.2.0) + htmlentities (4.3.4) httparty (0.15.6) multi_xml (>= 0.5.2) i18n (0.9.1) @@ -197,6 +205,10 @@ GEM rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.5) + roo (1.13.2) + nokogiri + rubyzip + spreadsheet (> 0.6.4) rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -215,6 +227,7 @@ GEM rspec-support (~> 3.7.0) rspec-support (3.7.0) ruby-ole (1.2.12.1) + rubyzip (1.0.0) sass (3.5.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -286,6 +299,8 @@ PLATFORMS DEPENDENCIES aescrypt + axlsx (= 2.0.1) + axlsx_rails bcrypt (~> 3.1.7) byebug cancancan (~> 1.10) @@ -320,13 +335,14 @@ DEPENDENCIES rack-cors rails (~> 5.1.0) redis (~> 3.0) + roo rspec-rails (~> 3.5) + rubyzip (= 1.0.0) sass-rails (~> 5.0) schema_to_scaffold shoulda-matchers (~> 3.1) sidekiq simple_form - spreadsheet spring spring-watcher-listen (~> 2.0.0) tether-rails diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index f6365db0..d3723026 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -196,7 +196,7 @@ $(function() { +add+ '' +'' +'' - +"
booking.booking_id, :order => self}) #Send order to queue one it done! - if self.source != "quick_service" + # if self.source != "quick_service" process_order_queue - end + # end #send order to broadcast job send_order_broadcast(booking) @@ -297,7 +297,7 @@ class Order < ApplicationRecord else if order oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id) + oqs.process_order(order, self.table_id, self.source) end assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) ActionCable.server.broadcast "order_queue_station_channel",order: assign_order @@ -313,7 +313,7 @@ class Order < ApplicationRecord else if order oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id) + oqs.process_order(order, self.table_id, self.source) end assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) ActionCable.server.broadcast "order_queue_station_channel",order: assign_order @@ -326,7 +326,7 @@ class Order < ApplicationRecord else if order oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id) + oqs.process_order(order, self.table_id, self.source) end assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) ActionCable.server.broadcast "order_queue_station_channel",order: assign_order diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index af544ce5..889491ed 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -13,7 +13,7 @@ class OrderQueueStation < ApplicationRecord # validations validates_presence_of :station_name, :printer_name - def process_order (order, table_id) + def process_order (order, table_id, order_source = nil) oqs_stations = OrderQueueStation.active @@ -55,7 +55,7 @@ class OrderQueueStation < ApplicationRecord end end - if oqs.auto_print + if oqs.auto_print && order_source != "quick_service" if oqs_order_items.length > 0 print_slip(oqs, order, oqs_order_items) is_auto_printed = true @@ -90,7 +90,81 @@ class OrderQueueStation < ApplicationRecord end end - if oqs.auto_print + if oqs.auto_print && order_source != "quick_service" + if oqs_order_items.length > 0 + print_slip(oqs, order, oqs_order_items) + is_auto_printed = true + end + end + end + end + end #end else + end + + def pay_process_order_queue (order_id, table_id) + + oqs_stations = OrderQueueStation.active + + order = Order.find(order_id) + order_items = order.order_items + + if table_id.to_i > 0 + # get dining + dining = DiningFacility.find(table_id) + oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}") + booking = Booking.find_by_dining_facility_id(dining.id) + + # ToDo per item per printer + + oqs_by_zones.each do |oqpbz| + oqs = OrderQueueStation.find(oqpbz.order_queue_station_id) + is_auto_printed = false + oqs_order_items = [] + + if oqs.is_active + #Get List of items - + pq_items = JSON.parse(oqs.processing_items) + #Loop through the processing items + pq_items.each do |pq_item| + #Processing through the looping items + order_items.each do |order_item| + if (pq_item == order_item.item_code) + if (order_item.qty > 0) + oqs_order_items.push(order_item) + end + end + end + end + + if oqs.auto_print + if oqs_order_items.length > 0 + print_slip(oqs, order, oqs_order_items) + is_auto_printed = true + end + end + end + end + else + oqs_stations.each do |oqs| + is_auto_printed = false + oqs_order_items = [] + + if oqs.is_active + #Get List of items - + pq_items = JSON.parse(oqs.processing_items) + #Loop through the processing items + pq_items.each do |pq_item| + #Processing through the looping items + order_items.each do |order_item| + if (pq_item == order_item.item_code) + if (order_item.qty > 0) + oqs_order_items.push(order_item) + end + end + end + end + + if oqs.auto_print if oqs_order_items.length > 0 print_slip(oqs, order, oqs_order_items) is_auto_printed = true diff --git a/app/models/sale.rb b/app/models/sale.rb index 5d46aafc..11ddd296 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -26,7 +26,7 @@ class Sale < ApplicationRecord SALE_STATUS_OUTSTANDING = "outstanding" SALE_STATUS_COMPLETED = "completed" - def generate_invoice_from_booking(booking_id, requested_by, cashier) + def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil) booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -36,9 +36,9 @@ class Sale < ApplicationRecord booking.booking_orders.each do |order| if booking.sale_id - status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier) + status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier, order_source) else - status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier) + status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier, order_source) end booking.sale_id = sale_id end @@ -58,7 +58,7 @@ class Sale < ApplicationRecord end end - def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil) + def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil, order_source = nil) taxable = true #if sale_id is exsit and validate #add order to that invoice @@ -128,7 +128,7 @@ class Sale < ApplicationRecord self.save! #compute sales summary - compute + compute(order_source) #Update the order items that is billed order.update_items_status_to_billed(nil) @@ -172,7 +172,7 @@ class Sale < ApplicationRecord # Create Sale if it doesn't exist # puts "current_login_employee" # puts current_login_employee.name - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user) + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user,order.source) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) else @@ -310,7 +310,7 @@ class Sale < ApplicationRecord end #compute - invoice total - def compute + def compute(order_source = nil) sales_items = self.sale_items #Computation Fields @@ -329,7 +329,7 @@ class Sale < ApplicationRecord # total_taxable = total_taxable + (item.taxable_price * item.qty) end - apply_tax (total_taxable) + apply_tax(total_taxable, order_source) self.total_amount = subtotal_price self.total_discount = total_discount @@ -342,7 +342,7 @@ class Sale < ApplicationRecord end #compute - invoice total - def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil) + def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil) sale = Sale.find(sale_id) sales_items = sale_itemss @@ -362,7 +362,7 @@ class Sale < ApplicationRecord end end - compute_tax(sale, total_taxable, total_discount) + compute_tax(sale, total_taxable, total_discount, order_source) sale.total_amount = subtotal_price sale.total_discount = total_discount sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax @@ -376,7 +376,7 @@ class Sale < ApplicationRecord end # No Use too many wrong - def compute_without_void + def compute_without_void(order_source = nil) sales_items = self.sale_items #Computation Fields @@ -396,7 +396,7 @@ class Sale < ApplicationRecord end end - apply_tax (total_taxable) + apply_tax(total_taxable, order_source) self.total_amount = subtotal_price self.total_discount = total_discount self.grand_total = (self.total_amount - self.total_discount) + self.total_tax @@ -407,7 +407,7 @@ class Sale < ApplicationRecord end # Tax Re-Calculte - def compute_tax(sale, total_taxable, total_discount = 0) + def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil) shop = Shop.first(); #if tax is not apply create new record @@ -423,8 +423,9 @@ class Sale < ApplicationRecord # #Creat new tax records if sale.payment_status != 'foc' tax_profiles.each do |tax| - customer.tax_profiles.each do |cus_tax| - if cus_tax.to_i == tax.id + # customer.tax_profiles.each do |cus_tax| + # if cus_tax.to_i == tax.id + if tax.group_type.to_s == order_source.to_s sale_tax = SaleTax.new(:sale => sale) sale_tax.tax_name = tax.name sale_tax.tax_rate = tax.rate @@ -447,15 +448,16 @@ class Sale < ApplicationRecord sale_tax.inclusive = tax.inclusive sale_tax.save - end end + # end + # end end end sale.total_tax = total_tax_amount end # Tax Calculate - def apply_tax(total_taxable) + def apply_tax(total_taxable, order_source = nil) shop = Shop.first(); #if tax is not apply create new record @@ -469,11 +471,14 @@ class Sale < ApplicationRecord tax_profiles = TaxProfile.all.order("order_by asc") customer = Customer.find(self.customer_id) - + if order_source.to_s == "emenu" + order_source = "cashier" + end #Create new tax records tax_profiles.each do |tax| - customer.tax_profiles.each do |cus_tax| - if cus_tax.to_i == tax.id + # customer.tax_profiles.each do |cus_tax| + # if cus_tax.to_i == tax.id + if tax.group_type.to_s == order_source.to_s sale_tax = SaleTax.new(:sale => self) sale_tax.tax_name = tax.name sale_tax.tax_rate = tax.rate @@ -497,8 +502,9 @@ class Sale < ApplicationRecord sale_tax.inclusive = tax.inclusive sale_tax.save - end end + # end + # end end self.total_tax = total_tax_amount end @@ -1963,7 +1969,7 @@ end end # Re-compute for add - saleobj.compute + saleobj.compute(order.source) saleobj.save order.save booking.save @@ -1993,7 +1999,7 @@ end end # Re-compute for add - saleobj.compute + saleobj.compute(order.source) saleobj.save order.save booking.save diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index b82cbf18..91a4db1e 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -325,6 +325,7 @@ class SalePayment < ApplicationRecord sObj = Sale.find(self.sale_id) is_credit = 0 is_foc = 0 + is_cash = false sObj.sale_payments.each do |spay| all_received_amount += spay.payment_amount.to_f if spay.payment_method == "creditnote" @@ -333,8 +334,12 @@ class SalePayment < ApplicationRecord if spay.payment_method == "foc" is_foc = 1 end + if spay.payment_method.to_s == "cash" + is_cash = true + end end - if (self.sale.grand_total <= all_received_amount) + + if (self.sale.grand_total <= all_received_amount) && is_cash if is_credit == 0 self.sale.payment_status = "paid" else @@ -374,11 +379,15 @@ class SalePayment < ApplicationRecord end self.sale.save! - table_update_status(sObj) if check_foc + table_update_status(sObj) update_shift elsif paid_amount.to_f > 0 #|| paid_amount != "0.0" + table_update_status(sObj) + update_shift + elsif is_cash && paid_amount.to_f == 0 + table_update_status(sObj) update_shift end end diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb index 7a1eebab..70e9a0ff 100644 --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -144,9 +144,12 @@ $(document).ready(function(){ }); $('#back').on('click', function () { + var booking_id = '<%= @booking.booking_id %>'; <% if !@link_type.nil? %> <% if @link_type == 'oqs' %> window.location.href = '/oqs'; + <% elsif @link_type == 'pending' %> + window.location.href = '/origami/quick_service/pending_order/'+booking_id; <% else %> <% if !@dining_type.nil? %> <% if @dining_type == 'Table' %> diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index d36a6715..eda3524a 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -913,7 +913,7 @@ }, function (isConfirm) { if (isConfirm) { var sale_id = "<%= @obj_sale.sale_id rescue "" %>" - var ajax_url = "/origami/sale/" + sale_id + '/void'; + var ajax_url = "/origami/sale/" + sale_id + '/cashier/void'; var remark = $("#remark").val(); $.ajax({ diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 415a3ba2..1d25c5c4 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -705,7 +705,7 @@ var customer_name = "<%= @customer.name %>"; if (isConfirm) { var sale_id = $('#sale_id').text(); var remark = $("#remark").val(); - var ajax_url = "/origami/sale/" + sale_id + '/void'; + var ajax_url = "/origami/sale/" + sale_id +'/'+cashier_type+ '/void'; $.ajax({ type: 'POST', url: ajax_url, @@ -913,7 +913,7 @@ var customer_name = "<%= @customer.name %>"; if (isConfirm) { $.ajax({ type: "POST", - url: "<%= origami_payment_foc_path %>", + url: "/origami/payment/"+cashier_type+"/foc", data: params, success:function(result){ customer_display_view(null,"reload"); diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb old mode 100755 new mode 100644 diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index a7ade0a4..19750c4d 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -97,13 +97,15 @@ <% end%> <% else%> <% sub_total = 0 + total = 0 @order_items.each do |order_item| - sub_total = sub_total + order_item.price %> + total = order_item.qty * order_item.price + sub_total = sub_total + total %> <%= order_item.item_name %> <%= order_item.qty %> - <%= order_item.price %> + <%= total %> <% end%> <% end%> @@ -210,7 +212,7 @@ $(document).ready(function(){ swal("Information!", result.error_message); } else { - location.reload(); + window.location.href = '/origami/quick_service/pending_order'; } } }); diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index d98a3fe2..758a5273 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -889,7 +889,7 @@ $('#add_invoice').on('click',function(){ var sure = confirm("Are you sure want to Void"); if (sure == true) { var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + '/void'; + var ajax_url = "/origami/sale/" + sale_id + '/cashier/void'; $.ajax({ type: 'POST', url: ajax_url, diff --git a/app/views/origami/sale_edit/edit.html.erb b/app/views/origami/sale_edit/edit.html.erb index 745286d3..ff203657 100755 --- a/app/views/origami/sale_edit/edit.html.erb +++ b/app/views/origami/sale_edit/edit.html.erb @@ -331,7 +331,7 @@ var cashier_type = "<%= @cashier_type %>"; $.ajax({ type: "POST", url: ajax_url, - data: 'sale_id=' + sale_id, + data: 'sale_id=' + sale_id +'&type='+cashier_type, success: function (result) { location.reload(); } @@ -345,7 +345,7 @@ var cashier_type = "<%= @cashier_type %>"; $.ajax({ type: "POST", url: ajax_url, - data: 'sale_id=' + sale_id, + data: 'sale_id=' + sale_id+'&type='+cashier_type, success: function (result) { if (cashier_type=="quick_service") { window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/'; diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index 515973f1..216e5eea 100644 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -261,7 +261,7 @@ $('#void').on('click',function () { if (isConfirm) { var sale_id = $('#sale_id').val(); var remark = $("#remark").val(); - var ajax_url = "/origami/sale/" + sale_id + '/void'; + var ajax_url = "/origami/sale/" + sale_id + '/cashier/void'; $.ajax({ type: 'POST', url: ajax_url, @@ -291,7 +291,7 @@ $('#foc').click(function() { if ($(this).attr('active')=== "true") { $.ajax({ type: "POST", - url: "<%= origami_payment_foc_path %>", + url: "/origami/payment/cashier/foc", data: params, success:function(result){ if (cash >= 0) { diff --git a/app/views/settings/menus/index.html.erb b/app/views/settings/menus/index.html.erb index ed215031..11ae575f 100755 --- a/app/views/settings/menus/index.html.erb +++ b/app/views/settings/menus/index.html.erb @@ -7,11 +7,12 @@
- +<%end%> +<%= link_to "Export users as spreadsheet", settings_menus_path(format: "xlsx") %>


diff --git a/app/views/settings/menus/index.xlsx.axlsx b/app/views/settings/menus/index.xlsx.axlsx new file mode 100644 index 00000000..977e9782 --- /dev/null +++ b/app/views/settings/menus/index.xlsx.axlsx @@ -0,0 +1,86 @@ +wb = xlsx_package.workbook +wb.styles do |s| + date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER) + wrap_text = s.add_style :sz => 11, + :alignment => { :horizontal => :left,:vertical => :center , + :wrap_text => true} + header_text = s.add_style :fg_color=> "FFFFFF", + :b => true, + :bg_color => "004586", + :sz => 12, + :border => { :style => :thin, :color => "00" }, + :alignment => { :horizontal => :left, + :vertical => :center , + :header_text => true} + + wb.add_worksheet(name: "Menu") do |sheet| + sheet.add_row %w( name is_active valid_days valid_time_from valid_time_to created_by ), :style=>header_text + @settings_menus.each do |menu| + sheet.add_row [ menu.name, menu.is_active, menu.valid_days, menu.valid_time_from,menu.valid_time_to, menu.created_by], :style=>[date,wrap_text] + end + end + + wb.add_worksheet(name: "Menu Category") do |sheet| + sheet.add_row %w(menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at), :style=>header_text + MenuCategory.all.each do |mc| + sheet.add_row [mc.menu_id, mc.code, mc.name, mc.alt_name, mc.order_by, mc.created_by, mc.menu_category_id, mc.is_available, mc.created_at, mc.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Menu Item") do |sheet| + sheet.add_row %w(item_code name alt_name image_path description information unit type menu_category_id item_attributes item_options account_id _qty taxable is_sub_item is_available created_by created_at updated_at), :style=>header_text + MenuItem.all.each do |mi| + sheet.add_row [mi.item_code, mi.name, mi.alt_name, mi.image_path, mi.description, mi.information, mi.unit, mi.type, mi.menu_category_id, mi.item_attributes, mi.item_options, mi.account_id, mi.min_qty, mi.taxable, mi.is_sub_item, mi.is_available, mi.created_by, mi.created_at, mi.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Menu Item Instance") do |sheet| + sheet.add_row %w(menu_item_id item_instance_code item_instance_name item_attributes price is_on_promotion promotion_price is_available is_default created_at updated_at), :style=>header_text + MenuItemInstance.all.each do |mii| + sheet.add_row [mii.menu_item_id, mii.item_instance_code, mii.item_instance_name, mii.item_attributes, mii.price, mii.is_on_promotion, mii.promotion_price, mii.is_available, mii.is_default, mii.created_at, mii.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Menu Options") do |sheet| + sheet.add_row %w(option_type name value created_at updated_at), :style=>header_text + MenuItemOption.all.each do |option| + sheet.add_row [option.option_type, option.name, option.value, option.created_at, option.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Item Attributes") do |sheet| + sheet.add_row %w(attribute_type name value created_at updated_at), :style=>header_text + MenuItemAttribute.all.each do |attr| + sheet.add_row [ attr.attribute_type,attr.name,attr.value,attr.created_at,attr.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Account") do |sheet| + sheet.add_row %w(title account_type discount point bonus rebate created_at updated_at), :style=>header_text + Account.all.each do |acc| + sheet.add_row [acc.title,acc.account_type,acc.discount,acc.point,acc.bonus,acc.rebate,acc.created_at,acc.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Item Set") do |sheet| + sheet.add_row %w(name alt_name min_selectable_qty max_selectable_qty created_at updated_at), :style=>header_text + ItemSet.all.each do |set| + sheet.add_row [set.name, set.alt_name, set.min_selectable_qty, set.max_selectable_qty, set.created_at, set.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Menu Instance Item Set") do |sheet| + sheet.add_row %w(item_set_id menu_item_instance_id created_at updated_at), :style=>header_text + MenuInstanceItemSet.all.each do |miis| + sheet.add_row [miis.item_set_id, miis.menu_item_instance_id, miis.created_at, miis.updated_at], :style=>wrap_text + end + end + + wb.add_worksheet(name: "Menu Item Set") do |sheet| + sheet.add_row %w(item_set_id menu_item_id created_at updated_at), :style=>header_text + MenuItemSet.all.each do |mis| + sheet.add_row [mis.item_set_id, mis.menu_item_id, mis.created_at, mis.updated_at], :style=>wrap_text + end + end + +end diff --git a/config/application.rb b/config/application.rb index e9a4e634..0e75d195 100755 --- a/config/application.rb +++ b/config/application.rb @@ -2,6 +2,7 @@ require_relative 'boot' require 'csv' require 'rails/all' +# require 'iconv' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 3859c754..3e0fb279 100755 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -3,3 +3,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 +Mime::Type.register "application/xlsx", :xlsx diff --git a/config/routes.rb b/config/routes.rb index d3921f13..e8c33e34 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -170,7 +170,7 @@ scope "(:locale)", locale: /en|mm/ do get 'sale/:sale_id/:type/payment' => 'payments#show' post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt - post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'} + post 'payment/:type/foc' => 'payments#foc', :defaults => {:format => 'json'} post 'payment/cash' => 'payments#create' post 'payment/mpu' => "mpu#create" post 'payment/jcb' => "jcb#create" @@ -194,7 +194,7 @@ scope "(:locale)", locale: /en|mm/ do get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index" #---------Void --------------# - post 'sale/:sale_id/void' => 'void#overall_void' + post 'sale/:sale_id/:type/void' => 'void#overall_void' #---------Multiple Invoices --------------# get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index" diff --git a/out.xls b/out.xls new file mode 100644 index 00000000..ffe4b922 Binary files /dev/null and b/out.xls differ