zugpferd 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 985b4ac96323c6efebddb2908c4346a25444370b4b930f052d79056586553695
4
- data.tar.gz: 80bbf8c1df7fd5ce7cc7357b1bd197b6c75926eea07354ae8ba65976af60885a
3
+ metadata.gz: 9a9f2f51374e01f8940bd39a69c088477348c26d77d69adca3f1737445f99c9d
4
+ data.tar.gz: 8a541edb6c9b0aa78d87d715e8a04271ef0a8ea03d9d49463b4d0f45f72ce499
5
5
  SHA512:
6
- metadata.gz: 28d68c38b89914a8a9d3edd29e073cc1d40790fdd47a8be96d698daaf55cffff9c9b5c146a9720884644a3cab473fc6c6d996c3601819be27961e93cd75335fe
7
- data.tar.gz: '03648cd41bd7b8759d7159c1d9d9ba2d649d1d93721d6b11557b6fa060ebbb045cecaffc71b62047fe903b6f4c8b5ff6114a650de72136d37a8210ca5b2a0583'
6
+ metadata.gz: 5f3051364d36fc4b5fddb4ff6e8369f37aca520f88aaa20784443176706bbfa688da434f4f3ba28fea8953460a092914b7fa0ca4380a9d07e16df5205258b7de
7
+ data.tar.gz: 4c40141f885ee40dd9da1e67432ba2a7a80cf5d59b2847cf4b487df4682baffc224f7b61d58b5a0b5f51aeeb684b6bf8ae501b9616e124dcaa77828761e8034a
@@ -139,6 +139,13 @@ module Zugpferd
139
139
  line_extension_amount: "ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount",
140
140
  }.freeze
141
141
 
142
+ # Invoice line period (BG-26)
143
+ LINE_PERIOD = "ram:SpecifiedLineTradeSettlement/ram:BillingSpecifiedPeriod"
144
+ LINE_PERIOD_FIELDS = {
145
+ start_date: "ram:StartDateTime/udt:DateTimeString",
146
+ end_date: "ram:EndDateTime/udt:DateTimeString",
147
+ }.freeze
148
+
142
149
  # Item (BG-31)
143
150
  ITEM = "ram:SpecifiedTradeProduct"
144
151
  ITEM_FIELDS = {
@@ -170,6 +170,7 @@ module Zugpferd
170
170
  item_node = node.at_xpath(ITEM, NS)
171
171
  price_node = node.at_xpath(PRICE, NS)
172
172
  tax_node = node.at_xpath(ITEM_TAX, NS)
173
+ period_node = node.at_xpath(LINE_PERIOD, NS)
173
174
 
174
175
  Model::LineItem.new(
175
176
  id: text(node, LINE[:id]),
@@ -177,6 +178,8 @@ module Zugpferd
177
178
  unit_code: node.at_xpath(LINE[:unit_code], NS)&.text,
178
179
  line_extension_amount: text(node, LINE[:line_extension_amount]),
179
180
  note: text(node, LINE[:note]),
181
+ period_start_date: parse_cii_date(period_node ? text(period_node, LINE_PERIOD_FIELDS[:start_date]) : nil),
182
+ period_end_date: parse_cii_date(period_node ? text(period_node, LINE_PERIOD_FIELDS[:end_date]) : nil),
180
183
  item: build_item(item_node, tax_node),
181
184
  price: build_price(price_node),
182
185
  )
@@ -314,6 +314,8 @@ module Zugpferd
314
314
  end
315
315
  end
316
316
 
317
+ build_line_period(xml, line) if line.period_start_date || line.period_end_date
318
+
317
319
  xml["ram"].SpecifiedTradeSettlementLineMonetarySummation do
318
320
  xml["ram"].LineTotalAmount format_decimal(line.line_extension_amount)
319
321
  end
@@ -321,6 +323,21 @@ module Zugpferd
321
323
  end
322
324
  end
323
325
 
326
+ def build_line_period(xml, line)
327
+ xml["ram"].BillingSpecifiedPeriod do
328
+ if line.period_start_date
329
+ xml["ram"].StartDateTime do
330
+ xml["udt"].DateTimeString(format_cii_date(line.period_start_date), format: "102")
331
+ end
332
+ end
333
+ if line.period_end_date
334
+ xml["ram"].EndDateTime do
335
+ xml["udt"].DateTimeString(format_cii_date(line.period_end_date), format: "102")
336
+ end
337
+ end
338
+ end
339
+ end
340
+
324
341
  def build_item(xml, item)
325
342
  xml["ram"].SpecifiedTradeProduct do
326
343
  xml["ram"].SellerAssignedID item.sellers_identifier if item.sellers_identifier
@@ -9,10 +9,13 @@ module Zugpferd
9
9
  # @return [String] BT-130 Unit of measure code
10
10
  # @return [BigDecimal] BT-131 Line extension amount
11
11
  # @return [String, nil] BT-127 Invoice line note
12
+ # @return [Date, nil] BT-134 Invoice line period start date
13
+ # @return [Date, nil] BT-135 Invoice line period end date
12
14
  # @return [Item, nil] BG-31 Item information
13
15
  # @return [Price, nil] BG-29 Price details
14
16
  attr_accessor :id, :invoiced_quantity, :unit_code,
15
- :line_extension_amount, :note, :item, :price
17
+ :line_extension_amount, :note, :period_start_date,
18
+ :period_end_date, :item, :price
16
19
 
17
20
  # @param id [String] BT-126 Line identifier
18
21
  # @param invoiced_quantity [String, BigDecimal] BT-129 Quantity
@@ -132,6 +132,13 @@ module Zugpferd
132
132
  note: "cbc:Note",
133
133
  }.freeze
134
134
 
135
+ # Invoice line period (BG-26)
136
+ LINE_PERIOD = "cac:InvoicePeriod"
137
+ LINE_PERIOD_FIELDS = {
138
+ start_date: "cbc:StartDate",
139
+ end_date: "cbc:EndDate",
140
+ }.freeze
141
+
135
142
  # Item (BG-31)
136
143
  ITEM = "cac:Item"
137
144
  ITEM_FIELDS = {
@@ -168,6 +168,7 @@ module Zugpferd
168
168
  def build_line_item(node)
169
169
  item_node = node.at_xpath(ITEM, @ns)
170
170
  price_node = node.at_xpath(PRICE, @ns)
171
+ period_node = node.at_xpath(LINE_PERIOD, @ns)
171
172
 
172
173
  quantity_element = @credit_note ? "cbc:CreditedQuantity" : LINE[:invoiced_quantity]
173
174
  unit_code_element = @credit_note ? "cbc:CreditedQuantity/@unitCode" : LINE[:unit_code]
@@ -178,6 +179,8 @@ module Zugpferd
178
179
  unit_code: node.at_xpath(unit_code_element, @ns)&.text,
179
180
  line_extension_amount: text(node, LINE[:line_extension_amount]),
180
181
  note: text(node, LINE[:note]),
182
+ period_start_date: period_node ? parse_date(text(period_node, LINE_PERIOD_FIELDS[:start_date])) : nil,
183
+ period_end_date: period_node ? parse_date(text(period_node, LINE_PERIOD_FIELDS[:end_date])) : nil,
181
184
  item: build_item(item_node),
182
185
  price: build_price(price_node),
183
186
  )
@@ -274,11 +274,19 @@ module Zugpferd
274
274
  unitCode: line.unit_code)
275
275
  xml["cbc"].LineExtensionAmount(format_decimal(line.line_extension_amount),
276
276
  currencyID: currency_code)
277
+ build_line_period(xml, line) if line.period_start_date || line.period_end_date
277
278
  build_item(xml, line.item) if line.item
278
279
  build_price(xml, line.price, currency_code) if line.price
279
280
  end
280
281
  end
281
282
 
283
+ def build_line_period(xml, line)
284
+ xml["cac"].InvoicePeriod do
285
+ xml["cbc"].StartDate line.period_start_date.to_s if line.period_start_date
286
+ xml["cbc"].EndDate line.period_end_date.to_s if line.period_end_date
287
+ end
288
+ end
289
+
282
290
  def build_item(xml, item)
283
291
  xml["cac"].Item do
284
292
  xml["cbc"].Description item.description if item.description
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zugpferd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zeitler
@@ -27,14 +27,14 @@ dependencies:
27
27
  name: bigdecimal
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - "~>"
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3.1'
40
40
  - !ruby/object:Gem::Dependency