diff --git a/Gemfile b/Gemfile index 22275707..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -# gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index d6588a94..3606dadc 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -130,6 +130,11 @@ text-align: right; } +.item-attr-edit{ + width: 10%; + text-align: left; +} + .display-none{ display: none; } diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 00abc9aa..0119953f 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -11,7 +11,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - + rebate_amount = nil unique_code = "ReceiptBillPdf" @@ -53,7 +53,8 @@ class Origami::PaymentsController < BaseOrigamiController response["data"].each do |res| if res["accountable_type"] == "RebateAccount" @balance = res["balance"] - @accountable_type = res["accountable_type"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" end end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb new file mode 100644 index 00000000..93e98d03 --- /dev/null +++ b/app/controllers/origami/sale_edit_controller.rb @@ -0,0 +1,8 @@ +class Origami::SaleEditController < BaseOrigamiController + + def edit + sale_id = params[:sale_id] + @table_id = params[:table_id] + @saleobj = Sale.find(sale_id) + end +end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index f8cb639c..0e10307b 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -20,8 +20,6 @@ class DiningFacility < ApplicationRecord def get_booking booking = self.get_current_booking - puts "is bookig?" - puts booking if booking if booking.dining_facility_id.to_i == self.id if booking.booking_status == 'assign' diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index f118506c..73f298ec 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -272,17 +272,19 @@ <% if @dining.bookings.length >= 1 %> - + <% if @status_order == 'order' && @status_sale != 'sale' %> - + + <% else %> - + + @@ -416,35 +418,41 @@ $('#add_invoice').on('click',function(){ //show cusotmer rebate amount function show_customer_details(customer_id){ var url = '<%= @show_customer_details_path %>' + //Start Ajax + $.ajax({ + type: "GET", + url: url, + data: {}, + dataType: "json", + success: function(data) { + $("#customer_name").text(data["customer"].name); + if (data["response_data"]["data"].length) { + $.each(data["response_data"]["data"], function (i) { + if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ + var balance = data["response_data"]["data"][i]["balance"]; + if (data["response_data"]["status"]==true) { + $('.rebate_amount').removeClass('hide'); + row = + '' + "Rebate Balance" +'' + +'' + balance + ''; - //Start Ajax - $.ajax({ - type: "GET", - url: url, - data: {}, - dataType: "json", - success: function(data) { - $("#customer_name").text(data["customer"].name); - if (data["response_data"]["data"].length) { - $.each(data["response_data"]["data"], function (i) { - if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ - var balance = data["response_data"]["data"][i]["balance"]; - if (data["response_data"]["status"]==true) { - $('.rebate_amount').removeClass('hide'); - row = - '' + "Rebate Balance" +'' - +'' + balance + ''; - - $(".rebate_amount").html(row); - } - + $(".rebate_amount").html(row); } - }); - }else{ - $('.rebate_amount').addClass('hide'); + } - } - }); - //End Ajax - } + }); + }else{ + $('.rebate_amount').addClass('hide'); + } + } + }); + //End Ajax +} + +$('#edit').on('click',function(){ + var dining_id = "<%= @dining.id %>" + var sale_id = "<%= @obj_sale.sale_id rescue "" %>" + window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit"; +}) + diff --git a/app/views/origami/sale_edit/edit.html.erb b/app/views/origami/sale_edit/edit.html.erb new file mode 100644 index 00000000..f04561e0 --- /dev/null +++ b/app/views/origami/sale_edit/edit.html.erb @@ -0,0 +1,120 @@ +
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @saleobj.receipt_no rescue '' %> +

+
+
+

Date: <%= @saleobj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + + <% + count = 0 + sub_total = 0 + @saleobj.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + + <% + end + end + %> + +
#ItemsQTY + Price + Action
<%= count %><%= sale_item.product_name %> +
+
+ +
+
+
+ + +
+ + +
+
+ diff --git a/config/routes.rb b/config/routes.rb index 986e99c3..c93beb92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,7 +76,7 @@ Rails.application.routes.draw do resources :customers #add customer type end post 'moving' => "movetable#moving" - + get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit" get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'sale/:sale_id' => 'sales#show'