Module: Ksef::FA3
- Defined in:
- lib/ksef/fa3.rb,
lib/ksef/fa3/nip.rb,
lib/ksef/fa3/line.rb,
lib/ksef/fa3/issue.rb,
lib/ksef/fa3/order.rb,
lib/ksef/fa3/parser.rb,
lib/ksef/fa3/totals.rb,
lib/ksef/fa3/address.rb,
lib/ksef/fa3/builder.rb,
lib/ksef/fa3/invoice.rb,
lib/ksef/fa3/subject.rb,
lib/ksef/fa3/vat_rate.rb,
lib/ksef/fa3/canonical.rb,
lib/ksef/fa3/summaries.rb,
lib/ksef/fa3/validator.rb,
lib/ksef/fa3/attachment.rb,
lib/ksef/fa3/correction.rb,
lib/ksef/fa3/data_block.rb,
lib/ksef/fa3/formatting.rb,
lib/ksef/fa3/meta_entry.rb,
lib/ksef/fa3/order_line.rb,
lib/ksef/fa3/provenance.rb,
lib/ksef/fa3/row_reader.rb,
lib/ksef/fa3/serializer.rb,
lib/ksef/fa3/node_reader.rb,
lib/ksef/fa3/element_tree.rb,
lib/ksef/fa3/field_checks.rb,
lib/ksef/fa3/table_column.rb,
lib/ksef/fa3/advance_checks.rb,
lib/ksef/fa3/advance_reader.rb,
lib/ksef/fa3/subject_checks.rb,
lib/ksef/fa3/subject_reader.rb,
lib/ksef/fa3/summary_checks.rb,
lib/ksef/fa3/advance_invoice.rb,
lib/ksef/fa3/generated/enums.rb,
lib/ksef/fa3/generated/types.rb,
lib/ksef/fa3/model_validator.rb,
lib/ksef/fa3/attachment_table.rb,
lib/ksef/fa3/builder/advances.rb,
lib/ksef/fa3/builder/subjects.rb,
lib/ksef/fa3/document_mapping.rb,
lib/ksef/fa3/attachment_checks.rb,
lib/ksef/fa3/attachment_reader.rb,
lib/ksef/fa3/corrected_invoice.rb,
lib/ksef/fa3/correction_checks.rb,
lib/ksef/fa3/correction_reader.rb,
lib/ksef/fa3/business_validator.rb,
lib/ksef/fa3/document_validator.rb,
lib/ksef/fa3/rounding_inference.rb,
lib/ksef/fa3/builder/corrections.rb
Overview
The FA(3) invoice builder. Has no HTTP dependency and is usable on its own
(DESIGN.md §5.1) — the transport layer accepts anything responding to #to_xml.
Defined Under Namespace
Modules: AdvanceChecks, AdvanceReader, AttachmentChecks, AttachmentReader, BusinessValidator, Canonical, CorrectionChecks, CorrectionReader, DocumentMapping, DocumentValidator, ElementTree, FieldChecks, Formatting, Generated, ModelValidator, NIP, NodeReader, Parser, Provenance, RoundingInference, RowReader, SubjectChecks, SubjectReader, Summaries, SummaryChecks, Validator, VatRate Classes: Address, AdvanceInvoice, Attachment, AttachmentTable, Builder, CorrectedInvoice, Correction, DataBlock, Invoice, Issue, Line, MetaEntry, Order, OrderLine, Serializer, Subject, TableColumn, Totals
Class Method Summary collapse
-
.build {|builder| ... } ⇒ Invoice
Build an Invoice through the keyword DSL of DESIGN.md §8.
-
.parse(xml) ⇒ Invoice
Read an FA(3) document back into an Invoice (DESIGN.md §7.6).
Class Method Details
.build {|builder| ... } ⇒ Invoice
Build an Invoice through the keyword DSL of DESIGN.md §8.
The DSL is a thin, forgiving front end over the value objects: it accepts English
shorthand (qty:, vat:), coerces a plain Hash into an Address, and reports a
missing or misspelled field by name instead of letting it surface later as a
schema rejection. Everything it produces could be constructed by hand; see the
README for the same invoice written the long way.
29 30 31 32 33 34 35 |
# File 'lib/ksef/fa3.rb', line 29 def build raise ArgumentError, "Ksef::FA3.build requires a block; see DESIGN.md §8" unless block_given? builder = Builder.new yield builder builder.to_invoice end |
.parse(xml) ⇒ Invoice
Read an FA(3) document back into an Invoice (DESIGN.md §7.6).
The inverse of #build only as far as this model reaches. FA(3) is much larger than
a plain VAT invoice, so the whole document is retained on
Ksef::FA3::Invoice#raw_document and Ksef::FA3::Provenance#unmapped_elements names what #to_xml would
drop. Check it before re-serialising anything you did not write yourself.
56 |
# File 'lib/ksef/fa3.rb', line 56 def parse(xml) = Parser.parse(xml) |