update member discount and seed for detail

This commit is contained in:
Aung Myo
2017-07-12 17:05:10 +06:30
parent ac7b4dc56d
commit 1d873ddb68
16 changed files with 94 additions and 63 deletions

View File

@@ -49,21 +49,7 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)
# get member information
total = Customer.get_member_account(@customer)
@balance = 0.00
@accountable_type = ''
if total["status"]==true
total["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance += res["balance"]
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
end
end
# @response = ""
#end customer amount

View File

@@ -170,37 +170,36 @@ class Origami::DiscountsController < BaseOrigamiController
response = {status: false, message: "Can't open membership server "}
rescue Net::OpenTimeout
response = { status: false , message: "Can't open membership server "}
rescue OpenURI::HTTPError
response = { status: false, message: "Can't open membership server "}
rescue SocketError
response = { status: false, message: "Can't open membership server "}
end
# {"status":true,"discount_earned":360.0,"is_bonus":false}
# {"status":false,"message":"Can't open membership server "}
puts "ssssssssss"
puts response.to_json["status"]
puts response["status"]
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
puts response.to_json
# Re-calc All Amount in Sale
if response["status"] == true
sale.compute_by_sale_items(sale_id, sale.sale_items, response["discount_earned"])
discount_amount = response["discount_earned"]
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
result = {:status=> "Success", :table_id => table_id,:table_type => table_type }
end
if response[:status] == false
result = {:status=> response[:message], :table_id => table_id,:table_type => table_type }
end
if response["status"] == 500
result = {:status=> response["message"], :table_id => table_id,:table_type => table_type }
if response["status"] == "500"
result = {:status=> response["error"], :table_id => table_id,:table_type => table_type }
end
if !response.nil?
if response[:status] == false
result = {:status=> response[:message], :table_id => table_id,:table_type => table_type }
end
end
render :json => result.to_json
end

View File

@@ -60,8 +60,15 @@ class SeedGenerator < ApplicationRecord
seed.save
end
padding_len = 5 - prefix.length
next_code = prefix + seed.current.to_s.to_s.rjust((4-prefix.length)+1,'0')
if prefix.length == 1
padding_len = 5 - prefix.length
count = 4-prefix.length
else prefix.length == 2
padding_len = 6 - prefix.length
count = 5-prefix.length
end
next_code = prefix + seed.current.to_s.to_s.rjust((count)+1,'0')
return next_code
end
end

View File

@@ -64,18 +64,11 @@
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th colspan="5">Membership Transactions</th>
<th>Current Balance : <%= @balance%></th>
</tr>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Redeem</th> -->
<th>Discount Amount</th>
<!-- <th>Balance</th> -->
<th>From Account</th>
<th>Status</th>
<th>Receipt No</th>
@@ -86,9 +79,9 @@
<% @response["data"].each do |transaction| %>
<tr>
<td><%= transaction["date"]%></td>
<td><%= transaction["redeem"]%></td>
<!-- <td><%= transaction["redeem"]%></td> -->
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["balance"] %></td> -->
<td><%= transaction["account_status"] %></td>
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>

View File

@@ -67,7 +67,12 @@
<td class="item-attr"><strong id="order-beverage"></strong></td>
</tr> -->
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale_data.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
</tr>
<tr class="hidden">
@@ -503,18 +508,17 @@ $(document).ready(function(){
success:function(result){
if (result.status == "Success") {
status = result.status
type = 'green'
btn_color = 'btn-green'
}else{
type = 'red'
btn_color = 'btn-red'
}else{
status = result.status
type = ''
btn_color = 'btn-green'
}
$.confirm({
title: 'Infomation!',
content: status,
content: result.status,
columnClass: 'small',
type: type,
buttons: {

View File

@@ -220,7 +220,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @obj_sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
</tr>

View File

@@ -175,7 +175,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @selected_item.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
</tr>
<tr class="rebate_amount"></tr>

View File

@@ -59,7 +59,11 @@
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
</tr>
<tr class="hidden">

View File

@@ -68,7 +68,12 @@
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
<%if @sale_data.discount_type == 'member_discount'%>
<td style="width:80%; text-align:left; border-top:none"><strong>Member Discount:</strong></td>
<%else%>
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
<%end%>
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
</tr>
<tr>

View File

@@ -40,7 +40,11 @@
<td class="item-attr"><strong id="order-sub-total"></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>

View File

@@ -106,7 +106,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>

View File

@@ -203,7 +203,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @obj.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%=@obj.total_discount rescue 0%>)</strong></td>
</tr>
<% if @status == "sale" %>

View File

@@ -164,7 +164,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>

View File

@@ -40,7 +40,11 @@
<td class="item-attr"><strong id="order-sub-total"></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>

View File

@@ -106,7 +106,11 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>

View File

@@ -138,7 +138,7 @@ menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size"
menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"})
menu_item_attribute_size_large = MenuItemAttribute.create({attribute_type:"size", name: "Large", value: "large"})
shop = Shop.create({id:1, name: "Beauty In the Pot", address:'No.42-A, Sayar San Road, Bahan, Yangon', township:"Bahan",state:"Yangon",city:"Yangon", country:"Myanmar", phone_no:"+95(9) 252221188, +95(9) 252221177",reservation_no:"111",license:"123",
shop = Shop.create({id:1, name: "OSAKA OHSHO", address:'No. 256, Kyaikkasan Road, Tamwe Township, Yangon', township:"Tamwe",state:"Yangon",city:"Yangon", country:"Myanmar", phone_no:"Tel: 09-258676611",reservation_no:"111",license:"123",
activated_at:"2017-06-26 08:36:24",license_data:"test",base_currency:"111",id_prefix:"111"})
#Default Order Queue stations
# order_queue_station1 = OrderQueueStation.create({station_name: "Queue Station 1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
@@ -172,7 +172,8 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
{membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"member_discount",gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:6},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})