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
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
end
# Promotion.promo_activate(@sale)
else
@status = false
@error_message = "No Current Open Shift"

View File

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

View File

@@ -298,8 +298,8 @@ class Sale < ApplicationRecord
customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
@@ -311,7 +311,7 @@ class Sale < ApplicationRecord
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
@@ -319,7 +319,7 @@ class Sale < ApplicationRecord
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
sale_tax.save
end
end
end
@@ -338,13 +338,13 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
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
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
@@ -356,16 +356,16 @@ class Sale < ApplicationRecord
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
sale_tax.save
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.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)
# 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_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- 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>
<%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
<%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>
<%end%>
</div>
</div>
<!-- Column One -->