From da0e7b0168645b77d180b3e99128b97ae0c11b28 Mon Sep 17 00:00:00 2001
From: Myat Zin Wai Maw
Date: Thu, 27 Feb 2020 10:17:24 +0630
Subject: [PATCH 1/4] tax
---
.../settings/tax_profiles_controller.rb | 4 +-
app/models/sale.rb | 37 +++++++++++--------
app/models/tax_profile.rb | 2 +-
app/pdf/receipt_bill_a5_pdf.rb | 11 ++++--
app/pdf/receipt_bill_pdf.rb | 11 ++++--
app/pdf/receipt_bill_star_pdf.rb | 11 ++++--
.../settings/tax_profiles/_form.html.erb | 5 ++-
.../20200226124607_add_column_tax_type.rb | 5 +++
8 files changed, 56 insertions(+), 30 deletions(-)
create mode 100644 db/migrate/20200226124607_add_column_tax_type.rb
diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb
index ddf4781a..9ad0b0fc 100755
--- a/app/controllers/settings/tax_profiles_controller.rb
+++ b/app/controllers/settings/tax_profiles_controller.rb
@@ -45,7 +45,7 @@ class Settings::TaxProfilesController < ApplicationController
# POST /settings/tax_profiles
# POST /settings/tax_profiles.json
def create
-
+
@settings_tax_profile = TaxProfile.new(settings_tax_profile_params)
@settings_tax_profile.created_by = current_login_employee.name
respond_to do |format|
@@ -109,6 +109,6 @@ class Settings::TaxProfilesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_tax_profile_params
- params.require(:tax_profile).permit(:name, :group_type, :rate, :inclusive, :order_by, :created_by)
+ params.require(:tax_profile).permit(:name, :group_type, :rate, :inclusive, :order_by, :created_by,:tax_type)
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index dd7cacf5..954674bb 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -486,15 +486,18 @@ class Sale < ApplicationRecord
# substract , to give after discount
total_tax = total_taxable - total_discount
#include or execulive
- if tax.inclusive
- tax_incl_exec = "inclusive"
- rate = tax.rate
- divided_value = (100 + rate)/rate
- sale_tax.tax_payable_amount = total_tax / divided_value
+ if tax.tax_type.to_s =="Net"
+ sale_tax.tax_payable_amount = tax.rate
else
- sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ if tax.inclusive
+ tax_incl_exec = "inclusive"
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ end
end
-
sale_tax.inclusive = tax.inclusive
sale_tax.save
@@ -609,16 +612,19 @@ class Sale < ApplicationRecord
# substract , to give after discount
total_tax = total_taxable - self.total_discount
- #include or execulive
- if tax.inclusive
- tax_incl_exec = "inclusive"
- rate = tax.rate
- divided_value = (100 + rate)/rate
- sale_tax.tax_payable_amount = total_tax / divided_value
+ if tax.tax_type.to_s =="Net"
+ sale_tax.tax_payable_amount = tax.rate
else
- sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ #include or execulive
+ if tax.inclusive
+ tax_incl_exec = "inclusive"
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ end
end
-
sale_tax.inclusive = tax.inclusive
sale_tax.save
@@ -2048,7 +2054,6 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
end
def unique_tax_profiles(order_source, customer_id)
- puts "unique_tax_profiles unique_tax_profiles"
tax_data = TaxProfile.where(group_type: order_source)
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
diff --git a/app/models/tax_profile.rb b/app/models/tax_profile.rb
index 5d85239d..955d58fa 100755
--- a/app/models/tax_profile.rb
+++ b/app/models/tax_profile.rb
@@ -7,7 +7,7 @@ class TaxProfile < ApplicationRecord
def self.calculate_tax(group_type)
divided_value =0.0
exclusive =0.0
- tax_profiles = TaxProfile.where(group_type: group_type)
+ tax_profiles = TaxProfile.where(group_type: group_type,tax_type: 'Percentage')
if !tax_profiles.empty?
tax_profiles.each do |tax|
#include or execulive
diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb
index 9c60cd6b..5b5e3eac 100644
--- a/app/pdf/receipt_bill_a5_pdf.rb
+++ b/app/pdf/receipt_bill_a5_pdf.rb
@@ -345,9 +345,14 @@ class ReceiptBillA5Pdf < Prawn::Document
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
-
- bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
- text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ if st.tax_rate.to_i == st.tax_payable_amount.to_i
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
+ end
+ else
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ end
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 2f8ba8ed..ba10e064 100755
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -405,9 +405,14 @@ class ReceiptBillPdf < Prawn::Document
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
-
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ if st.tax_rate.to_i == st.tax_payable_amount.to_i
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
+ end
+ else
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ end
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb
index 0670b2f9..147ef430 100644
--- a/app/pdf/receipt_bill_star_pdf.rb
+++ b/app/pdf/receipt_bill_star_pdf.rb
@@ -341,9 +341,14 @@ class ReceiptBillStarPdf < Prawn::Document
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
-
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ if st.tax_rate.to_i == st.tax_payable_amount.to_i
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
+ end
+ else
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
+ end
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
diff --git a/app/views/settings/tax_profiles/_form.html.erb b/app/views/settings/tax_profiles/_form.html.erb
index bfc4c314..b0254690 100755
--- a/app/views/settings/tax_profiles/_form.html.erb
+++ b/app/views/settings/tax_profiles/_form.html.erb
@@ -12,6 +12,8 @@
<%= f.input :group_type, :collection => Lookup.collection_of("tax_profiles"),:input_html=>{:class=>"col-md-10"},:required=>true %>
<%= f.input :name, :input_html=>{:onchange=>"checkDuplicate(this.value);"} %>
+ <%= f.input :tax_type,input_html: { :class => 'form-control select' },
+ collection: %w{Net Percentage},:label => "Tax Type" %>
<%= f.input :rate %>
<%= f.input :inclusive %>
<%= f.input :order_by %>
@@ -44,7 +46,7 @@
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.tax_profiles_txt") %>
-
+
@@ -69,4 +71,3 @@
}
}
-
diff --git a/db/migrate/20200226124607_add_column_tax_type.rb b/db/migrate/20200226124607_add_column_tax_type.rb
new file mode 100644
index 00000000..a00a3a35
--- /dev/null
+++ b/db/migrate/20200226124607_add_column_tax_type.rb
@@ -0,0 +1,5 @@
+class AddColumnTaxType < ActiveRecord::Migration[5.1]
+ def change
+ add_column :tax_profiles, :tax_type, :string, default: "Percentage"
+ end
+end
From 0868697b113e8b6b96bff033e720a4298177b287 Mon Sep 17 00:00:00 2001
From: Zin Moe
Date: Thu, 27 Feb 2020 10:54:10 +0630
Subject: [PATCH 2/4] fix page scroll
---
app/assets/javascripts/custom.js | 4 ++--
app/views/foodcourt/addorders/detail.html.erb | 2 +-
app/views/foodcourt/orders/app_orders.html.erb | 2 +-
app/views/inventory/inventory_definitions/_form.html.erb | 2 +-
app/views/inventory/stock_checks/index.html.erb | 2 +-
app/views/origami/addorders/detail.html.erb | 2 +-
app/views/origami/home/show.html.erb | 2 +-
app/views/origami/pending_order/show.html.erb | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js
index abde0bd5..620b9321 100644
--- a/app/assets/javascripts/custom.js
+++ b/app/assets/javascripts/custom.js
@@ -24,8 +24,8 @@ $(document).ready(function() {
});
$('#order-detail-slimscroll').slimScroll({
- height: $('#order-detail-slimscroll').attr('data-height'),
- // height: height-$('#order-detail-slimscroll').attr('data-height'),
+ // height: $('#order-detail-slimscroll').attr('data-height'),
+ height: height-$('#order-detail-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
diff --git a/app/views/foodcourt/addorders/detail.html.erb b/app/views/foodcourt/addorders/detail.html.erb
index d640e94c..7b639931 100644
--- a/app/views/foodcourt/addorders/detail.html.erb
+++ b/app/views/foodcourt/addorders/detail.html.erb
@@ -165,7 +165,7 @@
-
+
diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb
index f84e1434..03e922f4 100644
--- a/app/views/foodcourt/orders/app_orders.html.erb
+++ b/app/views/foodcourt/orders/app_orders.html.erb
@@ -103,7 +103,7 @@
-
+
diff --git a/app/views/inventory/inventory_definitions/_form.html.erb b/app/views/inventory/inventory_definitions/_form.html.erb
index ada37e7b..f5d3a245 100644
--- a/app/views/inventory/inventory_definitions/_form.html.erb
+++ b/app/views/inventory/inventory_definitions/_form.html.erb
@@ -79,7 +79,7 @@
-
+
diff --git a/app/views/inventory/stock_checks/index.html.erb b/app/views/inventory/stock_checks/index.html.erb
index 2ab89ba4..0d9f03a5 100644
--- a/app/views/inventory/stock_checks/index.html.erb
+++ b/app/views/inventory/stock_checks/index.html.erb
@@ -37,7 +37,7 @@
-
+
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 2a683c25..a54ef431 100644
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -243,7 +243,7 @@
-
+
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index f6f5373d..ef8e8e3d 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -276,7 +276,7 @@
-