modify api and change rounding adj

This commit is contained in:
phyusin
2018-04-11 10:28:33 +06:30
parent 590ee16aa4
commit 27e70f1a86
7 changed files with 14 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
# skip_before_action :authenticate # skip_before_action :authenticate
ORDER = "order" ORDER = "order"
RESERVATION = "reservation" RESERVATION = "reservation"
ORDER_RESERVATION = "order and reservation" ORDER_RESERVATION = "order_and_reservation"
def check_customer def check_customer
customer_id = 0 customer_id = 0
@@ -42,6 +42,8 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
else else
status = true status = true
end end
elsif !params[:callback_url]
render :json => { :status => false, :message => "callback_url is required!" }
end end
if status == true if status == true

View File

@@ -71,8 +71,10 @@ class Origami::MovetableController < BaseOrigamiController
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
order.order_items.each do |order_item| if order.status == 'new'
order_items.push(order_item) order.order_items.each do |order_item|
order_items.push(order_item)
end
end end
end end
end end

View File

@@ -360,7 +360,7 @@ class Customer < ApplicationRecord
customer.contact_no = params[:contact_no] customer.contact_no = params[:contact_no]
customer.gender = params[:gender] customer.gender = params[:gender]
customer.address = params[:address] 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.membership_id = params[:membership_id]
customer.customer_type = "Takeaway" customer.customer_type = "Takeaway"
customer.tax_profiles = ["2"] customer.tax_profiles = ["2"]

View File

@@ -13,6 +13,7 @@ class OrderReservation < ApplicationRecord
order_reservation.customer_id = params[:cus_info] order_reservation.customer_id = params[:cus_info]
order_reservation.requested_time = Time.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S") order_reservation.requested_time = Time.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S")
if params[:order_info] if params[:order_info]
order_reservation.callback_url = params[:order_info][:callback_url]
order_reservation.item_count = params[:order_info][:items].count order_reservation.item_count = params[:order_info][:items].count
order_reservation.payment_type = params[:payment_info][:payment_type] order_reservation.payment_type = params[:payment_info][:payment_type]
order_reservation.payment_status = params[:payment_info][:payment_status] 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.total_tax = params[:payment_info][:total_tax]
order_reservation.discount_amount = params[:payment_info][:discount_amount] order_reservation.discount_amount = params[:payment_info][:discount_amount]
order_reservation.grand_total = params[:payment_info][:grand_total] 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 end
if params[:reservation_info] if params[:reservation_info]
order_reservation.total_customer = params[:reservation_info][:total_user] order_reservation.total_customer = params[:reservation_info][:total_user]

View File

@@ -107,7 +107,7 @@
<%end%> <%end%>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td> <td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> <td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr> </tr>
@@ -120,7 +120,7 @@
<td><b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td> <td><b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<% end %> <% end %>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td> <td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(rounding_adj, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td> <td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %></b></td> <td><b><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %></b></td>
</tr> </tr>
<tr> <tr>

View File

@@ -21,7 +21,7 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
t.integer :dining_count, :default => 0 t.integer :dining_count, :default => 0
t.integer :takeaway_count, :default => 0 t.integer :takeaway_count, :default => 0
t.integer :member_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.integer :total_receipt, :default => 0
t.decimal :total_void, :default => 0 t.decimal :total_void, :default => 0
t.timestamps t.timestamps

View File

@@ -5,6 +5,7 @@ class CreateOrderReservations < ActiveRecord::Migration[5.1]
t.string :order_reservation_type, :null => false t.string :order_reservation_type, :null => false
t.string :customer_id, :null => false t.string :customer_id, :null => false
t.datetime :requested_time, :null => false t.datetime :requested_time, :null => false
t.string :callback_url, :null => false
t.integer :item_count, :null => false, :default => 0 t.integer :item_count, :null => false, :default => 0
t.integer :total_customer t.integer :total_customer
t.string :payment_type t.string :payment_type