foc
This commit is contained in:
23
Gemfile.lock
23
Gemfile.lock
@@ -47,7 +47,7 @@ GEM
|
|||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
aescrypt (1.0.0)
|
aescrypt (1.0.0)
|
||||||
airbrussh (1.3.2)
|
airbrussh (1.3.3)
|
||||||
sshkit (>= 1.6.1, != 1.7.0)
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
arel (8.0.0)
|
arel (8.0.0)
|
||||||
axlsx (2.0.1)
|
axlsx (2.0.1)
|
||||||
@@ -62,7 +62,7 @@ GEM
|
|||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (11.0.1)
|
byebug (11.0.1)
|
||||||
cancancan (1.17.0)
|
cancancan (1.17.0)
|
||||||
capistrano (3.11.0)
|
capistrano (3.11.1)
|
||||||
airbrussh (>= 1.0.0)
|
airbrussh (>= 1.0.0)
|
||||||
i18n
|
i18n
|
||||||
rake (>= 10.0.0)
|
rake (>= 10.0.0)
|
||||||
@@ -99,8 +99,8 @@ GEM
|
|||||||
factory_girl_rails (4.9.0)
|
factory_girl_rails (4.9.0)
|
||||||
factory_girl (~> 4.9.0)
|
factory_girl (~> 4.9.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faker (2.1.0)
|
faker (2.2.2)
|
||||||
i18n (>= 0.7)
|
i18n (~> 1.6.0)
|
||||||
ffi (1.11.1)
|
ffi (1.11.1)
|
||||||
filterrific (5.2.1)
|
filterrific (5.2.1)
|
||||||
font-awesome-rails (4.7.0.5)
|
font-awesome-rails (4.7.0.5)
|
||||||
@@ -148,9 +148,9 @@ GEM
|
|||||||
material_icons (2.2.1)
|
material_icons (2.2.1)
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
method_source (0.9.2)
|
method_source (0.9.2)
|
||||||
mime-types (3.2.2)
|
mime-types (3.3)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2019.0331)
|
mime-types-data (3.2019.0904)
|
||||||
mini_magick (4.9.5)
|
mini_magick (4.9.5)
|
||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
@@ -163,8 +163,8 @@ GEM
|
|||||||
net-scp (2.0.0)
|
net-scp (2.0.0)
|
||||||
net-ssh (>= 2.6.5, < 6.0.0)
|
net-ssh (>= 2.6.5, < 6.0.0)
|
||||||
net-ssh (5.2.0)
|
net-ssh (5.2.0)
|
||||||
nio4r (2.4.0)
|
nio4r (2.5.1)
|
||||||
nokogiri (1.10.3)
|
nokogiri (1.10.4)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
pdf-core (0.7.0)
|
pdf-core (0.7.0)
|
||||||
pdfjs_viewer-rails (0.3.1)
|
pdfjs_viewer-rails (0.3.1)
|
||||||
@@ -183,7 +183,7 @@ GEM
|
|||||||
puma (3.12.1)
|
puma (3.12.1)
|
||||||
rack (2.0.7)
|
rack (2.0.7)
|
||||||
rack-cors (1.0.3)
|
rack-cors (1.0.3)
|
||||||
rack-protection (2.0.5)
|
rack-protection (2.0.7)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
@@ -202,7 +202,7 @@ GEM
|
|||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
rails-html-sanitizer (1.1.0)
|
rails-html-sanitizer (1.2.0)
|
||||||
loofah (~> 2.2, >= 2.2.2)
|
loofah (~> 2.2, >= 2.2.2)
|
||||||
railties (5.1.7)
|
railties (5.1.7)
|
||||||
actionpack (= 5.1.7)
|
actionpack (= 5.1.7)
|
||||||
@@ -251,9 +251,8 @@ GEM
|
|||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
tilt (>= 1.1, < 3)
|
tilt (>= 1.1, < 3)
|
||||||
sassc (2.0.1)
|
sassc (2.2.0)
|
||||||
ffi (~> 1.9)
|
ffi (~> 1.9)
|
||||||
rake
|
|
||||||
schema_to_scaffold (0.8.0)
|
schema_to_scaffold (0.8.0)
|
||||||
activesupport (>= 3.2.1)
|
activesupport (>= 3.2.1)
|
||||||
shoulda-matchers (3.1.3)
|
shoulda-matchers (3.1.3)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
access_code = params[:access_code]
|
access_code = params[:access_code]
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
sale = Sale.find_by_sale_id(sale_id)
|
sale = Sale.find_by_sale_id(sale_id)
|
||||||
|
puts sale.to_json
|
||||||
if sale.discount_type == "member_discount"
|
if sale.discount_type == "member_discount"
|
||||||
sale.update_attributes(total_discount: 0)
|
sale.update_attributes(total_discount: 0)
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
#compute - invoice total
|
#compute - invoice total
|
||||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
|
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil,type=nil)
|
||||||
shop = Shop.first
|
shop = Shop.first
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sales_items = sale_itemss
|
sales_items = sale_itemss
|
||||||
@@ -473,20 +473,23 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
sales_items.each do |item|
|
sales_items.each do |item|
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
|
|
||||||
# check for item is taxable and calculate
|
# check for item is taxable and calculate
|
||||||
if item.is_taxable
|
if item.is_taxable
|
||||||
total_taxable = total_taxable + item.taxable_price
|
total_taxable = total_taxable + item.taxable_price
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
|
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
|
||||||
|
|
||||||
sale.total_amount = subtotal_price
|
sale.total_amount = subtotal_price
|
||||||
sale.total_discount = total_discount
|
sale.total_discount = total_discount
|
||||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
if type =="foc"
|
||||||
sale.grand_total_round
|
sale.grand_total = 0
|
||||||
|
else
|
||||||
|
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
||||||
|
sale.grand_total_round
|
||||||
|
end
|
||||||
|
|
||||||
if discount_type == "member_discount"
|
if discount_type == "member_discount"
|
||||||
sale.discount_type = discount_type
|
sale.discount_type = discount_type
|
||||||
end
|
end
|
||||||
@@ -2955,13 +2958,10 @@ end
|
|||||||
|
|
||||||
#not to show decimal in grand total
|
#not to show decimal in grand total
|
||||||
def grand_total_round
|
def grand_total_round
|
||||||
shop =Shop.first
|
print_settings = PrintSetting.get_precision_delimiter()
|
||||||
print_settings = PrintSetting.get_precision_delimiter()
|
if !print_settings.nil?
|
||||||
if !print_settings.nil?
|
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
||||||
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
end
|
||||||
puts self.grand_total
|
|
||||||
puts "Hello grand_total_round"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,10 @@ class SaleItem < ApplicationRecord
|
|||||||
# sale_item.is_taxable = 1
|
# sale_item.is_taxable = 1
|
||||||
# sale_item.sale_id = sale_id
|
# sale_item.sale_id = sale_id
|
||||||
# sale_item.save
|
# sale_item.save
|
||||||
sale = Sale.find(sale_id)
|
if type != "foc"
|
||||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
sale = Sale.find(sale_id)
|
||||||
|
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_order_items_details(sale_id)
|
def self.get_order_items_details(sale_id)
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class SalePayment < ApplicationRecord
|
|||||||
amount_due = amount_due - payment.payment_amount
|
amount_due = amount_due - payment.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (amount_due >= 0)
|
if (amount_due >= 0)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
membership_data = nil
|
membership_data = nil
|
||||||
@@ -419,6 +418,8 @@ class SalePayment < ApplicationRecord
|
|||||||
sale_items.each do|item|
|
sale_items.each do|item|
|
||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
end
|
end
|
||||||
|
sale = Sale.find(self.sale.sale_id)
|
||||||
|
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,'','','',"foc")
|
||||||
|
|
||||||
self.payment_method = "foc"
|
self.payment_method = "foc"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
|
|||||||
@@ -103,9 +103,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
|
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
||||||
</li>
|
</li> -->
|
||||||
<% if order_reservation %>
|
<% if order_reservation %>
|
||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_order_reservation_index_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
|
<a href="<%= reports_order_reservation_index_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
|
||||||
@@ -289,9 +289,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_hourly_saleitem_index_path %>">Hourly Sale Items</a>
|
<a href="<%= reports_hourly_saleitem_index_path %>">Hourly Sale Items</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
||||||
</li>
|
</li> -->
|
||||||
<% if order_reservation %>
|
<% if order_reservation %>
|
||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_order_reservation_index_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
|
<a href="<%= reports_order_reservation_index_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
|
||||||
|
|||||||
Reference in New Issue
Block a user