Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01

This commit is contained in:
Myat Zin Wai Maw
2020-02-03 09:59:29 +06:30
8 changed files with 58 additions and 69 deletions

View File

@@ -1,6 +1,6 @@
source 'https://rubygems.org'
#ruby '2.4.1'
ruby '2.6.5'
#ruby '2.5.7'
git_source(:github) do |repo_name|
@@ -15,7 +15,7 @@ gem 'rails', '~> 5.1.0'
#gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'pg'
gem 'mysql2'
gem 'mysql2', '~> 0.5.2'
#Use PosgreSQL

View File

@@ -1,5 +1,5 @@
class Transactions::CreditNotesController < ApplicationController
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
before_action :check_user
@@ -15,24 +15,9 @@ class Transactions::CreditNotesController < ApplicationController
to = params[:to]
order_source = params[:order_source]
if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil?
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=sales.sale_id GROUP BY so.sale_id)"
@credit_notes = Sale.select("sales.*, #{order_source_query} as source")
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
THEN NULL ELSE payment_method='creditnote' END)")
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
if !sale.nil?
@credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
@credit_notes = 0
end
end
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
@credit_notes = Kaminari.paginate_array(sale).page(params[:page]).per(20)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @credit_notes }
@@ -45,5 +30,5 @@ class Transactions::CreditNotesController < ApplicationController
redirect_to root_path
end
end
end
end

View File

@@ -708,43 +708,29 @@ class Sale < ApplicationRecord
end
def self.search_credit_sales(customer,filter,from,to,order_source="")
if filter.blank?
keyword = ''
else
keyword = "and sales.receipt_no LIKE ? OR sales.cashier_name LIKE ? OR sales.sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
end
if customer.blank?
custo = ''
else
custo = "and sales.customer_id = '#{customer}'"
end
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=sales.sale_id GROUP BY so.sale_id)"
if order_source.blank?
source = ""
else
if order_source == "cashier"
source = "and #{order_source_query}='cashier' or #{order_source_query}='emenu'"
else
source = "and #{order_source_query}='#{order_source}'"
end
end
sale = Sale.select(Sale.column_names)
.select(SalePayment.column_names)
.select(:source).includes(:customer)
.joins(:sale_payments, :orders)
.where(sale_payments: {payment_method: 'creditnote'})
.group(:sale_payment_id)
if from.present? && to.present?
sale = Sale.select("sales.*,#{order_source_query} as source").joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to)
else
sale = Sale.select("sales.*,#{order_source_query} as source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}")
sale = sale.receipt_date_between(from, to)
end
if filter.present?
sale = sale.where("sales.receipt_no LIKE ? OR sales.cashier_name LIKE ? OR sales.sale_status = ?", "%#{filter}%", "%#{filter}%", filter)
end
if customer.present?
sale = sale.where(customer_id: customer)
end
if order_source.present?
sale = sale.where(orders: {source: order_source})
end
return sale
end
def self.get_rounding_adjustment(num)

View File

@@ -142,7 +142,7 @@ class SaleAudit < ApplicationRecord
if paymal[0]
remark = paymal[0].remark.split("}")
response = "["+remark[0]+'}]'
response = JSON.parse(response)
# response = JSON.parse(response)
puts response
if response[0]["status"] == true
if response[0]["current_rebate_amount"].present?

View File

@@ -233,9 +233,9 @@ class SalePayment < ApplicationRecord
return response;
end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("redeem");
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
def redeem(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
# membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
puts "This is membership_actions_data"
puts membership_actions_data.to_json
if !membership_actions_data.nil?
@@ -243,8 +243,9 @@ class SalePayment < ApplicationRecord
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
campaign_type_id = JSON.parse(membership_actions_data.additional_parameters)["campaign_type_id"]
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
sale_data = Sale.find_by_sale_id(sale_id)
account_no = Customer.find_by_customer_id(self.sale.customer_id).paypar_account_no
if sale_data
others = 0
@@ -261,7 +262,7 @@ class SalePayment < ApplicationRecord
redeem_amount:received_amount,
receipt_no:sale_data.receipt_no,
campaign_type_id:campaign_type_id,
account_no:"",
account_no: account_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json,
:headers => {
@@ -504,7 +505,7 @@ class SalePayment < ApplicationRecord
#Next time - validate if the vochure number is valid - within
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
membership_data = redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
@@ -722,7 +723,10 @@ class SalePayment < ApplicationRecord
# update for shift with credit payment
def update_shift_for_credit_payment
shift_credit = ShiftSale.find_by_id(self.sale.shift_sale_id)
shift = ShiftSale.find_by_id(ShiftSale.current_shift)
shift = self.action_by.current_shift
if !shift.nil?
shift = ShiftSale.current_shift
end
if !shift.nil?
credit_payment_left = get_credit_payment_left[0].payment_amount.to_f
if self.payment_method == "cash"

View File

@@ -379,7 +379,11 @@
No Tax
<% end %></strong><br>
<%if !@webview && @changable_tax %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% if @current_user.role == 'cashier' %>
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
<% else %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
<% end %>
</td>
<td class="item-attr"><strong id="order-Tax"><%= number_format(@obj_sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
@@ -1406,6 +1410,9 @@
// overall_void();
}else if(type == "waste_and_spoilage"){
}else if(type == 'change_tax'){
$('#AccessCodeModal').modal('hide');
$('#change_taxModal').modal('show');
}
}else{
swal("Opps",result.message,"warning")

View File

@@ -105,7 +105,11 @@
No Tax
<% end %></strong><br>
<%if @sale_payment.nil? && @changable_tax %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% if @current_user.role == 'cashier' %>
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
<% else %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
<% end %>
</td>
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
@@ -1472,6 +1476,9 @@ $(document).ready(function(){
$('#AccessCodeModal').modal('hide');
$('#focModal').modal('show');
// overall_foc();
}else if(type == 'change_tax'){
$('#AccessCodeModal').modal('hide');
$('#change_taxModal').modal('show');
}
}else{
swal("Oops",result.message,"warning");

View File

@@ -37,7 +37,7 @@
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 mbl-style">
<label class="font-14"><%= t("views.right_panel.detail.enter_keyboards") %></label>
<input type="text" name="receipt_no" class="form-control m-t-3" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
<input type="text" name="filter" class="form-control m-t-3" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 col-mbl-view mbl-style">
<label class="font-14"><%= t("views.right_panel.detail.select_customer") %></label>
@@ -66,7 +66,7 @@
<label class="font-14"> &nbsp;</label><br>
<input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
</div>
</div>
<% end %>
</td>
</tr>