tax
This commit is contained in:
@@ -45,7 +45,7 @@ class Settings::TaxProfilesController < ApplicationController
|
|||||||
# POST /settings/tax_profiles
|
# POST /settings/tax_profiles
|
||||||
# POST /settings/tax_profiles.json
|
# POST /settings/tax_profiles.json
|
||||||
def create
|
def create
|
||||||
|
|
||||||
@settings_tax_profile = TaxProfile.new(settings_tax_profile_params)
|
@settings_tax_profile = TaxProfile.new(settings_tax_profile_params)
|
||||||
@settings_tax_profile.created_by = current_login_employee.name
|
@settings_tax_profile.created_by = current_login_employee.name
|
||||||
respond_to do |format|
|
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.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def settings_tax_profile_params
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -486,15 +486,18 @@ class Sale < ApplicationRecord
|
|||||||
# substract , to give after discount
|
# substract , to give after discount
|
||||||
total_tax = total_taxable - total_discount
|
total_tax = total_taxable - total_discount
|
||||||
#include or execulive
|
#include or execulive
|
||||||
if tax.inclusive
|
if tax.tax_type.to_s =="Net"
|
||||||
tax_incl_exec = "inclusive"
|
sale_tax.tax_payable_amount = tax.rate
|
||||||
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
|
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
|
end
|
||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
|
|
||||||
@@ -609,16 +612,19 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# substract , to give after discount
|
# substract , to give after discount
|
||||||
total_tax = total_taxable - self.total_discount
|
total_tax = total_taxable - self.total_discount
|
||||||
#include or execulive
|
if tax.tax_type.to_s =="Net"
|
||||||
if tax.inclusive
|
sale_tax.tax_payable_amount = tax.rate
|
||||||
tax_incl_exec = "inclusive"
|
|
||||||
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
|
#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
|
end
|
||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
|
|
||||||
@@ -2048,7 +2054,6 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unique_tax_profiles(order_source, customer_id)
|
def unique_tax_profiles(order_source, customer_id)
|
||||||
puts "unique_tax_profiles unique_tax_profiles"
|
|
||||||
tax_data = TaxProfile.where(group_type: order_source)
|
tax_data = TaxProfile.where(group_type: order_source)
|
||||||
|
|
||||||
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class TaxProfile < ApplicationRecord
|
|||||||
def self.calculate_tax(group_type)
|
def self.calculate_tax(group_type)
|
||||||
divided_value =0.0
|
divided_value =0.0
|
||||||
exclusive =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?
|
if !tax_profiles.empty?
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
#include or execulive
|
#include or execulive
|
||||||
|
|||||||
@@ -345,9 +345,14 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
if st.tax_rate.to_i == st.tax_payable_amount.to_i
|
||||||
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
|
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
|
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
|
end
|
||||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
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
|
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
|||||||
@@ -405,9 +405,14 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
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
|
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
|
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
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
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
|
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
|||||||
@@ -341,9 +341,14 @@ class ReceiptBillStarPdf < Prawn::Document
|
|||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
move_down line_move
|
move_down line_move
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
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
|
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
|
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
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
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
|
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
<%= f.input :group_type, :collection => Lookup.collection_of("tax_profiles"),:input_html=>{:class=>"col-md-10"},:required=>true %>
|
<%= 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 :name, :input_html=>{:onchange=>"checkDuplicate(this.value);"} %>
|
||||||
<span id="tax_profile_nameErr" style="color:red;"></span>
|
<span id="tax_profile_nameErr" style="color:red;"></span>
|
||||||
|
<%= f.input :tax_type,input_html: { :class => 'form-control select' },
|
||||||
|
collection: %w{Net Percentage},:label => "Tax Type" %>
|
||||||
<%= f.input :rate %>
|
<%= f.input :rate %>
|
||||||
<%= f.input :inclusive %>
|
<%= f.input :inclusive %>
|
||||||
<%= f.input :order_by %>
|
<%= 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") %> <br>
|
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.tax_profiles_txt") %> <br>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -69,4 +71,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
5
db/migrate/20200226124607_add_column_tax_type.rb
Normal file
5
db/migrate/20200226124607_add_column_tax_type.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddColumnTaxType < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
add_column :tax_profiles, :tax_type, :string, default: "Percentage"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user