{"id":19724160,"url":"https://github.com/fastruby/afip_bill","last_synced_at":"2025-04-29T22:31:13.561Z","repository":{"id":46968276,"uuid":"80021095","full_name":"fastruby/afip_bill","owner":"fastruby","description":"A small library to generate a bill's PDF","archived":false,"fork":false,"pushed_at":"2022-11-18T16:57:50.000Z","size":130,"stargazers_count":20,"open_issues_count":5,"forks_count":12,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-05T20:05:22.133Z","etag":null,"topics":["afip","factura-afip","pdf","ruby","rubygems"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-25T14:18:53.000Z","updated_at":"2023-07-03T14:25:33.000Z","dependencies_parsed_at":"2023-01-23T12:30:36.507Z","dependency_job_id":null,"html_url":"https://github.com/fastruby/afip_bill","commit_stats":null,"previous_names":["ombulabs/afip_bill"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fafip_bill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fafip_bill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fafip_bill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastruby%2Fafip_bill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastruby","download_url":"https://codeload.github.com/fastruby/afip_bill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251593015,"owners_count":21614458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["afip","factura-afip","pdf","ruby","rubygems"],"created_at":"2024-11-11T23:24:44.524Z","updated_at":"2025-04-29T22:31:13.176Z","avatar_url":"https://github.com/fastruby.png","language":"HTML","readme":"# AfipBill\n\nAfipBill allows you to generate an [AFIP](https://www.afip.gob.ar/) bill in PDF format.\n\nThe end result will look like this: [bill_sample.pdf](https://github.com/ombulabs/afip_bill/blob/master/bill_sample.pdf)\n\n## Installation\n\nInclude the gem in your Gemfile\n\n```ruby\ngem 'afip_bill'\n```\n\nInstall it\n```ruby\n$ bundle install\n```\n\n## Setup\n\nIn 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`\n\n```ruby\nAfipBill.configuration[:header_business_name] = \"Company Name\"\nAfipBill.configuration[:business_name] = \"CompanyName SRL\"\nAfipBill.configuration[:business_address] = \"Address 1234\"\nAfipBill.configuration[:business_start_date] = \"01/01/2016\"\nAfipBill.configuration[:business_cuit] = \"1234567890\"\nAfipBill.configuration[:city] = \"Ciudad de Buenos Aires\"\nAfipBill.configuration[:ingresos_brutos] = \"123-456789-0\"\nAfipBill.configuration[:iva] = \"IVA Responsable Inscripto\"\nAfipBill.configuration[:sale_point] = \"0001\"\n```\n\nAlso, one of the main things that you need to have, is a JSON for each of your bills.\nIt must contain at least these attributes:\n\n```ruby\njson_bill = {\n  cae: \"1234567890123\",       # CAE number\n  cae_due_date: \"20171125\",   # CAE expiry date\n  doc_num: \"12345678901\",     # CUIT number\n  cbte_tipo: \"01\",            # Bill type (01 = A, 06 = B, 11 = C)\n  cbte_fch: \"20170125\",       # Bill date\n  imp_neto: 220.0,            # Net amount\n  imp_iva: 46.2,              # IVA amount\n  imp_total: 266.2,           # Total amount\n  cbte_hasta: 1,              # Voucher number\n  fch_serv_desde: \"20170101\", # Invoiced from\n  fch_serv_hasta: \"20170131\", # Invoiced to\n  fch_vto_pago: \"20170115\"    # CAE expiration date\n}.to_json\n```\n\nIn [OmbuShop](https://www.ombushop.com/), we like to automatically generate this\nJSON using [Bravo](https://github.com/leanucci/bravo).\n\n## Usage\n\nThere are three important classes that you need to use: `AfipBill::User`,\n`AfipBill::LineItem` and `AfipBill::Generator`.\n\n### AfipBill::User\n\nYou 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`.\n\n```ruby\nuser = AfipBill::User.new(\"Bill company name\",\n                          \"Bill owner name\",\n                          \"Bill address\",\n                          \"Bill tax category\")\n```\n\n### AfipBill::LineItem\n\nWith this class you can define the line items for your bill. It receives three parameters: `Name`, `Quantity`, and `Unit amount`.\n\n```ruby\nitem_1 = AfipBill::LineItem.new(\"Item 1\", 1, 100)\nitem_2 = AfipBill::LineItem.new(\"Item 2\", 1, 120)\n...\n```\n\n### AfipBill::Generator\n\nThis 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)\n\n```ruby\ngenerator = AfipBill::Generator.new(json_bill, user, [item_1, item_2])\n```\n\nAnd finally you can render the PDF by using the `generate_pdf_string` method\n\n```ruby\ngenerator.generate_pdf_string\n```\n\nOr if you're in a Rails app you can render it like this:\n```ruby\nrespond_to do |format|\n  format.pdf { render text: generator.generate_pdf_string }\nend\n```\n\n## Special Thanks\n\nAfipBill was inspired in code by [nubis](https://github.com/nubis) and [gastonconcilio](https://github.com/gastonconcilio).\n\nInitial development of this gem was sponsored by [OmbuShop](http://www.ombushop.com).\n\nThank you!\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fafip_bill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastruby%2Fafip_bill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastruby%2Fafip_bill/lists"}