82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/facturacr/cli/generate.rb', line 82
def debit_note
data = YAML.load_file(options[:data_path]).with_indifferent_access
builder = FE::Builder.new
debit_note = builder.debit_note(data[:document])
if options[:invoice_number].present?
date = DateTime.parse(options[:invoice_date])
debit_note.references = [FE::Document::Reference.new(document_type: "01", code: "01", reason: "Anula documento", number: options[:invoice_number], date: date)]
end
debit_note.date = Time.now
debit_note.number = options[:number].to_i if options[:number].present?
if options[:output_path]
output_path = options[:output_path]
else
output_path = "tmp/#{debit_note.key}.xml"
end
write(debit_note, output_path)
print_details(debit_note)
sign(output_path, options) if options[:sign]
send_document("#{output_path}.signed.xml") if options[:sign] && options[:send]
end
|