diff --git a/README.md b/README.md index 4ba6d51f..146f216e 100755 --- a/README.md +++ b/README.md @@ -201,7 +201,8 @@ Add Feature for Order and Reservation => settings/lookups => { type:order_reservation, name: OrderReservation, value:'{0 or 1}' } For Price 0 in receipt bill - 2) settings/lookups => { type:show_price, name:Shoe Price, value:1 } + 2) settings/lookups => { type:show_price, name:Show Price, value:1 } + For Price 0 in receipt bill 2) settings/lookups => { type:order_by, name:Order By, value:name } diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index f6a43514..47a3703c 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -9,7 +9,7 @@ class Api::Restaurant::MenuController < Api::ApiController all_menu = Menu.all @request_url = '' if ENV["SERVER_MODE"] == "cloud" - @request_url = request.subdomain + "." + request.domain #local_url => 'http://0.0.0.0:3000' + @request_url = request.base_url end # to hash menu_array = [] diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 77f4589a..c7311fd6 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -161,11 +161,11 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts order_id - puts order_ids.count - puts order_id_count - puts order_items.count - puts order_item_count + # puts order_id + # puts order_ids.count + # puts order_id_count + # puts order_items.count + # puts order_item_count if !order_id.nil? if order_id_count > 1 @@ -181,8 +181,8 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts "updated_order_id" - puts updated_order_id + # puts "updated_order_id" + # puts updated_order_id if !updated_order_id.empty? order_ids.each do |odr_id| @@ -211,7 +211,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(odr_id).delete @@ -239,7 +239,7 @@ class Origami::SplitBillController < BaseOrigamiController end end else - puts "order_id_count < 1" + # puts "order_id_count < 1" new_order_status = true order_items.each do |order_item| orderItem = OrderItem.find(order_item["id"]) @@ -252,7 +252,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(order_id).delete @@ -379,20 +379,26 @@ class Origami::SplitBillController < BaseOrigamiController orderItem.set_menu_items = instance_item_sets.to_json end - OrderItem.processs_item(orderItem.item_code, - orderItem.item_instance_code, - orderItem.item_name, - orderItem.alt_name, - orderItem.account_id, - order_item['qty'], - orderItem.price, - orderItem.options, - set_menu_items_obj.to_json, - order_id, - orderItem.item_order_by, - orderItem.taxable) - - orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f + same_order = OrderItem.find_by_order_id(order_id) + if same_order.nil? + OrderItem.processs_item(orderItem.item_code, + orderItem.item_instance_code, + orderItem.item_name, + orderItem.alt_name, + orderItem.account_id, + order_item['qty'], + orderItem.price, + orderItem.options, + set_menu_items_obj.to_json, + order_id, + orderItem.item_order_by, + orderItem.taxable) + else + same_order.qty = same_order.qty.to_f + order_item['qty'].to_f + same_order.set_menu_items = set_menu_items_obj.to_json + same_order.save + end + orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f else orderItem.order_id = order_id end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 2e43da0b..19d5720a 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -27,7 +27,8 @@ authorize_resource :class => false payment_type = params[:payment_type] @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) - @tax_profiles = TaxProfile.where('group_type = "cashier"').order('order_by asc').limit(2) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) + @from = from @to = to # get printer info diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index be370371..2a823888 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -236,6 +236,155 @@ class Transactions::SalesController < ApplicationController redirect_to root_path end end + + def overall_void + sale_id = params[:sale_id] + remark = params[:remark] + order_source = params[:type] #tax profile source + access_code = params[:access_code] + 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) + end + + # update count for shift sale + if(sale.sale_status == "completed") + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.calculate(sale_id, "void") + end + else + # void before sale payment complete + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.total_void = shift.total_void + sale.grand_total + shift.save + end + end + + sale.rounding_adjustment = 0.0 + sale.payment_status = 'void' + sale.sale_status = 'void' + sale.save + + # No Need + # bookings = sale.bookings + # bookings.each do |booking| + # orders = booking.orders + # orders.each do |order| + # # order.status = 'void' + # end + # end + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_avaliable = true + table_count = 0 + table = sale.bookings[0].dining_facility + 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' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else + table_avaliable = false + table_count += 1 + end + end + end + + if table_avaliable && table_count == 0 + table.status = 'available' + table.save + end + else + table = nil + end + + # FOr Sale Audit + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" + sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" ) + + # For Print + + member_info = nil + rebate_amount = nil + current_balance = nil + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings.count > 1 + # for Multiple Booking + if bookings[0].dining_facility_id.to_i>0 + table = DiningFacility.find(bookings[0].dining_facility_id) + end + end + + if bookings[0].dining_facility_id.to_i > 0 + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + unique_code = "ReceiptBillPdf" + customer= Customer.find(sale.customer_id) + + #shop detail + shop_details = Shop.find(1) + # get member information + rebate = MembershipSetting.find_by_rebate(1) + if customer.membership_id != nil && rebate + member_info = Customer.get_member_account(customer) + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 + end + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + 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) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + + #end print + + # 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 + private # Use callbacks to share common setup or constraints between actions. diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index b6c48215..829e7252 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -5,16 +5,10 @@ class Transactions::SurveysController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - surveys = Survey.all + @surveys = Survey.all else - surveys = Survey.search(filter,from,to) + @surveys = Survey.search(filter,from,to) end - - if !surveys.nil? - @surveys = Kaminari.paginate_array(surveys).page(params[:page]).per(20) - else - @surveys = [] - end @filter = filter @from = from @@ -22,6 +16,7 @@ class Transactions::SurveysController < ApplicationController respond_to do |format| format.html # index.html.erb + format.xls format.json { render json: @surveys } end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 7ceecebd..24d3f81c 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -51,7 +51,7 @@ class Sale < ApplicationRecord if !charges.nil? block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at) dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s - create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time) + create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source) end return status, sale_id @@ -131,6 +131,7 @@ class Sale < ApplicationRecord if order_source.nil? order_source = order.source end + puts "compute source" compute(order_source) #Update the order items that is billed @@ -275,7 +276,7 @@ class Sale < ApplicationRecord end end - def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time) + def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time, order_source = nil) sale_item = SaleItem.new sale_item.product_code = chargeObj.item_code sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )" @@ -291,7 +292,7 @@ class Sale < ApplicationRecord # Re-calc sale = Sale.find(self.id) - self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount) + self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) end def update_item (item) @@ -506,6 +507,7 @@ class Sale < ApplicationRecord 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| diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 382633de..55b09668 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -187,6 +187,20 @@ class ReceiptBillA5Pdf < Prawn::Document def add_line_item_row(sale_items,precision,delimiter) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end + y_position = cursor move_down line_move sub_total = 0.0 @@ -194,7 +208,7 @@ class ReceiptBillA5Pdf < Prawn::Document sale_items.each do |item| # check for item not to show - show_price = Lookup.find_by_lookup_type("show_price").value + show_price = Lookup.find_by_lookup_type("show_price") sub_total += item.price #(item.qty*item.unit_price) - comment for room charges if item.status != 'Discount' && item.qty > 0 @@ -221,12 +235,15 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do - text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center - end - bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do - text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + # bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do + # text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center + # end + # bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do + # text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + # end + text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -632,5 +649,4 @@ class ReceiptBillA5Pdf < Prawn::Document end return status end -end - +end \ No newline at end of file diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 862a91a5..5f3cdc09 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -181,6 +181,20 @@ class ReceiptBillPdf < Prawn::Document def add_line_item_row(sale_items,precision,delimiter) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end + y_position = cursor move_down line_move sub_total = 0.0 @@ -215,12 +229,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do - text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center - end - bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do - text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -627,5 +637,4 @@ class ReceiptBillPdf < Prawn::Document end return status end -end - +end \ No newline at end of file diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index e1b88f85..5f24494f 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -759,30 +759,41 @@ return false; }); }); + // Print for first bill $("#first_bill").on('click', function () { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - var server_mode = - $.ajax({ - type: "GET", - url: ajax_url, - success: function (result) { - receipt_no = ($("#receipt_no").html()).trim(); - if((receipt_no!=undefined) && (receipt_no!="")) - createReceiptNoInFirstBillData(receipt_no,""); + swal({ + title: "Alert", + text: "Are you sure want to print First Bill?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, print it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + var server_mode = - // For Server Print - from jade - if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); - } - - // console.log(result); - // code2lab.printBill(result.filepath, result.printer_model, result.printer_url); - location.reload(); + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no,""); + + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + location.reload(); } - }); + }); + } + }); }); // click select option icon for add diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index bd06be3f..30a610d0 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -47,7 +47,7 @@ <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <% @tax_profiles.each do |tax| %> - <%= tax.name %> + <%= tax.name %> <% end %> <%= t("views.right_panel.detail.grand_total") %> @@ -89,20 +89,39 @@ <% total_sum += result.total_amount.to_f %> <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> - - - + + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %> - <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %> - <%if result.customer.customer_type == "Takeaway"%> - <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> - <%end%> - <% result.sale_taxes.each do |tax| %> - <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %> + + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <% end %> <%end%> <%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %> diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index ff74ef5a..ac955e73 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -59,17 +59,35 @@ <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= result.total_amount rescue '-' %> <%= result.total_discount rescue '-' %> - <%if result.customer.customer_type == "Takeaway"%> + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + 0 + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= tax.tax_payable_amount rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + 0 + <% end %> <%end%> <%= result.grand_total %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 049ca8c9..fd98e214 100755 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -1,4 +1,3 @@ -
-
- +
+ - - - + + + -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - <% @sale.sale_items.each do |s| %> - - - - - - - - - - <% end %> - - - - - - - - - - - <% @sale.sale_taxes.each do |r|%> - - - - - - <% end %> - - - - - - - - - - - - - <% @sale_receivables.each do |r|%> - - - - - - - <% end %> - - - - - - - - - -
<%= t("views.right_panel.detail.receipt_date") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %><%= t("views.right_panel.detail.sales_status") %><%= t("views.right_panel.detail.receipt_generated_at") %>
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %>
<%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %><%= t("views.right_panel.detail.remark") %>
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.unit_price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %><%=s.remark rescue ' '%>
<%= t("views.right_panel.detail.total") %><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.discount") %><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.tax_name %> <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.grand_total") %><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
<%= t("views.right_panel.detail.total_pay_amount") %><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.payment_method.capitalize rescue ' '%> Payment<%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> -
<%= t("views.right_panel.detail.change") %><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
- -
-
- -
-
- - - - - - - - - - - - - - - - <% @order_items.each do |order_item| %> - - - - - - - - - - - <% end %> - -
<%= t("views.right_panel.detail.order_id") %><%= t("views.right_panel.header.menu_item") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.option") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.waiter") %><%= t("views.right_panel.detail.created_at") %>
<%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y %I:%M %p") %>
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - <% if @customer.membership_id %> - - - - - - - - - - - - - - - <% - if @response["status"] == true %> - <% @response["data"].each do |transaction| %> - - - - - - - - - - - <% end %> - <% end %> - <% end %> - -
<%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.company") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %><%= t("views.right_panel.detail.nrc_passport_no") %><%= t("views.right_panel.detail.address") %><%= t("views.right_panel.detail.dob") %>
<%= @customer.card_no rescue '-'%><%= @customer.name %><%= @customer.company rescue '-' %><%= @customer.contact_no %><%= @customer.email %><%= @customer.nrc_no %><%= @customer.address%><%= @customer.date_of_birth %>
<%= t("views.right_panel.detail.membership_transactions") %>
<%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.redeem") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.balance") %><%= t("views.right_panel.detail.from_account") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.receipt_no") %>
<%= transaction["date"]%><%= transaction["redeem"]%><%= transaction["rebate"] %><%= transaction["balance"] %><%= transaction["account_status"] %><%= transaction["status"] %><%= transaction["receipt_no"] %>
-
-
- -
-
-
- - - - - - - - - - - - - <% @sale_audits.each do |audit| %> - - - - - - - - <% end %> - - -
<%= t("views.right_panel.detail.action") %><%= t("views.right_panel.detail.action_at") %><%= t("views.right_panel.detail.approved_at") %><%= t("views.right_panel.detail.remark") %>
<%= audit.action%><%= audit.action_at.strftime("%m-%d-%Y %H:%M %p")%><%= audit.approved_by%><%= audit.remark%>
-
-
+
+
+
+ + + + + + + + + <% if @sale["sale_status"] == "completed" %> + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + <% @sale.sale_taxes.each do |r|%> + + + + + + <% end %> + + + + + + + + + + + + <% @sale_receivables.each do |r|%> + + + + + + <% end %> + + + + + + +
<%= t("views.right_panel.detail.receipt_date") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %><%= t("views.right_panel.detail.sales_status") %><%= t("views.right_panel.detail.receipt_generated_at") %> + <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %>
<%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %><%= t("views.right_panel.detail.remark") %>
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.unit_price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %><%=s.remark rescue ' '%>
<%= t("views.right_panel.detail.total") %><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.discount") %><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.tax_name %> <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.grand_total") %><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
<%= t("views.right_panel.detail.total_pay_amount") %><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.payment_method.capitalize rescue ' '%> Payment<%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.change") %><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+
+
+
+ + + + + + + + + + + + + + + <% @order_items.each do |order_item| %> + + + + + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.order_id") %><%= t("views.right_panel.header.menu_item") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.option") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.waiter") %><%= t("views.right_panel.detail.created_at") %>
<%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y %I:%M %p") %>
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + <% if @customer.membership_id %> + + + + + + + + + + + + + + + <% if @response["status"] == true %> + <% @response["data"].each do |transaction| %> + + + + + + + + + + + <% end %> + <% end %> + <% end %> + +
<%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.company") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %><%= t("views.right_panel.detail.nrc_passport_no") %><%= t("views.right_panel.detail.address") %><%= t("views.right_panel.detail.dob") %>
<%= @customer.card_no rescue '-'%><%= @customer.name %><%= @customer.company rescue '-' %><%= @customer.contact_no %><%= @customer.email %><%= @customer.nrc_no %><%= @customer.address%><%= @customer.date_of_birth %>
<%= t("views.right_panel.detail.membership_transactions") %>
<%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.redeem") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.balance") %><%= t("views.right_panel.detail.from_account") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.receipt_no") %>
<%= transaction["date"]%><%= transaction["redeem"]%><%= transaction["rebate"] %><%= transaction["balance"] %><%= transaction["account_status"] %><%= transaction["status"] %><%= transaction["receipt_no"] %>
+
+
+ +
+
+
+ + + + + + + + + + + <% @sale_audits.each do |audit| %> + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.action") %><%= t("views.right_panel.detail.action_at") %><%= t("views.right_panel.detail.approved_at") %><%= t("views.right_panel.detail.remark") %>
<%= audit.action%><%= audit.action_at.strftime("%m-%d-%Y %H:%M %p")%><%= audit.approved_by%><%= audit.remark%>
+
+
- - +
+ + + + + diff --git a/app/views/transactions/surveys/_survey_report_filter.html.erb b/app/views/transactions/surveys/_survey_report_filter.html.erb new file mode 100644 index 00000000..78a988b9 --- /dev/null +++ b/app/views/transactions/surveys/_survey_report_filter.html.erb @@ -0,0 +1,41 @@ +<%= form_tag transactions_surveys_path, :method => :get, :id=>"frm_report", :class => "form" do %> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+<% end %> + \ No newline at end of file diff --git a/app/views/transactions/surveys/index.html.erb b/app/views/transactions/surveys/index.html.erb index 7e750faa..a57d724f 100644 --- a/app/views/transactions/surveys/index.html.erb +++ b/app/views/transactions/surveys/index.html.erb @@ -10,29 +10,15 @@
- <%= form_tag transactions_surveys_path, :method => :get do %> -
-
- - -
+ <%= render :partial=>'survey_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>transactions_surveys_path} %> -
- - -
+
+ + -
- - -
- -
- -
-
-
- <% end %>
@@ -107,12 +93,15 @@

- <%if !@orders.nil?%> - <%= paginate @surveys %> - <%end%>
+ \ No newline at end of file diff --git a/app/views/transactions/surveys/index.xls.erb b/app/views/transactions/surveys/index.xls.erb new file mode 100644 index 00000000..3e31ad12 --- /dev/null +++ b/app/views/transactions/surveys/index.xls.erb @@ -0,0 +1,86 @@ +
+
+
+
+
+ + + + + + + + + + + + + + + <% total_child = 0 %> + <% total_adult = 0 %> + <% total_male = 0 %> + <% total_female = 0 %> + <% total_local = 0 %> + <% total_customer = 0 %> + <% total_foreigner = 0 %> + <% if !@surveys.nil? %> + <% @surveys.each do |survey| %> + <% total_child = total_child.to_i + survey.child.to_i %> + <% total_adult = total_adult.to_i + survey.adult.to_i %> + <% total_male = total_male.to_i + survey.male.to_i %> + <% total_female = total_female.to_i + survey.female.to_i %> + <% total_local = total_local.to_i + survey.local.to_i %> + <% total_customer = total_customer.to_i + survey.total_customer.to_i %> + + + + + + + + + + + + + <% end %> + <% end %> + + + + + + + + + + + +
<%= t("views.right_panel.detail.dining") %><%= t("views.right_panel.detail.receipt_no") %><%= t("views.right_panel.detail.created_by") %><%= t("views.right_panel.detail.child") %><%= t("views.right_panel.detail.adult") %><%= t("views.right_panel.detail.male") %><%= t("views.right_panel.detail.female") %><%= t("views.right_panel.detail.total") %> <%= t :customer %> + <%= t("views.right_panel.detail.local") %><%= t("views.right_panel.detail.foreigner") %>
<%= survey.dining_name rescue ' '%><%= survey.receipt_no rescue '-'%><%= survey.created_by rescue ' '%><%= survey.child rescue ' '%><%= survey.adult rescue ' '%><%= survey.male rescue ' '%><%= survey.female rescue ' '%><%= survey.total_customer rescue ' '%><%= survey.local rescue ' '%> + <% if !survey.foreigner.nil? %> + <% JSON.parse(survey.foreigner).each do |foreign| %> + <% foreigner_lists = foreign.split(",") %> + <% if !foreigner_lists.empty? %> + <% foreigner_lists.each do |fgn| %> + <% unless fgn.match(/[^[:digit:]]+/) + total_foreigner = total_foreigner.to_i + fgn.to_i + end %> + <% if !fgn.scan(/\D/).empty? %> + <%= fgn %> :<% end %> <%= fgn.to_i unless fgn.match(/[^[:digit:]]+/) %>
+ <% end %> + <% end %> + <% end %> + <% end %> +
<%= t("views.right_panel.detail.total") %><%= total_child %><%= total_adult %><%= total_male %><%= total_female %><%= total_customer %><%= total_local %><%= total_foreigner %>
+
+ <%if !@orders.nil?%> + <%= paginate @surveys %> + <%end%> +
+
+
+ +
+
diff --git a/config/routes.rb b/config/routes.rb index 77e26bbb..7f776da0 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -431,6 +431,7 @@ scope "(:locale)", locale: /en|mm/ do get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale" get "/sales/:sale_id/void" => "manual_sales#void", :as => "void" post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale" + post "sales/:sale_id/:type/void" => "sales#overall_void" end #--------- Reports Controller Sections ------------#