zugpferd 0.3.5 → 0.4.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: abb862a514f5dca77411e88cf1f21a3ed148192d30c3e6e661dbd9720344cae4
4
- data.tar.gz: 7effd9d5bed0d5a9e6d054acbad9602846f7c334a98ee32ec65037c62b4aee95
3
+ metadata.gz: 985b4ac96323c6efebddb2908c4346a25444370b4b930f052d79056586553695
4
+ data.tar.gz: 80bbf8c1df7fd5ce7cc7357b1bd197b6c75926eea07354ae8ba65976af60885a
5
5
  SHA512:
6
- metadata.gz: 111a8f3af318dba1cd0d4f5f208ed5a35fce92d59eda7c5660098cc83d10d61d8229ad97a400fba46160bb4bb7df80fe23820c2a35d92f81e563b3b2e1bc36a3
7
- data.tar.gz: 16c0f30986919d7365f321ef18c3f3cf820152d6d0abc3943a3889e7485733ffc77d61a392755d48859011e79bac8bd30e3b4e77e65ed0f2fca2c9f866b57065
6
+ metadata.gz: 28d68c38b89914a8a9d3edd29e073cc1d40790fdd47a8be96d698daaf55cffff9c9b5c146a9720884644a3cab473fc6c6d996c3601819be27961e93cd75335fe
7
+ data.tar.gz: '03648cd41bd7b8759d7159c1d9d9ba2d649d1d93721d6b11557b6fa060ebbb045cecaffc71b62047fe903b6f4c8b5ff6114a650de72136d37a8210ca5b2a0583'
@@ -31,6 +31,13 @@ module Zugpferd
31
31
  SETTLEMENT = "#{TRANSACTION}/ram:ApplicableHeaderTradeSettlement"
32
32
  AGREEMENT = "#{TRANSACTION}/ram:ApplicableHeaderTradeAgreement"
33
33
 
34
+ # Invoicing period (BG-14)
35
+ BILLING_PERIOD = "ram:BillingSpecifiedPeriod"
36
+ BILLING_PERIOD_FIELDS = {
37
+ start_date: "ram:StartDateTime/udt:DateTimeString",
38
+ end_date: "ram:EndDateTime/udt:DateTimeString",
39
+ }.freeze
40
+
34
41
  INVOICE_SETTLEMENT = {
35
42
  currency_code: "#{SETTLEMENT}/ram:InvoiceCurrencyCode",
36
43
  buyer_reference: "#{AGREEMENT}/ram:BuyerReference",
@@ -36,6 +36,7 @@ module Zugpferd
36
36
  def build_invoice(root)
37
37
  settlement = root.at_xpath(SETTLEMENT, NS)
38
38
  delivery = root.at_xpath(DELIVERY, NS)
39
+ period = settlement&.at_xpath(BILLING_PERIOD, NS)
39
40
  type_code = text(root, INVOICE[:type_code])
40
41
  model_class = TYPE_CODE_MAP.fetch(type_code, Model::Invoice)
41
42
 
@@ -44,6 +45,8 @@ module Zugpferd
44
45
  issue_date: parse_cii_date(text(root, INVOICE[:issue_date])),
45
46
  due_date: parse_cii_date(settlement ? text(settlement, PAYMENT_TERMS_DUE_DATE) : nil),
46
47
  delivery_date: parse_cii_date(delivery ? text(delivery, DELIVERY_DATE) : nil),
48
+ invoicing_period_start_date: parse_cii_date(period ? text(period, BILLING_PERIOD_FIELDS[:start_date]) : nil),
49
+ invoicing_period_end_date: parse_cii_date(period ? text(period, BILLING_PERIOD_FIELDS[:end_date]) : nil),
47
50
  type_code: text(root, INVOICE[:type_code]),
48
51
  currency_code: text(root, INVOICE_SETTLEMENT[:currency_code]),
49
52
  buyer_reference: text(root, INVOICE_SETTLEMENT[:buyer_reference]),
@@ -173,6 +173,8 @@ module Zugpferd
173
173
  end
174
174
  end
175
175
 
176
+ build_billing_period(xml, doc) if doc.invoicing_period_start_date || doc.invoicing_period_end_date
177
+
176
178
  doc.allowance_charges.each { |ac| build_allowance_charge(xml, ac) }
177
179
 
178
180
  if doc.payment_instructions&.note || doc.due_date || doc.payment_instructions&.mandate_reference
@@ -191,6 +193,21 @@ module Zugpferd
191
193
  end
192
194
  end
193
195
 
196
+ def build_billing_period(xml, doc)
197
+ xml["ram"].BillingSpecifiedPeriod do
198
+ if doc.invoicing_period_start_date
199
+ xml["ram"].StartDateTime do
200
+ xml["udt"].DateTimeString(format_cii_date(doc.invoicing_period_start_date), format: "102")
201
+ end
202
+ end
203
+ if doc.invoicing_period_end_date
204
+ xml["ram"].EndDateTime do
205
+ xml["udt"].DateTimeString(format_cii_date(doc.invoicing_period_end_date), format: "102")
206
+ end
207
+ end
208
+ end
209
+ end
210
+
194
211
  def build_payment_means(xml, payment)
195
212
  xml["ram"].SpecifiedTradeSettlementPaymentMeans do
196
213
  xml["ram"].TypeCode payment.payment_means_code
@@ -19,6 +19,8 @@ module Zugpferd
19
19
  # @return [String] BT-3 Invoice type code
20
20
  # @return [String] BT-5 Document currency code (default: "EUR")
21
21
  # @return [Date, nil] BT-72 Actual delivery date
22
+ # @return [Date, nil] BT-73 Invoicing period start date
23
+ # @return [Date, nil] BT-74 Invoicing period end date
22
24
  # @return [String, nil] BT-10 Buyer reference
23
25
  # @return [String, nil] BT-24 Specification identifier
24
26
  # @return [String, nil] BT-23 Business process type
@@ -31,8 +33,9 @@ module Zugpferd
31
33
  # @return [PaymentInstructions, nil] BG-16 Payment information
32
34
  # @return [Array<AllowanceCharge>] BG-20/BG-21 Document-level allowances and charges
33
35
  attr_accessor :number, :issue_date, :due_date, :type_code,
34
- :currency_code, :delivery_date, :buyer_reference,
35
- :customization_id, :profile_id, :note, :seller, :buyer,
36
+ :currency_code, :delivery_date,
37
+ :invoicing_period_start_date, :invoicing_period_end_date,
38
+ :buyer_reference, :customization_id, :profile_id, :note, :seller, :buyer,
36
39
  :line_items, :tax_breakdown, :monetary_totals,
37
40
  :payment_instructions, :allowance_charges
38
41
 
@@ -30,6 +30,13 @@ module Zugpferd
30
30
  DELIVERY = "cac:Delivery"
31
31
  DELIVERY_DATE = "cbc:ActualDeliveryDate"
32
32
 
33
+ # Invoicing period (BG-14)
34
+ INVOICE_PERIOD = "cac:InvoicePeriod"
35
+ INVOICE_PERIOD_FIELDS = {
36
+ start_date: "cbc:StartDate",
37
+ end_date: "cbc:EndDate",
38
+ }.freeze
39
+
33
40
  # Seller (BG-4)
34
41
  SELLER = "cac:AccountingSupplierParty/cac:Party"
35
42
  # Buyer (BG-7)
@@ -34,12 +34,15 @@ module Zugpferd
34
34
  model_class = @credit_note ? Model::CreditNote : Model::Invoice
35
35
 
36
36
  delivery_node = root.at_xpath(DELIVERY, @ns)
37
+ period_node = root.at_xpath(INVOICE_PERIOD, @ns)
37
38
 
38
39
  model_class.new(
39
40
  number: text(root, INVOICE[:number]),
40
41
  issue_date: parse_date(text(root, INVOICE[:issue_date])),
41
42
  due_date: parse_date(text(root, INVOICE[:due_date])),
42
43
  delivery_date: delivery_node ? parse_date(text(delivery_node, DELIVERY_DATE)) : nil,
44
+ invoicing_period_start_date: period_node ? parse_date(text(period_node, INVOICE_PERIOD_FIELDS[:start_date])) : nil,
45
+ invoicing_period_end_date: period_node ? parse_date(text(period_node, INVOICE_PERIOD_FIELDS[:end_date])) : nil,
43
46
  type_code: text(root, type_code_element),
44
47
  currency_code: text(root, INVOICE[:currency_code]),
45
48
  buyer_reference: text(root, INVOICE[:buyer_reference]),
@@ -50,6 +50,7 @@ module Zugpferd
50
50
  xml["cbc"].Note doc.note if doc.note
51
51
  xml["cbc"].DocumentCurrencyCode doc.currency_code
52
52
  xml["cbc"].BuyerReference doc.buyer_reference if doc.buyer_reference
53
+ build_invoice_period(xml, doc) if doc.invoicing_period_start_date || doc.invoicing_period_end_date
53
54
 
54
55
  build_supplier(xml, doc.seller, doc.payment_instructions) if doc.seller
55
56
  build_customer(xml, doc.buyer) if doc.buyer
@@ -141,6 +142,13 @@ module Zugpferd
141
142
  end
142
143
  end
143
144
 
145
+ def build_invoice_period(xml, doc)
146
+ xml["cac"].InvoicePeriod do
147
+ xml["cbc"].StartDate doc.invoicing_period_start_date.to_s if doc.invoicing_period_start_date
148
+ xml["cbc"].EndDate doc.invoicing_period_end_date.to_s if doc.invoicing_period_end_date
149
+ end
150
+ end
151
+
144
152
  def build_delivery(xml, doc)
145
153
  xml["cac"].Delivery do
146
154
  xml["cbc"].ActualDeliveryDate doc.delivery_date.to_s
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.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zeitler