From 27e70f1a86632db7a7e8b82a2d673e5b55893498 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 11 Apr 2018 10:28:33 +0630 Subject: [PATCH] modify api and change rounding adj --- .../api/order_reserve/order_reservation_controller.rb | 4 +++- app/controllers/origami/movetable_controller.rb | 6 ++++-- app/models/customer.rb | 2 +- app/models/order_reservation.rb | 3 ++- app/views/reports/receipt_no/index.html.erb | 4 ++-- db/migrate/20170626191519_create_shift_sales.rb | 2 +- db/migrate/20180406080240_create_order_reservations.rb | 1 + 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 0093409c..957b84a9 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -2,7 +2,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController # skip_before_action :authenticate ORDER = "order" RESERVATION = "reservation" - ORDER_RESERVATION = "order and reservation" + ORDER_RESERVATION = "order_and_reservation" def check_customer customer_id = 0 @@ -42,6 +42,8 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController else status = true end + elsif !params[:callback_url] + render :json => { :status => false, :message => "callback_url is required!" } end if status == true diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index d6d1fc61..9cacd8f4 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -71,8 +71,10 @@ class Origami::MovetableController < BaseOrigamiController booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) - order.order_items.each do |order_item| - order_items.push(order_item) + if order.status == 'new' + order.order_items.each do |order_item| + order_items.push(order_item) + end end end end diff --git a/app/models/customer.rb b/app/models/customer.rb index 2ece4330..3eb51a24 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -360,7 +360,7 @@ class Customer < ApplicationRecord customer.contact_no = params[:contact_no] customer.gender = params[:gender] customer.address = params[:address] - customer.date_of_birth = Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") + customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : '' customer.membership_id = params[:membership_id] customer.customer_type = "Takeaway" customer.tax_profiles = ["2"] diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 0be5e4c8..84821314 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -13,6 +13,7 @@ class OrderReservation < ApplicationRecord order_reservation.customer_id = params[:cus_info] order_reservation.requested_time = Time.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S") if params[:order_info] + order_reservation.callback_url = params[:order_info][:callback_url] order_reservation.item_count = params[:order_info][:items].count order_reservation.payment_type = params[:payment_info][:payment_type] order_reservation.payment_status = params[:payment_info][:payment_status] @@ -21,7 +22,7 @@ class OrderReservation < ApplicationRecord order_reservation.total_tax = params[:payment_info][:total_tax] order_reservation.discount_amount = params[:payment_info][:discount_amount] order_reservation.grand_total = params[:payment_info][:grand_total] - order_reservation.order_remark = params[:payment_info][:order_remark] + order_reservation.order_remark = params[:order_info][:order_remark] end if params[:reservation_info] order_reservation.total_customer = params[:reservation_info][:total_user] diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 9eee6ab9..567b056b 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -107,7 +107,7 @@ <%end%> <%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %> - <%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= result.rounding_adjustment.to_f rescue '-' %> <%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %> @@ -120,7 +120,7 @@ <%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <% end %> <%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> - <%= number_with_precision(rounding_adj, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= rounding_adj.to_f rescue '-' %> <%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %> diff --git a/db/migrate/20170626191519_create_shift_sales.rb b/db/migrate/20170626191519_create_shift_sales.rb index d16449d7..f18a2c1c 100755 --- a/db/migrate/20170626191519_create_shift_sales.rb +++ b/db/migrate/20170626191519_create_shift_sales.rb @@ -21,7 +21,7 @@ class CreateShiftSales < ActiveRecord::Migration[5.1] t.integer :dining_count, :default => 0 t.integer :takeaway_count, :default => 0 t.integer :member_count, :default => 0 - t.integer :total_rounding, :default => 0 + t.decimal :total_rounding,, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.integer :total_receipt, :default => 0 t.decimal :total_void, :default => 0 t.timestamps diff --git a/db/migrate/20180406080240_create_order_reservations.rb b/db/migrate/20180406080240_create_order_reservations.rb index 7f044ff0..4a53aaf0 100644 --- a/db/migrate/20180406080240_create_order_reservations.rb +++ b/db/migrate/20180406080240_create_order_reservations.rb @@ -5,6 +5,7 @@ class CreateOrderReservations < ActiveRecord::Migration[5.1] t.string :order_reservation_type, :null => false t.string :customer_id, :null => false t.datetime :requested_time, :null => false + t.string :callback_url, :null => false t.integer :item_count, :null => false, :default => 0 t.integer :total_customer t.string :payment_type