Project

icms

0.0
No commit activity in last 3 years
No release in over 3 years
Calculate ICMS between states.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
 Project Readme

Icms

Icms implements the new icms tax table between states http://guiatributario.net/2015/04/20/nova-sistematica-de-recolhimento-do-icms-interestadual-a-partir-de-16072015/.

Installation

Add this line to your application's Gemfile:

gem 'icms'

And then execute:

$ bundle

Or install it yourself as:

$ gem install icms

Usage

First of all create a new instance of Icms::States passing the taxes rates and the separator. example:

state_rates = Icms::StateRates.new

# Use get_percentual to get the value between two states
puts state_rates.get_percentual(:SP, :AC) # 7.0
puts state_rates.get_percentual(:AC, :SP) # 12.0

# Passing only source state will return that state rate
puts state_rates.get_percentual(:SP) # 18.0

# To obtain all informations about the source and destination state use `get`
result = state_rates.get(:AC, :SP) # <destination_state=18.0, source_state=17.0, between=12.0>
puts result.source_state # AC: 17.0
puts result.destination_state # AC: 18.0
puts result.between # AC -> SP: 12.0



# You can use a custom rates table instead of using the default table in Icms module
# Rates table
TABLE = <<-TABLE
AC,AL,AM,AP,BA,CE,DF,ES,GO,MA,MT,MS,MG,PA,PB,PR,PE,PI,RN,RS,RJ,RO,RR,SC,SP,SE,TO
--
AC,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
AL,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
AM,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
AP,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
BA,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
CE,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
DF,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
ES,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
GO,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
MA,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
MT,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
MS,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
MG,7,7,7,7,7,7,7,7,7,7,7,7,18,7,7,12,7,7,7,12,12,7,7,12,12,7,7
PA,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12,12
PB,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12,12,12
PR,7,7,7,7,7,7,7,7,7,7,7,7,12,7,7,18,7,7,7,12,12,7,7,12,12,7,7
PE,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12,12
PI,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12,12
RN,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12,12,12,12
RS,7,7,7,7,7,7,7,7,7,7,7,7,12,7,7,12,7,7,7,17,12,7,7,12,12,7,7
RJ,7,7,7,7,7,7,7,7,7,7,7,7,12,7,7,12,7,7,7,12,19,7,7,12,12,7,7
RO,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12,12
RR,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,12,12,12
SC,7,7,7,7,7,7,7,7,7,7,7,7,12,7,7,12,7,7,7,12,12,7,7,17,12,7,7
SP,7,7,7,7,7,7,7,7,7,7,7,7,12,7,7,12,7,7,7,12,12,7,7,12,18,7,7
SE,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12
TO,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,17
TABLE

separator = ','

state_rates = Icms::StateRates.new(table, separator)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/icms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.