Merge branch 'adminbsb_material_ui' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-11-30 17:35:16 +06:30
27 changed files with 197 additions and 110 deletions

View File

@@ -1,5 +1,5 @@
class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource
def index
@products = InventoryDefinition.all.active.order('created_at desc')
end

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

@@ -1,6 +1,5 @@
class Origami::InDutiesController < BaseOrigamiController
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
# GET /in_duties
# GET /in_duties.json
def index

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,6 +54,15 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
#end rounding adjment
end
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
@@ -75,9 +84,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Print
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -114,6 +121,14 @@ class Origami::PaymentsController < BaseOrigamiController
@accountable_type = ''
@table_no = ''
@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
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
accounts = @customer.tax_profiles
@@ -127,7 +142,6 @@ class Origami::PaymentsController < BaseOrigamiController
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
puts response.to_json
if response["status"]==true
response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@@ -191,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
@@ -240,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

@@ -21,7 +21,7 @@ class Reports::PaymentMethodController < BaseReportController
end
@payment_type = params[:payment_type]
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
puts @pyament_method.to_json
puts @sale_data.to_json
puts "sssssssssssss"
@from = from
@to = to

View File

@@ -26,8 +26,6 @@ class Settings::MenuItemInstancesController < ApplicationController
def get_instance
@id = MenuItemInstance.find(params[:id])
puts "iddddddddd"
puts @id.to_json
end
# GET /settings/menu_item_instances/1/edit

View File

@@ -25,11 +25,6 @@ class Ability
can :manage, TaxProfile
can :manage, PrintSetting
can :manage, Account
can :manage, Commission
can :manage, Commissioner
can :manage, Promotion
can :manage, Product
can :manage, Order
can :manage, Booking
@@ -79,6 +74,13 @@ class Ability
can :overall_void, :void
can :manage, Commission
can :manage, Commissioner
can :manage, Promotion
can :manage, Product
can :manage, Inventory
elsif user.role == "cashier"
# can :overall_void, :void
@@ -112,6 +114,11 @@ class Ability
can :move_dining, :moveroom
can :manage, DiningQueue
can :manage, Commission
can :manage, Commissioner
can :manage, Promotion
can :manage, Product
elsif user.role == "account"
@@ -148,6 +155,12 @@ class Ability
can :show, :payment
can :reprint, :payment
can :rounding_adj, :payment
can :manage, Commission
can :manage, Commissioner
can :manage, Promotion
can :manage, Product
end
end
end

View File

@@ -813,11 +813,12 @@ end
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
sale_payment = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
sale_payment = SalePayment.select("s.amount_changed as change_amount,s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.order('s.receipt_no DESC')
payments_total = SalePayment.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
payments_total = SalePayment.select("sales.amount_changed as total_change_amount,CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,

View File

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

View File

@@ -65,12 +65,14 @@
</ul>
</li>
<% end %>
<li>
<% if can? :menage, Inventory %>
<!-- <li>
<a href="<%= inventory_path %>">
<i class="material-icons">store</i>
<span><%= t :inventory %></span>
</a>
</li>
</li> -->
<%end%>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>

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

@@ -377,8 +377,10 @@
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' active="<%= can? :edit, :sale_edit %>">Edit</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
@@ -522,19 +524,20 @@
});
});
// $('#pay').on('click', function () {
// var sale_id = $('#sale_id').val();
// var url = '/origami/sale/' + sale_id + "/rounding_adj";
// $.ajax({
// type: "POST",
// url: '/origami/sale/' + sale_id + "/rounding_adj",
// success: function (result) {
// window.location.href = '/origami/sale/' + sale_id + "/payment";
// }
// });
// });
$('#pay').on('click', function () {
var sale_id = $('#sale_id').val();
var url = '/origami/sale/' + sale_id + "/rounding_adj";
$.ajax({
type: "POST",
url: '/origami/sale/' + sale_id + "/rounding_adj",
success: function (result) {
window.location.href = '/origami/sale/' + sale_id + "/payment";
}
});
window.location.href = '/origami/sale/' + sale_id + "/payment";
});
// Bill Request

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

@@ -94,11 +94,11 @@
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.rounding_adjustment rescue 0%></span></strong></td>
<td class="item-attr"><strong><span id="rounding_adj"><%=@rounding_adj rescue 0%></span></strong></td>
</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>
@@ -109,7 +109,7 @@
</tfooter>
</table>
</div>
<!-- <div> -->
<!-- <div> -->
<!-- <INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/> -->
<!-- </div> -->
@@ -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

@@ -348,6 +348,7 @@
<button type="button" class="btn bg-blue btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn bg-blue btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" class="btn bg-blue btn-block" id='move' disabled="">Move</button> -->

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>

View File

@@ -82,7 +82,7 @@
<tr>
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
<th> <%= t("views.right_panel.detail.payment_method") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th> <%= t :payment_method %></th>
<th> <%= t("views.right_panel.detail.amount") %> </th>
@@ -92,7 +92,11 @@
<tbody>
<% total = 0 %>
<% @pyament_method.each do |payment| %>
<% total += payment.payment_amount + payment.outstanding_amount %>
<% if payment.payment_method === 'cash'
total += payment.payment_amount - payment.change_amount
else
total += payment.payment_amount
end%>
<tr>
<% if @shift_from.nil? && @shift_to.nil? %>
<td><%= payment.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
@@ -103,7 +107,11 @@
<td><%= payment.cashier_name rescue '-' %></td>
<!--<td><%= payment.sale.customer.name rescue '-' %></td>-->
<td><%= payment.payment_method rescue '-' %></td>
<td><%= payment.payment_amount + payment.outstanding_amount%> </td>
<% if payment.payment_method === 'cash' %>
<td><%= payment.payment_amount - payment.change_amount%> </td>
<%else%>
<td><%= payment.payment_amount%> </td>
<%end%>
<td><%= payment.sale.grand_total rescue '-' %></td>
</tr>