promotion + merge with master

This commit is contained in:
Nweni
2017-08-23 10:12:41 +06:30
parent 28dab9d3e0
commit eedf6c39a1
4 changed files with 20 additions and 22 deletions

View File

@@ -24,6 +24,7 @@ class Api::BillController < Api::ApiController
@sale = Sale.new @sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
end end
# Promotion.promo_activate(@sale)
else else
@status = false @status = false
@error_message = "No Current Open Shift" @error_message = "No Current Open Shift"

View File

@@ -10,8 +10,7 @@ class Promotion < ApplicationRecord
PROMO_TYPE3 = "Net_price" PROMO_TYPE3 = "Net_price"
PROMO_TYPE4 = "Percentage" PROMO_TYPE4 = "Percentage"
def self.promo_activate def self.promo_activate(saleObj)
saleObj = Sale.first # Test
current_day = Time.now.strftime("%Y-%m-%d") current_day = Time.now.strftime("%Y-%m-%d")
current_time = Time.now.strftime('%H:%M:%S') current_time = Time.now.strftime('%H:%M:%S')
day = Date.today.wday day = Date.today.wday

View File

@@ -298,8 +298,8 @@ class Sale < ApplicationRecord
customer = Customer.find(sale.customer_id) customer = Customer.find(sale.customer_id)
# #Creat new tax records # #Creat new tax records
tax_profiles.each do |tax| tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax| customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale) sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate sale_tax.tax_rate = tax.rate
@@ -311,7 +311,7 @@ class Sale < ApplicationRecord
rate = tax.rate rate = tax.rate
divided_value = (100 + rate)/rate divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value sale_tax.tax_payable_amount = total_tax / divided_value
else else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100 sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end end
@@ -319,7 +319,7 @@ class Sale < ApplicationRecord
# total_taxable = total_taxable + sale_tax.tax_payable_amount # total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive sale_tax.inclusive = tax.inclusive
sale_tax.save sale_tax.save
end end
end end
end end
@@ -338,13 +338,13 @@ class Sale < ApplicationRecord
total_tax_amount = 0 total_tax_amount = 0
#tax_profile - list by order_by #tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc") tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
customer = Customer.find(self.customer_id)
puts customer
#Create new tax records #Create new tax records
tax_profiles.each do |tax| tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax| customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self) sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate sale_tax.tax_rate = tax.rate
@@ -356,16 +356,16 @@ class Sale < ApplicationRecord
rate = tax.rate rate = tax.rate
divided_value = (100 + rate)/rate divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value sale_tax.tax_payable_amount = total_tax / divided_value
else else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100 sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end end
#new taxable amount is standard rule for step by step #new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount # total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive sale_tax.inclusive = tax.inclusive
sale_tax.save sale_tax.save
end end
end end
end end
@@ -596,7 +596,7 @@ def self.get_item_query()
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id") query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id") query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
end end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status) def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
# date_type_selection = get_sql_function_for_report_type(report_type) # date_type_selection = get_sql_function_for_report_type(report_type)

View File

@@ -108,17 +108,15 @@
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button> <button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button> <button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled --> <!-- Temporary Disabled -->
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Summary</button>
<%end%>
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button> <button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %> <%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back <button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
</button> </button>
<%end%> <%end%>
</div> </div>
</div> </div>
<!-- Column One --> <!-- Column One -->