secretariat 3.4.0 → 3.6.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: f1a42571c7c3ceb77877659b076fbd8974ee661843dbc4f4d294012163a4c99f
4
- data.tar.gz: 871cf260400cdf9470c867572a77d6ac5d109886b30b9d99120bbbfa94b5f950
3
+ metadata.gz: 24767d1bf53e67440e5b012f83b19e45119e937fde0085d8197ff21dcf0c65e0
4
+ data.tar.gz: c0cc0b22c3f8fa4612e08a6bab5af89f0fefd30a06c899976264305991d08846
5
5
  SHA512:
6
- metadata.gz: e69622419e9e48946ddf0dc4921515a02fa3e8c1f53cd1fd23cd14c89d7f2470718e8d220a4c9594142a768db4c143452efd93607917b230c28e9bb647ec537d
7
- data.tar.gz: f5c1da6eea2d10742eebb2ae95993026f74ee6968ac630caaa2f38face0c26b03e401d6204752b14e816af8c408d8052843e77071bc6b68f37200bd3607099f6
6
+ metadata.gz: acaff7a169b01482c53491609cd0b91add3d528b74e84659369d6283463eae3787020d6a91153775778decf393353f2c8a88935e046eb8a3ab1bb151fd5dd31b
7
+ data.tar.gz: c213647657402309c566461b15d11dc1a1cc5d72e8d158ab79fc0f51b2bde4eb6245c86e68cd976bc707f372f9d8ce803ef076453a7cfd222ae95f60e7257fac
@@ -42,6 +42,7 @@ module Secretariat
42
42
  :due_amount,
43
43
  :paid_amount,
44
44
  :tax_calculation_method,
45
+ :notes,
45
46
  :attachments,
46
47
  keyword_init: true
47
48
  ) do
@@ -84,7 +85,7 @@ module Secretariat
84
85
  taxes[line_item.tax_percent].base_amount += BigDecimal(line_item.net_amount) * line_item.quantity
85
86
  end
86
87
  end
87
-
88
+
88
89
  if tax_calculation_method == :VERTICAL
89
90
  taxes.values.map do |tax|
90
91
  tax.tax_amount = (tax.base_amount * tax.tax_percent / 100).round(2)
@@ -113,7 +114,12 @@ module Secretariat
113
114
  @errors << "Base amount and summed tax base amount deviate: #{basis} / #{summed_tax_base_amount}"
114
115
  return false
115
116
  end
116
- if tax_calculation_method != :NONE
117
+ if tax_calculation_method == :ITEM_BASED
118
+ line_items_tax_amount = line_items.sum(&:tax_amount)
119
+ if tax_amount != line_items_tax_amount
120
+ @errors << "Tax amount #{tax_amount} and summed up item tax amounts #{line_items_tax_amount} deviate"
121
+ end
122
+ elsif tax_calculation_method != :NONE
117
123
  taxes.each do |tax|
118
124
  calc_tax = tax.base_amount * BigDecimal(tax.tax_percent) / BigDecimal(100)
119
125
  calc_tax = calc_tax.round(2)
@@ -167,7 +173,7 @@ module Secretariat
167
173
  raise ValidationError.new("Invoice is invalid", errors)
168
174
  end
169
175
 
170
- builder = Nokogiri::XML::Builder.new do |xml|
176
+ builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
171
177
 
172
178
  root = by_version(version, 'CrossIndustryDocument', 'CrossIndustryInvoice')
173
179
 
@@ -195,8 +201,13 @@ module Secretariat
195
201
  xml.text(issue_date.strftime("%Y%m%d"))
196
202
  end
197
203
  end
198
-
204
+ Array(self.notes).each do |note|
205
+ xml['ram'].IncludedNote do
206
+ xml['ram'].Content note
207
+ end
208
+ end
199
209
  end
210
+
200
211
  transaction = by_version(version, 'SpecifiedSupplyChainTradeTransaction', 'SupplyChainTradeTransaction')
201
212
  xml['rsm'].send(transaction) do
202
213
 
@@ -15,5 +15,5 @@ limitations under the License.
15
15
  =end
16
16
 
17
17
  module Secretariat
18
- VERSION = '3.4.0'
18
+ VERSION = '3.6.0'
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secretariat
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Krutisch
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 3.6.0
46
+ version: '3.6'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 3.6.0
53
+ version: '3.6'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: minitest
56
56
  requirement: !ruby/object:Gem::Requirement