sie 1.0.4 → 1.0.5
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 +8 -8
- data/lib/sie/document.rb +14 -3
- data/lib/sie/version.rb +1 -1
- data/spec/unit/document_spec.rb +43 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDlhZjFkZmQwYmY5YjFhMDQ5ODljYTU1ZGM1ODFkMzMxMmIxMTRhOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWIzMjZlMTE5YjAxZjg0MDE0YmNiOWE4MTljMDYzMGY4ZTE0NDc5Ng==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDA2OWNhMjU2OWFmNzBkNjZlOTgzODQyODBjNGZhNzFkYThkZTU1Y2UxNTlk
|
10
|
+
YjhkNTNhNDUwOTcxMGQ3OGU3ZTFlYzkwNDIzMTgyZWYyMDIwYmY4NWEzNDU2
|
11
|
+
ZjEwNDYxZTg4ZTk4NTE4MGMzZTE0NGRkMjYwNzdlOTMxZGQ3ZDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWFlMzY5ZmI4YjljZGQwMzY5Y2U3ZmIyZWE0ZDE5ZGMxYWE1YjY1ODJhNjk2
|
14
|
+
NmE3MjE1OThlZTAxN2VkNzU0NzgyNWFhZjgyODhiNDUzMmEyMzBiYmQwZDM5
|
15
|
+
Yjg2ODMxYjQ3NGIzZmE2MzI5M2Q0OGQ1MjNiMjlkMDNiYjg0N2M=
|
data/lib/sie/document.rb
CHANGED
@@ -6,6 +6,7 @@ require "active_support/core_ext/module/delegation"
|
|
6
6
|
|
7
7
|
class Sie::Document
|
8
8
|
pattr_initialize :data_source
|
9
|
+
FORTNOX_DESCRIPTION_LENGTH_MAX = 30
|
9
10
|
|
10
11
|
def render
|
11
12
|
add_header
|
@@ -42,7 +43,7 @@ class Sie::Document
|
|
42
43
|
def add_accounts
|
43
44
|
accounts.each do |account|
|
44
45
|
number = account.fetch(:number)
|
45
|
-
description = account.fetch(:description)
|
46
|
+
description = account.fetch(:description).slice(0, FORTNOX_DESCRIPTION_LENGTH_MAX)
|
46
47
|
|
47
48
|
add_line("KONTO", number, description)
|
48
49
|
end
|
@@ -69,12 +70,13 @@ class Sie::Document
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
|
72
74
|
def add_voucher(opts)
|
73
75
|
creditor = opts.fetch(:creditor)
|
74
76
|
type = opts.fetch(:type)
|
75
77
|
number = opts.fetch(:number)
|
76
78
|
booked_on = opts.fetch(:booked_on)
|
77
|
-
description = opts.fetch(:description)
|
79
|
+
description = opts.fetch(:description).slice(0, FORTNOX_DESCRIPTION_LENGTH_MAX)
|
78
80
|
voucher_lines = opts.fetch(:voucher_lines)
|
79
81
|
|
80
82
|
add_line("VER", voucher_series(creditor, type), number, booked_on, description)
|
@@ -84,9 +86,18 @@ class Sie::Document
|
|
84
86
|
account_number = line.fetch(:account_number)
|
85
87
|
amount = line.fetch(:amount)
|
86
88
|
booked_on = line.fetch(:booked_on)
|
87
|
-
|
89
|
+
# Some SIE-importers (fortnox) cannot handle descriptions longer than 30 characters,
|
90
|
+
# but the specification has no limit.
|
91
|
+
description = line.fetch(:description).slice(0, FORTNOX_DESCRIPTION_LENGTH_MAX)
|
88
92
|
|
89
93
|
add_line("TRANS", account_number, Renderer::EMPTY_ARRAY, amount, booked_on, description)
|
94
|
+
|
95
|
+
# Some consumers of SIE cannot handle single voucher lines (fortnox), so add another empty one to make
|
96
|
+
# it balance. The spec just requires the sum of lines to be 0, so single lines with zero amount would conform,
|
97
|
+
# but break for these implementations.
|
98
|
+
if voucher_lines.size < 2 && amount == 0
|
99
|
+
add_line("TRANS", account_number, Renderer::EMPTY_ARRAY, amount, booked_on, description)
|
100
|
+
end
|
90
101
|
end
|
91
102
|
end
|
92
103
|
end
|
data/lib/sie/version.rb
CHANGED
data/spec/unit/document_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Sie::Document, "#render" do
|
|
9
9
|
let(:generated_on) { Date.yesterday }
|
10
10
|
let(:accounts) {
|
11
11
|
[
|
12
|
-
number: 1500, description: "Customer ledger"
|
12
|
+
number: 1500, description: "Customer ledger",
|
13
13
|
]
|
14
14
|
}
|
15
15
|
let(:vouchers) {
|
@@ -155,6 +155,48 @@ describe Sie::Document, "#render" do
|
|
155
155
|
)
|
156
156
|
end
|
157
157
|
|
158
|
+
context "with really long descriptions" do
|
159
|
+
let(:accounts) {
|
160
|
+
[
|
161
|
+
number: 1500, description: "Customer ledger with really really long description blablabla"
|
162
|
+
]
|
163
|
+
}
|
164
|
+
let(:vouchers) {
|
165
|
+
[
|
166
|
+
{
|
167
|
+
creditor: true, type: :payment, number: 3, booked_on: from_date + 365, description: "Payout 1 with really really long description blablabla",
|
168
|
+
voucher_lines: [
|
169
|
+
{ account_number: 2400, amount: 256.0, booked_on: from_date + 365, description: "Payout line 1 with really really long description blablabla" },
|
170
|
+
{ account_number: 1970, amount: -256.0, booked_on: from_date + 365, description: "Payout line 2" },
|
171
|
+
]
|
172
|
+
}
|
173
|
+
]
|
174
|
+
}
|
175
|
+
|
176
|
+
it "truncates the descriptions" do
|
177
|
+
expect(indexed_entry_attributes("konto", 0)).to eq("kontonr" => "1500", "kontonamn" => "Customer ledger with really re")
|
178
|
+
expect(indexed_entry("ver", 0).attributes["vertext"]).to eq("Payout 1 with really really lo")
|
179
|
+
expect(indexed_voucher_entries(0)[0].attributes["transtext"]).to eq("Payout line 1 with really real")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "with a zeroed single voucher line" do
|
184
|
+
let(:vouchers) {
|
185
|
+
[
|
186
|
+
{
|
187
|
+
creditor: false, type: :invoice, number: 1, booked_on: from_date + 2, description: "Invoice 1",
|
188
|
+
voucher_lines: [
|
189
|
+
{ account_number: 1500, amount: 0, booked_on: from_date + 2, description: "Item 1" },
|
190
|
+
]
|
191
|
+
},
|
192
|
+
]
|
193
|
+
}
|
194
|
+
|
195
|
+
it "makes sure there is always a matching zeroed line" do
|
196
|
+
expect(indexed_voucher_entries(0).size).to eq(2)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
158
200
|
private
|
159
201
|
|
160
202
|
def entry_attribute(label, attribute)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barsoom AB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_extras
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.2.
|
145
|
+
rubygems_version: 2.2.2
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Parses and generates SIE files (http://sie.se/)
|