Git Product home page Git Product logo

sunat-ruby's Introduction

SUNAT Declaration Generator

Easily generate declarations for SUNAT, Peru's state tax collection entity.

Installation

Add this line to your application's Gemfile:

gem 'sunat'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sunat

Configuration

Prepare the SUNAT library by defining the configuration somewhere in your project as follows:

SUNAT.configure do |config| config.credentials do |c| # Regular credentials provided by SUNAT c.ruc = "123456780" c.username = "USERNAME" c.password = "PASSWORD" end

config.signature do |s|
  # A company ID (Should be RUC)
  s.party_id    = "20100454523"

  # The name of the company
  s.party_name  = "SOPORTE TECNOLOGICO EIRL"

  # SUNAT validated certificate
  s.cert_file   = File.join(Dir.pwd, 'config', 'keys', 'sunat.crt')

  # Password-less private key used to sign certificate
  s.pk_file     = File.join(Dir.pwd, 'config', 'keys', 'sunat.key')
end

# General Company details to be included in every document generated.
# Only used if no alternative is provided.
config.supplier do |s|
  s.ruc        = "20100454523"
  s.name       = "SOPORTE TECNOLOGICO EIRL"
  s.address_id = "070101"
  s.street     = "Calle los Olivos 234"
  s.city       = "Lima"
  s.district   = "Callao"
  s.country    = "PE"
end

end

Testing

Set the next ENV variables: SUNAT_RUC, SUNAT_USERNAME and SUNAT_PASSWORD. They must be secret!

In Fish:

set -gx SUNAT_RUC ruc # ruc set -gx SUNAT_USERNAME username # sol user set -gx SUNAT_PASSWORD password # sol password

In Bash:

export SUNAT_RUC=ruc # ruc export SUNAT_USERNAME=username # sol user export SUNAT_PASSWORD=password # sol password

Serialization

Every model can be serialized and de-serialized from JSON. This is extremely useful for storing a declaration a more readily usable form.

Homologation

SUNAT requires that all clients of their system first go through a homolgation process to test all possible combinations of invoices, receipts, credit and debit notes, and summary documents.

Its an increadibly teadious process made more frustrating by the fact you probably only need a couple of standard documents for your project. Fortunately, this library makes the process a bit simpler by including the default set of test cases. Simply enter the homologation directory, create your own config.rb file, and call rake. All of the available yaml definitions in the cases directory will be compiled and sent to SUNAT using your own details.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Authors

Creation of the sunay-ruby library was sponsored by Cabify.

sunat-ruby's People

Contributors

juliogarciag avatar samlown avatar

Watchers

Ernesto Anaya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.