diff --git a/Gemfile b/Gemfile index 09e358f5..9b04d035 100644 --- a/Gemfile +++ b/Gemfile @@ -10,10 +10,10 @@ end gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -gem 'mysql2', '>= 0.3.18', '< 0.5' +# gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL - # gem 'pg' + gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 70197025..1f48bd93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -117,11 +117,11 @@ GEM minitest (5.10.2) multi_json (1.12.1) multi_xml (0.6.0) - mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -255,7 +255,7 @@ DEPENDENCIES jquery-rails kaminari! listen (~> 3.0.5) - mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) diff --git a/app/assets/javascripts/api/origami/paypar.coffee b/app/assets/javascripts/api/origami/paypar.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/api/origami/paypar.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/javascripts/origami/paypar.coffee b/app/assets/javascripts/origami/paypar.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/paypar.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/api/origami/paypar.scss b/app/assets/stylesheets/api/origami/paypar.scss new file mode 100644 index 00000000..3ce106bb --- /dev/null +++ b/app/assets/stylesheets/api/origami/paypar.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the api/origami/paypar controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/orgiami.scss b/app/assets/stylesheets/orgiami.scss index 327c5897..afefe4c7 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -29,3 +29,11 @@ .purple { background-color:#7a62d3; } + +.red { + background-color:#ff0000; +} + +.green{ + background-color: #009900 +} diff --git a/app/assets/stylesheets/origami/paypar.scss b/app/assets/stylesheets/origami/paypar.scss new file mode 100644 index 00000000..8cc055f3 --- /dev/null +++ b/app/assets/stylesheets/origami/paypar.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/paypar 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/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb new file mode 100644 index 00000000..1542734a --- /dev/null +++ b/app/controllers/origami/others_payments_controller.rb @@ -0,0 +1,27 @@ +class Origami::OthersPaymentsController < BaseOrigamiController + + + def index + @membership_rebate_balance = 0 + @membership_id = 0 + if !@membership_id.nil? + membership_setting = MembershipSetting.find_by_membership_type("smartpay_url") + membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id) + if membership_data["status"]==true + membership_account_data = membership_data["data"]; + membership_account_data.each do |acc_data| + if acc_data["accountable_type"] == "REBATEACCOUNT" + @membership_rebate_balance=acc_data["balance"] + else + @membership_rebate_balance = 0 + end + end + else + @membership_rebate_balance = 0 + end + end + + def create + end + +end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f64e27e3..bac414ad 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -5,13 +5,20 @@ class Origami::PaymentsController < BaseOrigamiController end def create - #payment type - #sale status - #point - get [ food amount ] + cash = params[:cash] + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + sale_payment.process_payment(saleObj, @user, cash) + end end def show - + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find_by_sale_id(sale_id) + end end end diff --git a/app/controllers/origami/paypar_controller.rb b/app/controllers/origami/paypar_controller.rb new file mode 100644 index 00000000..428cbc87 --- /dev/null +++ b/app/controllers/origami/paypar_controller.rb @@ -0,0 +1,3 @@ +class Origami::PayparController < ApplicationController + +end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 31766599..9ccce028 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,6 +1,6 @@ class Origami::RequestBillsController < BaseOrigamiController - def create + def show @sale = Sale.new @@ -25,13 +25,5 @@ class Origami::RequestBillsController < BaseOrigamiController printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) end - - - def show - sale_id = params[:sale_id] - if Sale.exists?(sale_id) - @sale_data = Sale.find_by_sale_id(sale_id) - end - end - + end diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 1c3e2247..5946ff49 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -81,6 +81,6 @@ class Settings::SetMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index b02310dc..05952d0d 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -78,6 +78,6 @@ class Settings::SimpleMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/helpers/api/origami/paypar_helper.rb b/app/helpers/api/origami/paypar_helper.rb new file mode 100644 index 00000000..0e102f10 --- /dev/null +++ b/app/helpers/api/origami/paypar_helper.rb @@ -0,0 +1,2 @@ +module Api::Origami::PayparHelper +end diff --git a/app/helpers/origami/paypar_helper.rb b/app/helpers/origami/paypar_helper.rb new file mode 100644 index 00000000..fe18e897 --- /dev/null +++ b/app/helpers/origami/paypar_helper.rb @@ -0,0 +1,2 @@ +module Origami::PayparHelper +end diff --git a/app/models/account.rb b/app/models/account.rb index e1cdc6d3..a950865c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,5 +3,7 @@ class Account < ApplicationRecord has_many :menu_items # belongs_to :lookup , :class_name => "Lookup" - + def self.collection + Account.select("id, title").map { |e| [e.title, e.id] } + end end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 9c5a75ac..89967e2e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,10 +1,10 @@ class MenuItem < ApplicationRecord - #belongs_to :account belongs_to :menu_category, :optional => true has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" + belongs_to :account validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index c99d2dfc..29daa796 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,6 +1,6 @@ class SaleAudit < ApplicationRecord self.primary_key = "sale_audit_id" - + #primary key - need to be unique generated for SaleAudit before_create :generate_custom_id @@ -44,13 +44,14 @@ class SaleAudit < ApplicationRecord sale_audit.save! end - def record_payment(sale_id, remark, action_by) + def self.record_payment(sale_id, remark, action_by) sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALEPAYMENT" sale_audit.action_at = DateTime.now.utc sale_audit.action_by = action_by sale_audit.remark = remark + sale_audit.approved_by = Time.now sale_audit.save! end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 9f68e4f4..ee1efd79 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,6 +1,6 @@ class SalePayment < ApplicationRecord self.primary_key = "sale_payment_id" - + #primary key - need to be unique generated for multiple shops before_create :generate_custom_id @@ -8,62 +8,67 @@ class SalePayment < ApplicationRecord attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status - # def process_payment(invoice, action_by) - # self.sale = invoice + def process_payment(invoice, action_by, cash_amount) - # amount_due = invoice.grand_total - # #get all payment for this invoices - # invoice.sale_payments.each do |payment| - # if (payment.payment_status == "paid" ) - # amount_due = amount_due - payment.payment_amount - # end - # end + self.sale = invoice + self.received_amount = cash_amount + + payment_method = "cash" + amount_due = invoice.grand_total - # if (amount_due > 0) - # payment_status = false - # #route to payment type - # switch (payment_method) - # case "cash" - # payment_status = cash_payment - # case "creditnote" - # payment_status = creditnote_payment - # case "visa" - # payment_status = external_terminal_card_payment(:visa) - # case "master" - # payment_status = external_terminal_card_payment(:master) - # case "jcb" - # payment_status = external_terminal_card_payment(:jcb) - # case "mpu" - # payment_status = external_terminal_card_payment(:mpu) - # case "unionpay" - # payment_status = external_terminal_card_payment(:unionpay) - # case "vochure" - # payment_status = vochure_payment - # case "giftcard" - # payment_status = giftcard_payment - # case "paypar" - # #TODO: implement paypar implementation - # payment_status = paypar_payment - # end + #get all payment for this invoices + invoice.sale_payments.each do |payment| + if (payment.payment_status == "paid" ) + amount_due = amount_due - payment.payment_amount + end + end + if (amount_due > 0) + payment_status = false + #route to payment type + case payment_method + when "cash" + payment_status = cash_payment + when "creditnote" + if !self.customer_id.nil? + payment_status = creditnote_payment(self.customer_id) + end + when "visa" + payment_status = external_terminal_card_payment(:visa) + when "master" + payment_status = external_terminal_card_payment(:master) + when "jcb" + payment_status = external_terminal_card_payment(:jcb) + when "mpu" + payment_status = external_terminal_card_payment(:mpu) + when "unionpay" + payment_status = external_terminal_card_payment(:unionpay) + when "vochure" + payment_status = vochure_payment + when "giftcard" + payment_status = giftcard_payment + when "paypar" + payment_status = paypar_payment + else + puts "it was something else" + end + #record an payment in sale-audit + remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{amount} | Payment Status ->#{payment_status}" + sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) - # #record an payment in sale-audit - # remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{amount} | Payment Status ->#{payment_status}" - # sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) + return true, self.sale + else + #record an payment in sale-audit + remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" + sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by) - # return true, self.sale - # else - # #record an payment in sale-audit - # remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" - # sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by) + return false, "No outstanding Amount" + end - # return false, "No outstanding Amount" - # end + end - # end - - def self.get_paypar_account(paypar_url,token,membership_id) + def self.get_paypar_account(paypar_url,token,membership_id) url = paypar_url.to_s + "/api/get_membership_data".to_s response = HTTParty.get(url, :body => { app_token: token,membership_id:membership_id}.to_json, @@ -76,102 +81,102 @@ class SalePayment < ApplicationRecord end - # private - # def cash_payment - # payment_status = false + private + def cash_payment + payment_status = false + self.payment_method = "cash" + self.payment_amount = self.received_amount + self.outstanding_amount = self.sale.grand_total - self.received_amount + self.payment_status = "paid" + payment_method = self.save! - # self.payment_method = "cash" - # self.payment_amount = self.received_amount - # self.outstanding_amount = self.sale.grand_total - received_amount - # self.payment_status = "paid" - # payment_method = self.save! + sale_update_payment_status(self.received_amount) - # sale_update_payment_status(self.received_amount) + return payment_status + end - # return payment_status - # end + def creditnote_payment(customer_id) - # def creditnote_payment(self.customer_id) - # payment_status = false + payment_status = false - # self.payment_method = "creditnote" - # self.payment_amount = self.received_amount - # self.customer_id = self.customer_id - # self.outstanding_amount = 0 - self.received_amount - # self.payment_status = "outstanding" - # payment_method = self.save! + self.payment_method = "creditnote" + self.payment_amount = self.received_amount + self.customer_id = self.customer_id + self.outstanding_amount = 0 - self.received_amount + self.payment_status = "outstanding" + payment_method = self.save! - # sale_update_payment_status(self.received_amount) + sale_update_payment_status(self.received_amount) - # return payment_status - # end + return payment_status + end - # def external_terminal_card_payment(method) - # payment_status = false + def external_terminal_card_payment(method) + payment_status = false - # self.payment_method = method - # self.payment_amount = self.received_amount - # self.payment_reference = self.card_payment_reference - # self.outstanding_amount = self.sale.grand_total- self.received_amount - # self.payment_status = "paid" - # payment_method = self.save! + self.payment_method = method + self.payment_amount = self.received_amount + self.payment_reference = self.card_payment_reference + self.outstanding_amount = self.sale.grand_total- self.received_amount + self.payment_status = "paid" + payment_method = self.save! - # sale_update_payment_status(self.received_amount) + sale_update_payment_status(self.received_amount) - # return payment_status - # end + return payment_status + end - # def voucher_payment - # payment_status = false + def voucher_payment + payment_status = false - # #Next time - validate if the vochure number is valid - within - # self.payment_method = "voucher" - # self.payment_amount = self.received_amount - # self.payment_reference = self.voucher_no - # self.outstanding_amount = self.sale.grand_total- self.received_amount - # self.payment_status = "paid" - # payment_method = self.save! + #Next time - validate if the vochure number is valid - within + self.payment_method = "voucher" + self.payment_amount = self.received_amount + self.payment_reference = self.voucher_no + self.outstanding_amount = self.sale.grand_total- self.received_amount + self.payment_status = "paid" + payment_method = self.save! - # sale_update_payment_status(self.received_amount) + sale_update_payment_status(self.received_amount) - # return payment_status + return payment_status - # end + end - # def giftcard_payment - # payment_status = false + def giftcard_payment + payment_status = false - # #Next time - validate if the vochure number is valid - within - # self.payment_method = "giftcard" - # self.payment_amount = self.received_amount - # self.payment_reference = self.giftcard_no - # self.outstanding_amount = self.sale.grand_total- self.received_amount - # self.payment_status = "paid" - # payment_method = self.save! + #Next time - validate if the vochure number is valid - within + self.payment_method = "giftcard" + self.payment_amount = self.received_amount + self.payment_reference = self.giftcard_no + self.outstanding_amount = self.sale.grand_total- self.received_amount + self.payment_status = "paid" + payment_method = self.save! - # sale_update_payment_status(self.received_amount) + sale_update_payment_status(self.received_amount) - # return payment_status + return payment_status - # end + end - # def paypar_payment - # ##TODO - Integration with Paypar (SmartPay) - # end + def paypar_payment + ##TODO - Integration with Paypar (SmartPay) + end - # def sale_update_payment_status(paid_amount) - - # #update amount_outstanding - # self.sale.amount_received = self.sale.amount_received + paid_amount - # self.sale.amount_changed = amount - self.sale.amount_received - # if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0) - # self.sale.payment_status = "paid" - # self.sale.sale_status = "completed" - # self.sale.save! - # end - - # end + def sale_update_payment_status(paid_amount) + puts "paid_amount" + puts paid_amount + #update amount_outstanding + self.sale.amount_received = self.sale.amount_received + paid_amount + self.sale.amount_changed = amount - self.sale.amount_received + if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0) + self.sale.payment_status = "paid" + self.sale.sale_status = "completed" + self.sale.save! + end + end private def generate_custom_id diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 4897407d..7a955a8d 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -190,13 +190,13 @@ - - + @@ -217,12 +217,14 @@ function callOrderDetails(sale_order_id){ sale_id = sale_order_id.split("_")[1] url = "origami/"+sale_order_id.split("_")[1] data_val = { sale_id: sale_order_id.split("_")[1]} - + $("#pay").prop('disabled',false); + $("#request_bills").prop('disabled',true); }else{ order_id = sale_order_id.split("_")[1] url = "origami/"+order_id data_val = { order_id: sale_order_id.split("_")[1]} - + $("#request_bills").prop('disabled',false); + $("#pay").prop('disabled',true); } table_or_order_id = order_id pay_sale_id = sale_id diff --git a/app/views/origami/card_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb similarity index 100% rename from app/views/origami/card_payments/index.html.erb rename to app/views/origami/others_payments/index.html.erb diff --git a/app/views/origami/request_bills/show.html.erb b/app/views/origami/payments/show.html.erb similarity index 88% rename from app/views/origami/request_bills/show.html.erb rename to app/views/origami/payments/show.html.erb index 573a63f4..ccd9fd77 100644 --- a/app/views/origami/request_bills/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -4,12 +4,10 @@
- - Receipt No : <%=@sale_data.receipt_no rescue ' '%> - Receipt Date : <%=@sale_data.receipt_date rescue '-'%> + Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %> - Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %> + Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %>
@@ -89,7 +87,7 @@

-
CARD
+
OTHERS PAYMENT
0.0

@@ -152,8 +150,8 @@
-
DEL
-
CLR
+
DEL
+
CLR
@@ -174,6 +172,7 @@ $(document).on('click', '.cashier_number', function(event){ original_value = $('#cash').text(); var input_type = $(this).attr("data-type"); + switch (input_type) { case 'num': var input_value = $(this).attr("data-value"); @@ -193,6 +192,10 @@ $(document).on('click', '.cashier_number', function(event){ update_balance(); break; + case 'clr': + $('#cash').text("0.0"); + update_balance(); + break; } event.handled = true; } else { @@ -209,16 +212,28 @@ $( document ).ready(function() { $('#card_payment').click(function() { var sale_id = $('#sale_id').text(); - window.location.href = '/origami/sale/'+ sale_id + "/payment/card_payment" + window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment" return false; }); $('#pay').click(function() { - console.log("pay") - if($('#amount_due').text() > 0){ - console.log("greater") + + if($('#balance').text() > 0){ + alert(" Insufficient Amount!") }else{ - console.log("less") + // payment + var cash = $('#cash').text(); + var credit = $('#credit').text(); + var card = $('#card').text(); + var sale_id = $('#sale_id').text(); + $.ajax({type: "POST", + url: "<%= origami_payment_process_path %>", + data: "cash="+ cash + "&sale_id=" + sale_id, + success:function(result){ + alert("THANK YOU") + } + }); + } }); diff --git a/app/views/origami/paypar/index.html.erb b/app/views/origami/paypar/index.html.erb new file mode 100644 index 00000000..859a854b --- /dev/null +++ b/app/views/origami/paypar/index.html.erb @@ -0,0 +1,137 @@ +
+ +
+
+ <% if @membership_id!=0 %> +
+
Redim Amount
+
+ <% end %> +
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
+
1000
+
+
+
+
+
+
4
+
5
+
6
+
+
+
+
5000
+
+
+
+
+
+
7
+
8
+
9
+
+
+
+
10000
+
+
+
+
+
+
0
+
.
+
00
+
+
+
+
50000
+
+
+
+
+
+
+
DEL
+
CLR
+
+
+
+
PAY
+
+
+
+
+ +
+
+
+ +
+ \ No newline at end of file diff --git a/app/views/settings/menu_item_options/show.html.erb b/app/views/settings/menu_item_options/show.html.erb index fdcb9d09..611f3165 100644 --- a/app/views/settings/menu_item_options/show.html.erb +++ b/app/views/settings/menu_item_options/show.html.erb @@ -2,8 +2,7 @@
diff --git a/app/views/settings/set_menu_items/_form.html.erb b/app/views/settings/set_menu_items/_form.html.erb index bdf0e97e..aeae0f5c 100644 --- a/app/views/settings/set_menu_items/_form.html.erb +++ b/app/views/settings/set_menu_items/_form.html.erb @@ -6,6 +6,7 @@ <%= f.input :name %> <%= f.input :alt_name %> <%= f.input :type %> + <%= f.input :account_id, :label => "Account type", :collection => Account.collection %> <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> <%= f.input :min_qty %> diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index 0082c819..ba23771f 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -19,6 +19,7 @@ Name Alt name Type + Account Type Menu category Menu item Min qty @@ -35,6 +36,7 @@ <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %> + <%= @settings_menu_item.account.title %> <%= @settings_menu_item.menu_category_id %> <%= @settings_menu_item.menu_item_id %> <%= @settings_menu_item.min_qty %> diff --git a/app/views/settings/simple_menu_items/_form.html.erb b/app/views/settings/simple_menu_items/_form.html.erb index 885f725e..01c5b482 100644 --- a/app/views/settings/simple_menu_items/_form.html.erb +++ b/app/views/settings/simple_menu_items/_form.html.erb @@ -6,6 +6,7 @@ <%= f.input :name %> <%= f.input :alt_name %> <%= f.input :type %> + <%= f.input :account_id, :label => "Account type", :collection => Account.collection %> <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> <%= f.input :min_qty %> <%= f.input :min_selectable_item %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index d2d93e0e..11620acd 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -21,6 +21,7 @@ Name Alt name Type + Accout Menu category Menu item Min qty @@ -37,6 +38,7 @@ <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %> + <%= @settings_menu_item.account.title %> <%= @settings_menu_item.menu_category_id %> <%= @settings_menu_item.menu_item_id %> <%= @settings_menu_item.min_qty %> diff --git a/config/routes.rb b/config/routes.rb index 64b5feeb..f227f7e3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,14 +68,25 @@ Rails.application.routes.draw do namespace :origami do root "home#index" get "/:booking_id" => "home#show" do #origami/:booking_id will show - resources :payments, only: [:index, :new, :create ] #add payment by payment_method resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers, only: [:index,:new, :create ] #add customer type end - # resources :request_bills, only: [:show] + + resources :request_bills, only: [:show] get 'sale/:sale_id/payment' => 'request_bills#show' + + get 'sale/:sale_id/payment' => 'payments#show' + post 'payment_process' => 'payments#create' + get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" - get 'sale/:sale_id/payment/card_payment' => "card_payments#index" + get 'sale/:sale_id/payment/others_payment' => "others_payments#index" + + get 'sale/:sale_id/payment' => 'payments#show' + post 'payment_process' => 'payments#create' + + get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" + get 'sale/:sale_id/payment/others_payment' => "others_payments#index" + end #--------- Waiter/Ordering Station ------------# diff --git a/db/migrate/20170602101727_create_accounts.rb b/db/migrate/20170331024747_create_accounts.rb similarity index 100% rename from db/migrate/20170602101727_create_accounts.rb rename to db/migrate/20170331024747_create_accounts.rb diff --git a/db/migrate/20170331024749_create_menu_items.rb b/db/migrate/20170331024749_create_menu_items.rb index f61a9172..81baa5ab 100644 --- a/db/migrate/20170331024749_create_menu_items.rb +++ b/db/migrate/20170331024749_create_menu_items.rb @@ -10,6 +10,7 @@ class CreateMenuItems < ActiveRecord::Migration[5.0] t.string :type, :null => false, :default => "SimpleMenuItem" t.references :menu_category, foreign_key: true t.references :menu_item, foreign_key: true + t.references :account, foreign_key: true t.integer :min_qty, :null => false, :default => 1 t.boolean :taxable, :null => false, :default => true t.integer :min_selectable_item, :null => false, :default => 1 diff --git a/db/migrate/20170403174111_create_sale_audits.rb b/db/migrate/20170403174111_create_sale_audits.rb index ae6ba3f4..e8197c4b 100644 --- a/db/migrate/20170403174111_create_sale_audits.rb +++ b/db/migrate/20170403174111_create_sale_audits.rb @@ -7,8 +7,8 @@ class CreateSaleAudits < ActiveRecord::Migration[5.0] t.string :action, :null => false t.datetime :action_at, :null => false t.string :action_by, :null => false - t.string :approved_by, :null => false - t.datetime :approved_by, :null => false + t.string :approved_by, :null => true + t.datetime :approved_at, :null => true t.string :remark t.timestamps end diff --git a/db/seeds.rb b/db/seeds.rb index 4d7799db..02fa39fb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -90,6 +90,9 @@ room = Room.create({name:"Default Room", zone: zone2, status:"available", seater #Tax Profile tax_profiles = TaxProfile.create({id:1, name: "Commerical Tax", rate:5.0, order_by:1, created_by:"SYSTEM DEFAULT"}) +#Account for Menu Item Type (eg: Food, Beverage) +food = Account.create({title: "Food", account_type: "0"}) +beverage = Account.create({title: "Beverage", account_type: "1"}) #Default menu menu = Menu.create({name: "Default Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) @@ -104,17 +107,17 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Men menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 4", alt_name: "Sample Alternate Category 4", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) #Default Menu items -menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 }) +menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"half portion",item_instance_code:"01001-1", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"full portion",item_instance_code:"01001-2", menu_item: menu_category1_menu_item0, price:18.00, is_on_promotion:false}]) -menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 }) -menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 }) -menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 }) +menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) -menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 }) -menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 }) -menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 }) +menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"}) menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) @@ -133,7 +136,3 @@ zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_o #Create Adminstrator employee admin_employee = Employee.create({name: "Administrator", role: "Administrator", password: "99999", emp_id:"999", created_by: "SYSTEM DEFAULT"}) - -#Account for Menu Item Type (eg: Food, Beverage) -food = Account.create({title: "Food", account_type: "0"}) -beverage = Account.create({title: "Beverage", account_type: "1"}) diff --git a/dump.rdb b/dump.rdb index 71b39e91..60850de8 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/spec/controllers/api/origami/paypar_controller_spec.rb b/spec/controllers/api/origami/paypar_controller_spec.rb new file mode 100644 index 00000000..e0003e75 --- /dev/null +++ b/spec/controllers/api/origami/paypar_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Api::Origami::PayparController, type: :controller do + +end diff --git a/spec/controllers/origami/paypar_controller_spec.rb b/spec/controllers/origami/paypar_controller_spec.rb new file mode 100644 index 00000000..749649d4 --- /dev/null +++ b/spec/controllers/origami/paypar_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::PayparController, type: :controller do + +end diff --git a/spec/helpers/api/origami/paypar_helper_spec.rb b/spec/helpers/api/origami/paypar_helper_spec.rb new file mode 100644 index 00000000..d53d9eae --- /dev/null +++ b/spec/helpers/api/origami/paypar_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Api::Origami::PayparHelper. For example: +# +# describe Api::Origami::PayparHelper 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 Api::Origami::PayparHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/origami/paypar_helper_spec.rb b/spec/helpers/origami/paypar_helper_spec.rb new file mode 100644 index 00000000..4613b9e7 --- /dev/null +++ b/spec/helpers/origami/paypar_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Origami::PayparHelper. For example: +# +# describe Origami::PayparHelper 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::PayparHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end