Class: FE::CLI::Generate
- Inherits:
-
Thor
- Object
- Thor
- FE::CLI::Generate
- Defined in:
- lib/facturacr/cli/generate.rb
Instance Method Summary collapse
Instance Method Details
#credit_note ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/facturacr/cli/generate.rb', line 44 def credit_note data = YAML.load_file([:data_path]).with_indifferent_access builder = FE::Builder.new credit_note = builder.credit_note(data[:document]) if [:invoice_number].present? date = DateTime.parse([:invoice_date]) credit_note.references = [FE::Document::Reference.new(document_type: "01", code: "01", reason: "Anula documento", number: [:invoice_number], date: date)] end credit_note.date = Time.now credit_note.number = [:number].to_i if [:number].present? if [:output_path] output_path = output_path else output_path = "tmp/#{credit_note.key}.xml" end write(credit_note, output_path) print_details(credit_note) sign(output_path, ) if [:sign] send_document("#{output_path}.signed.xml") if [:sign] && [:send] end |
#debit_note ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/facturacr/cli/generate.rb', line 79 def debit_note data = YAML.load_file([:data_path]).with_indifferent_access builder = FE::Builder.new debit_note = builder.debit_note(data[:document]) if [:invoice_number].present? date = DateTime.parse([:invoice_date]) debit_note.references = [FE::Document::Reference.new(document_type: "01", code: "01", reason: "Anula documento", number: [:invoice_number], date: date)] end debit_note.date = Time.now debit_note.number = [:number].to_i if [:number].present? if [:output_path] output_path = output_path else output_path = "tmp/#{debit_note.key}.xml" end write(debit_note, output_path) print_details(debit_note) sign(output_path, ) if [:sign] send_document("#{output_path}.signed.xml") if [:sign] && [:send] end |
#invoice ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/facturacr/cli/generate.rb', line 13 def invoice data = YAML.load_file([:data_path]).with_indifferent_access builder = FE::Builder.new invoice = builder.invoice(data[:document]) invoice.date = Time.now invoice.number = [:number].to_i if [:number].present? if [:output_path] output_path = output_path else output_path = "tmp/#{invoice.key}.xml" end write(invoice, output_path) print_details(invoice) sign(output_path, ) if [:sign] send_document("#{output_path}.signed.xml") if [:sign] && [:send] end |