Class: Ksef::Client::Receipt
- Inherits:
-
Data
- Object
- Data
- Ksef::Client::Receipt
- Defined in:
- lib/ksef/client/receipt.rb
Overview
What #send_invoice returns: proof that KSeF accepted the upload, and the pair of references needed to find out what became of the invoice.
Why #reference returns the whole object
DESIGN.md §8's contract reads client.wait_until_accepted(result.reference), which
looks like it wants a single string. It cannot be one: every status and UPO endpoint is
keyed on both the session and the invoice (GET /sessions/{ref}/invoices/{ref}), so
an invoice reference on its own cannot look anything up.
Rather than bend the API into passing two arguments, or hiding the session on a client
that has to stay thread-safe, #reference returns self — because the pair genuinely
is the reference of a submission. §8's snippet then runs verbatim, and nothing has to
remember which session an invoice went through.
Note what this is not: acceptance. POST .../invoices answers 202, meaning the
upload was taken, and whether the invoice itself is accepted arrives asynchronously
(§12.1). #wait_until_accepted is what settles that.
Instance Attribute Summary collapse
-
#invoice_reference ⇒ Object
readonly
Returns the value of attribute invoice_reference.
-
#session_reference ⇒ Object
readonly
Returns the value of attribute session_reference.
-
#session_valid_until ⇒ Object
readonly
Returns the value of attribute session_valid_until.
Instance Method Summary collapse
-
#reference ⇒ Object
See the class note: the pair is the reference.
-
#session_expired?(now = Time.now) ⇒ Boolean
The session closes itself at this point (§11), after which the collective UPO is generated.
-
#to_s ⇒ Object
The invoice's own reference number, which is what a human quotes.
Instance Attribute Details
#invoice_reference ⇒ Object (readonly)
Returns the value of attribute invoice_reference
23 24 25 |
# File 'lib/ksef/client/receipt.rb', line 23 def invoice_reference @invoice_reference end |
#session_reference ⇒ Object (readonly)
Returns the value of attribute session_reference
23 24 25 |
# File 'lib/ksef/client/receipt.rb', line 23 def session_reference @session_reference end |
#session_valid_until ⇒ Object (readonly)
Returns the value of attribute session_valid_until
23 24 25 |
# File 'lib/ksef/client/receipt.rb', line 23 def session_valid_until @session_valid_until end |
Instance Method Details
#reference ⇒ Object
See the class note: the pair is the reference.
25 |
# File 'lib/ksef/client/receipt.rb', line 25 def reference = self |
#session_expired?(now = Time.now) ⇒ Boolean
The session closes itself at this point (§11), after which the collective UPO is generated. Exposed because a long batch may want to check rather than assume.
32 33 34 |
# File 'lib/ksef/client/receipt.rb', line 32 def session_expired?(now = Time.now) !session_valid_until.nil? && session_valid_until <= now end |
#to_s ⇒ Object
The invoice's own reference number, which is what a human quotes.
28 |
# File 'lib/ksef/client/receipt.rb', line 28 def to_s = invoice_reference.to_s |