Class: Ksef::FA3::OrderLine
- Inherits:
-
Data
- Object
- Data
- Ksef::FA3::OrderLine
- Includes:
- Canonical
- Defined in:
- lib/ksef/fa3/order_line.rb
Overview
One position of the order or contract an advance invoice relates to
(Zamowienie/ZamowienieWiersz).
Nothing here is derived, and that is the difference from Line
Line#net computes a net from quantity × price when the document does not state one,
because a VAT invoice's tax summary is computed from its rows. An order's rows feed
nothing: WartoscZamowienia is stated, and so are the invoice's own buckets — every type
that carries a Zamowienie is in Invoice::STATED_TOTALS_TYPES. So a derivation here
would have no consumer, and inventing an amount the contract does not state is the thing
this model spends its effort avoiding (docs/REFERENCE.md §8.5).
The tax is stated too, in P_11VatZ — "kwota podatku od zamówionego towaru lub
usługi". FaWiersz has no such element and the tax is computed from the rate; here the
document carries both, so both are read.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#net_amount ⇒ Object
readonly
Returns the value of attribute net_amount.
-
#net_unit_price ⇒ Object
readonly
Returns the value of attribute net_unit_price.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#row_number ⇒ Object
readonly
Returns the value of attribute row_number.
-
#state_before ⇒ Object
readonly
Returns the value of attribute state_before.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#vat_amount ⇒ Object
readonly
Returns the value of attribute vat_amount.
-
#vat_rate ⇒ Object
readonly
Returns the value of attribute vat_rate.
Instance Method Summary collapse
-
#initialize(name: nil, quantity: nil, unit: nil, net_unit_price: nil, net_amount: nil, vat_amount: nil, vat_rate: nil, row_number: nil, state_before: false) ⇒ OrderLine
constructor
Every element of
ZamowienieWierszexceptNrWierszaZamisminOccurs="0", so every field here is optional and an absent one is omitted rather than written empty. -
#to_fa3(row_number:) ⇒ Object
StanPrzedZisStanPrzed's twin for an order position: aKOR_ZALshows a corrected position before and after as separate rows.
Methods included from Canonical
Constructor Details
#initialize(name: nil, quantity: nil, unit: nil, net_unit_price: nil, net_amount: nil, vat_amount: nil, vat_rate: nil, row_number: nil, state_before: false) ⇒ OrderLine
Every element of ZamowienieWiersz except NrWierszaZam is minOccurs="0", so every
field here is optional and an absent one is omitted rather than written empty.
P_9AZ is TKwotowy2, not TKwotowy — the same eight-place unit price as Line's
P_9A, and rounded to the same scale for the same reason.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ksef/fa3/order_line.rb', line 30 def initialize(name: nil, quantity: nil, unit: nil, net_unit_price: nil, net_amount: nil, vat_amount: nil, vat_rate: nil, row_number: nil, state_before: false) super( name: Formatting.text(name), unit: Formatting.text(unit), vat_rate: Formatting.text(vat_rate), quantity: Line.scaled(quantity, Formatting::QUANTITY_SCALE), net_unit_price: Line.scaled(net_unit_price, Formatting::UNIT_PRICE_SCALE), net_amount: Line.scaled(net_amount, Formatting::AMOUNT_SCALE), vat_amount: Line.scaled(vat_amount, Formatting::AMOUNT_SCALE), row_number: row_number.nil? ? nil : Formatting.integer(row_number), state_before: Formatting.unflag(state_before) ) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def name @name end |
#net_amount ⇒ Object (readonly)
Returns the value of attribute net_amount
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def net_amount @net_amount end |
#net_unit_price ⇒ Object (readonly)
Returns the value of attribute net_unit_price
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def net_unit_price @net_unit_price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def quantity @quantity end |
#row_number ⇒ Object (readonly)
Returns the value of attribute row_number
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def row_number @row_number end |
#state_before ⇒ Object (readonly)
Returns the value of attribute state_before
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def state_before @state_before end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def unit @unit end |
#vat_amount ⇒ Object (readonly)
Returns the value of attribute vat_amount
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def vat_amount @vat_amount end |
#vat_rate ⇒ Object (readonly)
Returns the value of attribute vat_rate
20 21 22 |
# File 'lib/ksef/fa3/order_line.rb', line 20 def vat_rate @vat_rate end |
Instance Method Details
#to_fa3(row_number:) ⇒ Object
StanPrzedZ is StanPrzed's twin for an order position: a KOR_ZAL shows a corrected
position before and after as separate rows. Same shape, same pairing by row number.
48 49 50 51 52 53 54 55 56 |
# File 'lib/ksef/fa3/order_line.rb', line 48 def to_fa3(row_number:) { "NrWierszaZam" => self.row_number || row_number, "P_7Z" => name, "P_8AZ" => unit, "P_12Z" => vat_rate, "StanPrzedZ" => state_before ? Formatting.flag(true) : nil }.merge(amounts).compact end |