All Projects → fastruby → afip_bill

fastruby / afip_bill

Licence: MIT license
A small library to generate a bill's PDF

Programming Languages

HTML
75241 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to afip bill

microformats-ruby
Ruby gem that parse HTML containing microformats/microformats2 and returns Ruby objects, a Ruby hash or a JSON hash
Stars: ✭ 89 (+368.42%)
Mutual labels:  rubygems
rails-mini-profiler
Performance profiling for Rails, made simple 🦔
Stars: ✭ 380 (+1900%)
Mutual labels:  rubygems
slack neuralyzer
Ruby gem for clean up messages and files on Slack.
Stars: ✭ 58 (+205.26%)
Mutual labels:  rubygems
fcmpush
Firebase Cloud Messaging API wrapper for Ruby, suppot HTTP v1 API including access_token auto refresh feature.
Stars: ✭ 44 (+131.58%)
Mutual labels:  rubygems
harvesting
Ruby wrapper for the Harvest API v2
Stars: ✭ 24 (+26.32%)
Mutual labels:  rubygems
sinator
Sinatra application generator
Stars: ✭ 19 (+0%)
Mutual labels:  rubygems
waxseal
Big official brass stamp to make signing gems dead simple.
Stars: ✭ 21 (+10.53%)
Mutual labels:  rubygems
middleman-robots
middleman-robots is extension of Middleman. This extension create robots.txt by config.rb.
Stars: ✭ 33 (+73.68%)
Mutual labels:  rubygems
vultr.rb
Ruby bindings for VULTR API v2.
Stars: ✭ 47 (+147.37%)
Mutual labels:  rubygems
gemdiff
Find source repositories for ruby gems. Open, compare, and update outdated gem versions
Stars: ✭ 116 (+510.53%)
Mutual labels:  rubygems
tss-rb
A Ruby implementation of Threshold Secret Sharing (Shamir) as defined in IETF Internet-Draft draft-mcgrew-tss-03.txt
Stars: ✭ 22 (+15.79%)
Mutual labels:  rubygems
material-sass
A rubygem of Material Design for Bootstrap 4
Stars: ✭ 55 (+189.47%)
Mutual labels:  rubygems
drunker
Distributed CLI runner on AWS CodeBuild
Stars: ✭ 22 (+15.79%)
Mutual labels:  rubygems
The-Ruby-Workshop
A New, Interactive Approach to Learning Ruby
Stars: ✭ 26 (+36.84%)
Mutual labels:  rubygems
crm114.rb
[Retired] Ruby interface to the CRM114 Controllable Regex Mutilator.
Stars: ✭ 29 (+52.63%)
Mutual labels:  rubygems
vital
Design Framework
Stars: ✭ 53 (+178.95%)
Mutual labels:  rubygems
rubysec.github.io
Current home of rubysec.com
Stars: ✭ 25 (+31.58%)
Mutual labels:  rubygems
account invoice ar
Tryton module with AFIP WS integration
Stars: ✭ 15 (-21.05%)
Mutual labels:  afip
ruby-sensor
💎 Ruby Distributed Tracing & Metrics Sensor for Instana
Stars: ✭ 23 (+21.05%)
Mutual labels:  rubygems
awesome-rails-security
A curated list of security resources for a Ruby on Rails application
Stars: ✭ 36 (+89.47%)
Mutual labels:  rubygems

AfipBill

AfipBill allows you to generate an AFIP bill in PDF format.

The end result will look like this: bill_sample.pdf

Installation

Include the gem in your Gemfile

gem 'afip_bill'

Install it

$ bundle install

Setup

In order to have the bills fully complete, you will need to setup some configuration about your business. If you're in a Rails application you can place that in config/initializers/afip_bill.rb

AfipBill.configuration[:header_business_name] = "Company Name"
AfipBill.configuration[:business_name] = "CompanyName SRL"
AfipBill.configuration[:business_address] = "Address 1234"
AfipBill.configuration[:business_start_date] = "01/01/2016"
AfipBill.configuration[:business_cuit] = "1234567890"
AfipBill.configuration[:city] = "Ciudad de Buenos Aires"
AfipBill.configuration[:ingresos_brutos] = "123-456789-0"
AfipBill.configuration[:iva] = "IVA Responsable Inscripto"
AfipBill.configuration[:sale_point] = "0001"

Also, one of the main things that you need to have, is a JSON for each of your bills. It must contain at least these attributes:

json_bill = {
  cae: "1234567890123",       # CAE number
  cae_due_date: "20171125",   # CAE expiry date
  doc_num: "12345678901",     # CUIT number
  cbte_tipo: "01",            # Bill type (01 = A, 06 = B, 11 = C)
  cbte_fch: "20170125",       # Bill date
  imp_neto: 220.0,            # Net amount
  imp_iva: 46.2,              # IVA amount
  imp_total: 266.2,           # Total amount
  cbte_hasta: 1,              # Voucher number
  fch_serv_desde: "20170101", # Invoiced from
  fch_serv_hasta: "20170131", # Invoiced to
  fch_vto_pago: "20170115"    # CAE expiration date
}.to_json

In OmbuShop, we like to automatically generate this JSON using Bravo.

Usage

There are three important classes that you need to use: AfipBill::User, AfipBill::LineItem and AfipBill::Generator.

AfipBill::User

You should create a new instance of this class to provide some information about the bill. It receives four parameters: Company name, Owner name, Address, and Tax category.

user = AfipBill::User.new("Bill company name",
                          "Bill owner name",
                          "Bill address",
                          "Bill tax category")

AfipBill::LineItem

With this class you can define the line items for your bill. It receives three parameters: Name, Quantity, and Unit amount.

item_1 = AfipBill::LineItem.new("Item 1", 1, 100)
item_2 = AfipBill::LineItem.new("Item 2", 1, 120)
...

AfipBill::Generator

This class will generate the PDF bill. It receives three parameters: the json bill, the user, and the array of line items (all the parameters were defined above)

generator = AfipBill::Generator.new(json_bill, user, [item_1, item_2])

And finally you can render the PDF by using the generate_pdf_string method

generator.generate_pdf_string

Or if you're in a Rails app you can render it like this:

respond_to do |format|
  format.pdf { render text: generator.generate_pdf_string }
end

Special Thanks

AfipBill was inspired in code by nubis and gastonconcilio.

Initial development of this gem was sponsored by OmbuShop.

Thank you!

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].