update rounding adj

This commit is contained in:
Aung Myo
2017-11-30 15:44:48 +06:30
parent a871bf3789
commit 5b9182c1d1
17 changed files with 126 additions and 78 deletions

View File

@@ -4,9 +4,18 @@ class Origami::CreditPaymentsController < BaseOrigamiController
# limit visa_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = sale_data.grand_total
@creditcount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "creditnote"
@creditcount = @creditcount + sale_payment.payment_amount

View File

@@ -6,7 +6,7 @@ class Origami::HomeController < BaseOrigamiController
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
@shop = Shop::ShopDetail
# @shift = ShiftSale.current_open_shift(current_user.id)
end

View File

@@ -8,6 +8,15 @@ class Origami::JcbController < BaseOrigamiController
total = sale_data.grand_total
@jcbcount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount

View File

@@ -8,6 +8,15 @@ class Origami::MasterController < BaseOrigamiController
total = sale_data.grand_total
@mastercount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master"
@mastercount = @mastercount + sale_payment.payment_amount

View File

@@ -8,6 +8,14 @@ class Origami::MpuController < BaseOrigamiController
@mpucount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount

View File

@@ -24,7 +24,7 @@ class Origami::PaymentsController < BaseOrigamiController
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
#shop detail
shop_details = Shop.find(1)
shop_details = Shop::ShopDetail
# customer= Customer.where('customer_id=' +.customer_id)
customer= Customer.find(sale_data.customer_id)
# get member information
@@ -54,7 +54,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop.find(1)
shop_details = Shop::ShopDetail
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -121,7 +121,7 @@ class Origami::PaymentsController < BaseOrigamiController
@accountable_type = ''
@table_no = ''
@shop = Shop.find_by_id(1)
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else
@@ -205,7 +205,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = Shop::ShopDetail
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -254,7 +254,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = Shop::ShopDetail
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)

View File

@@ -5,76 +5,65 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
# limit redeem_amount
# rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
# nonrebate_prices = sale_data.total_amount - rebate_prices
# @payparcount = 0
# others = 0
# sale_data.sale_payments.each do |sale_payment|
# if sale_payment.payment_method == "paypar"
# @payparcount = @payparcount + sale_payment.payment_amount
# else
# others = others + sale_payment.payment_amount
# end
# end
# non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
# if non_rebate_exceed < 0
# @redeem_prices = rebate_prices - @payparcount
# else
# @redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
# end
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
others = others + sale_payment.payment_amount
new_total = sale_data.grand_total
end
end
@redeem_prices = sale_data.grand_total - @payparcount -others
@rounding_adj = new_total-sale_data.grand_total
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@redeem_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
@out = false,0
end
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
@out = false,0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
@out = false, 0
end
end

View File

@@ -7,6 +7,15 @@ class Origami::VisaController < BaseOrigamiController
total = sale_data.grand_total
@visacount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount

View File

@@ -7,6 +7,15 @@ class Origami::VoucherController < BaseOrigamiController
total = sale_data.grand_total
@vouchercount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "voucher"
@vouchercount = @vouchercount + sale_payment.payment_amount

View File

@@ -1,3 +1,3 @@
class Shop < ApplicationRecord
ShopDetail = Shop.find_by_id(1)
end

View File

@@ -21,6 +21,7 @@
<label>You can pay up to </label>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<%@can_credit = @can_credit +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control" readonly="" value="<%=@can_credit %>" data-member-value="">
</div>
</div>

View File

@@ -20,6 +20,7 @@
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_jcb = @can_jcb +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_jcb %>" data-member-value="">
</div>
<hr>

View File

@@ -20,6 +20,7 @@
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_master = @can_master +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_master %>" data-member-value="">
</div>
<hr>

View File

@@ -21,7 +21,8 @@
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_mpu %>" data-member-value="">
<%@can_mpu = @can_mpu +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @can_mpu %>" data-member-value="">
</div>
<hr>
</div>

View File

@@ -98,7 +98,7 @@
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total+ @rounding_adj rescue 0%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
@@ -121,7 +121,7 @@
<div class="card-header">
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Amount Due</strong></div>
<div class="col-md-4"><strong><span id="amount_due"><%= @sale_data.grand_total %></span></strong></div>
<div class="col-md-4"><strong><span id="amount_due"><%= @sale_data.grand_total + @rounding_adj rescue 0%></span></strong></div>
</div>
<div class="row payment cash-color p-l-5 p-r-5">
@@ -219,7 +219,7 @@
<!-- <br> -->
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total %></span></strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total+ @rounding_adj rescue 0 %></span></strong></div>
</div>
<!-- <br> -->
</div>

View File

@@ -17,6 +17,7 @@
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="">You can redeem up to </label>
<%@redeem_prices = @redeem_prices +@rounding_adj%>
<input type="text" name="" id="redeemamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @redeem_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
</div>
<hr>

View File

@@ -20,6 +20,7 @@
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_visa = @can_visa +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_visa %>" data-member-value="">
</div>
<hr>