From 48ce8e4809351947d9e28a0429f5d256a26aff19 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 18:12:59 +0630 Subject: [PATCH] split bill --- .../javascripts/origami/split_bill.coffee | 3 + .../stylesheets/origami/split_bill.scss | 3 + .../origami/split_bill_controller.rb | 7 + app/helpers/origami/split_bill_helper.rb | 2 + app/views/origami/home/show.html.erb | 44 +- app/views/origami/split_bill/index.html.erb | 780 ++++++++++++++++++ config/routes.rb | 2 + .../origami/split_bill_controller_spec.rb | 5 + .../helpers/origami/split_bill_helper_spec.rb | 15 + 9 files changed, 846 insertions(+), 15 deletions(-) create mode 100644 app/assets/javascripts/origami/split_bill.coffee create mode 100644 app/assets/stylesheets/origami/split_bill.scss create mode 100644 app/controllers/origami/split_bill_controller.rb create mode 100644 app/helpers/origami/split_bill_helper.rb create mode 100755 app/views/origami/split_bill/index.html.erb create mode 100644 spec/controllers/origami/split_bill_controller_spec.rb create mode 100644 spec/helpers/origami/split_bill_helper_spec.rb diff --git a/app/assets/javascripts/origami/split_bill.coffee b/app/assets/javascripts/origami/split_bill.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/split_bill.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/origami/split_bill.scss b/app/assets/stylesheets/origami/split_bill.scss new file mode 100644 index 00000000..343bce7f --- /dev/null +++ b/app/assets/stylesheets/origami/split_bill.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/split_bill controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb new file mode 100644 index 00000000..24ded975 --- /dev/null +++ b/app/controllers/origami/split_bill_controller.rb @@ -0,0 +1,7 @@ +class Origami::SplitBillController < BaseOrigamiController + + def index + dining_id = params[:dining_id] + @table = DiningFacility.find_by_id(dining_id) + end +end diff --git a/app/helpers/origami/split_bill_helper.rb b/app/helpers/origami/split_bill_helper.rb new file mode 100644 index 00000000..cc88e5b2 --- /dev/null +++ b/app/helpers/origami/split_bill_helper.rb @@ -0,0 +1,2 @@ +module Origami::SplitBillHelper +end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8440f354..4f81116d 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -670,22 +670,36 @@ // Bill Request $('#request_bills').click(function () { - var order_id = $('#save_order_id').attr('data-order'); - var ajax_url = "/origami/" + order_id + "/request_bills"; - $.ajax({ - type: "GET", - url: ajax_url, - // data: 'order_id='+ order_id, - success: function (result) { - - if (!result.status) { - swal("Information!", result.error_message); + swal({ + title: "Alert", + text: "Are you sure want to Split?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, split it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + var dining_id = "<%= @dining.id %>"; + window.location.href = '/origami/table/' + dining_id + "/split_bill"; + }else{ + var order_id = $('#save_order_id').attr('data-order'); + var ajax_url = "/origami/" + order_id + "/request_bills"; + $.ajax({ + type: "GET", + url: ajax_url, + // data: 'order_id='+ order_id, + success: function (result) { + if (!result.status) { + swal("Information!", result.error_message); + } + else { + location.reload(); + } } - else { - location.reload(); - } - } - }); + }); + } + }); }); $('#move').on('click', function () { diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb new file mode 100755 index 00000000..0691ca2c --- /dev/null +++ b/app/views/origami/split_bill/index.html.erb @@ -0,0 +1,780 @@ +
+ +
+ +
+ +
+ +
+
+
+ + +
+
+

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

+
+
+
+
+ + + + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% + sub_total += sale_item.qty*sale_item.unit_price + if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc" + %> + > + + + + + <% + end + end + %> + +
ItemsQTYPrice
+ + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+
+ +
+
+
+ + + +
+ +
+
+
Discount Control
+
+
+
+
+
+
+ +
+
+
+ <% + @accounts.each do |acc| + %> + + <% end %> +
+
+
+
+ +
+
+
+
+
+
+
5%
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
10%
+
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
15%
+
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
20%
+
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
30%
+
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+ + +
+ +
+ + + + + <% if @member_discount%> + + <%end %> +
+
+
+
+ + diff --git a/config/routes.rb b/config/routes.rb index 7d21aeb5..58fd5ffd 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -220,6 +220,8 @@ scope "(:locale)", locale: /en|mm/ do post "bank_integration/settle_trans", to: "bank_integration#settle_trans", as:"settle_trans" post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans" + #split bill + get 'table/:dining_id/split_bill' => 'split_bill#index', as:'split_bill_index' end #--------- Waiter/Ordering Station ------------# diff --git a/spec/controllers/origami/split_bill_controller_spec.rb b/spec/controllers/origami/split_bill_controller_spec.rb new file mode 100644 index 00000000..2ab33eb0 --- /dev/null +++ b/spec/controllers/origami/split_bill_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::SplitBillController, type: :controller do + +end diff --git a/spec/helpers/origami/split_bill_helper_spec.rb b/spec/helpers/origami/split_bill_helper_spec.rb new file mode 100644 index 00000000..db065ff0 --- /dev/null +++ b/spec/helpers/origami/split_bill_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Origami::SplitBillHelper. For example: +# +# describe Origami::SplitBillHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Origami::SplitBillHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end