cfonb 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 894f7b20e6c030c8343e833f79f0a5a69c4701e4d262c66a5740c1872efd4603
4
- data.tar.gz: 380cb8f1225d203fdf845456a2630d3ca13605c03c7bc0deb11f64da6f8e905c
3
+ metadata.gz: 92590bdbb35e07a65cd7b8dbb244a276a5efdcb05c424b0a3372f562742dc79e
4
+ data.tar.gz: 73d29480cb94c937a465f31b3342ff7bc4cdb4df23a6ad9b6c47db624cdf8488
5
5
  SHA512:
6
- metadata.gz: f6ba5f905c66dc4a4c60916ca5548703484e5270893efc1785d94aa100d60ef4933784589c75964e7dab358c7843b12958348f2476e2d04cc364b3687c0bc604
7
- data.tar.gz: 5cc5774eb790f41f28fb9b885a50fd4682719feb9d6083351600e50ac9045dc375202a382ef36cd748fd4991b35ce84d7fdd4ffb6ccaf96c586c56f7a510df3f
6
+ metadata.gz: 8e893921454fdfb646796d64a0cf0d1a1150488ccf73952d23e55db36d2d5e7551eab014550006195cbde4c2915aa52e6a50253605d98d2f1edc3871baf58ed1
7
+ data.tar.gz: a44a4b448a3bcb560bd0f4bc61dbd7beb1bf5083ffcb72be1862546af6d0f59dd549e758e796f0e3ff5e6915b94e46ac4fb3fa0b2c1d3f4c81f9c9f28cb263e0
@@ -5,7 +5,7 @@ require 'bigdecimal'
5
5
  module CFONB
6
6
  module OperationDetail
7
7
  class MMO
8
- ATTRIBUTES = %i[original_currency original_amount].freeze
8
+ ATTRIBUTES = %i[original_currency original_amount exchange_rate].freeze
9
9
 
10
10
  def self.apply(operation, line)
11
11
  operation.original_currency = line.detail[0..2]
@@ -14,6 +14,12 @@ module CFONB
14
14
  sign = operation.amount <=> 0 # the detail amount is unsigned
15
15
 
16
16
  operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale)
17
+ exchange_rate_value = line.detail[26..29]
18
+
19
+ return if exchange_rate_value.nil? || exchange_rate_value.strip.empty?
20
+
21
+ exchange_rate_scale = line.detail[18]
22
+ operation.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale))
17
23
  end
18
24
 
19
25
  CFONB::OperationDetail.register('MMO', self)
@@ -89,8 +89,37 @@ describe CFONB::Operation do
89
89
  expect(operation).to have_attributes(
90
90
  original_currency: 'USD',
91
91
  original_amount: -12.34,
92
+ exchange_rate: nil,
92
93
  )
93
94
  end
95
+
96
+ context 'with exchange rate' do
97
+ let(:detail) { OpenStruct.new(body: '', detail_code: 'MMO', detail: 'USD000000000008358300000001077') }
98
+
99
+ it 'Adds the original currency information' do
100
+ operation.merge_detail(detail)
101
+
102
+ expect(operation).to have_attributes(
103
+ original_currency: 'USD',
104
+ original_amount: -8358,
105
+ exchange_rate: 1.077,
106
+ )
107
+ end
108
+ end
109
+
110
+ context 'when exchange rate is missing' do
111
+ let(:detail) { OpenStruct.new(body: '', detail_code: 'MMO', detail: 'EUR200000001875625 04') }
112
+
113
+ it 'Adds the original currency information' do
114
+ operation.merge_detail(detail)
115
+
116
+ expect(operation).to have_attributes(
117
+ original_currency: 'EUR',
118
+ original_amount: -18_756.25,
119
+ exchange_rate: nil,
120
+ )
121
+ end
122
+ end
94
123
  end
95
124
 
96
125
  context 'with a NPY detail' do
@@ -44,6 +44,7 @@ describe CFONB::Parser do
44
44
  value_date: Date.new(2019, 5, 16),
45
45
  original_currency: nil,
46
46
  original_amount: nil,
47
+ exchange_rate: nil,
47
48
  debtor: 'INTERNET SFR',
48
49
  )
49
50
 
@@ -62,6 +63,7 @@ describe CFONB::Parser do
62
63
  value_date: Date.new(2019, 5, 16),
63
64
  original_currency: nil,
64
65
  original_amount: nil,
66
+ exchange_rate: nil,
65
67
  debtor: 'ELEC ERDF',
66
68
  )
67
69
 
@@ -80,6 +82,7 @@ describe CFONB::Parser do
80
82
  value_date: Date.new(2019, 5, 15),
81
83
  original_currency: nil,
82
84
  original_amount: nil,
85
+ exchange_rate: nil,
83
86
  )
84
87
 
85
88
  expect(statements[1]).to have_attributes(
@@ -110,6 +113,7 @@ describe CFONB::Parser do
110
113
  value_date: Date.new(2019, 5, 15),
111
114
  original_currency: nil,
112
115
  original_amount: nil,
116
+ exchange_rate: nil,
113
117
  )
114
118
 
115
119
  expect(statements[1].operations[1]).to have_attributes(
@@ -127,6 +131,7 @@ describe CFONB::Parser do
127
131
  value_date: Date.new(2019, 5, 15),
128
132
  original_currency: nil,
129
133
  original_amount: nil,
134
+ exchange_rate: nil,
130
135
  )
131
136
 
132
137
  expect(statements[1].operations[2]).to have_attributes(
@@ -144,6 +149,7 @@ describe CFONB::Parser do
144
149
  value_date: Date.new(2019, 5, 16),
145
150
  original_currency: nil,
146
151
  original_amount: nil,
152
+ exchange_rate: nil,
147
153
  )
148
154
  end
149
155
  end
@@ -234,6 +240,7 @@ describe CFONB::Parser do
234
240
  value_date: Date.new(2019, 5, 16),
235
241
  original_currency: nil,
236
242
  original_amount: nil,
243
+ exchange_rate: nil,
237
244
  debtor: 'INTERNET SFR',
238
245
  )
239
246
 
@@ -252,6 +259,7 @@ describe CFONB::Parser do
252
259
  value_date: Date.new(2019, 5, 16),
253
260
  original_currency: nil,
254
261
  original_amount: nil,
262
+ exchange_rate: nil,
255
263
  debtor: 'ELEC ERDF',
256
264
  )
257
265
 
@@ -270,6 +278,7 @@ describe CFONB::Parser do
270
278
  value_date: Date.new(2019, 5, 15),
271
279
  original_currency: nil,
272
280
  original_amount: nil,
281
+ exchange_rate: nil,
273
282
  )
274
283
 
275
284
  expect(statements[1]).to have_attributes(
@@ -300,6 +309,7 @@ describe CFONB::Parser do
300
309
  value_date: Date.new(2019, 5, 15),
301
310
  original_currency: nil,
302
311
  original_amount: nil,
312
+ exchange_rate: nil,
303
313
  )
304
314
 
305
315
  expect(statements[1].operations[1]).to have_attributes(
@@ -317,6 +327,7 @@ describe CFONB::Parser do
317
327
  value_date: Date.new(2019, 5, 15),
318
328
  original_currency: nil,
319
329
  original_amount: nil,
330
+ exchange_rate: nil,
320
331
  )
321
332
 
322
333
  expect(statements[1].operations[2]).to have_attributes(
@@ -334,6 +345,7 @@ describe CFONB::Parser do
334
345
  value_date: Date.new(2019, 5, 16),
335
346
  original_currency: nil,
336
347
  original_amount: nil,
348
+ exchange_rate: nil,
337
349
  )
338
350
  end
339
351
  end
@@ -359,6 +371,7 @@ describe CFONB::Parser do
359
371
  value_date: Date.new(2019, 5, 16),
360
372
  original_currency: nil,
361
373
  original_amount: nil,
374
+ exchange_rate: nil,
362
375
  debtor: 'ELEC ERDF',
363
376
  )
364
377
  end
@@ -385,6 +398,7 @@ describe CFONB::Parser do
385
398
  value_date: Date.new(2019, 5, 16),
386
399
  original_currency: nil,
387
400
  original_amount: nil,
401
+ exchange_rate: nil,
388
402
  debtor: 'ELEC ERDF',
389
403
  )
390
404
  end
@@ -411,6 +425,7 @@ describe CFONB::Parser do
411
425
  value_date: Date.new(2019, 5, 16),
412
426
  original_currency: nil,
413
427
  original_amount: nil,
428
+ exchange_rate: nil,
414
429
  debtor: 'ELEC ERDF',
415
430
  )
416
431
  end
@@ -437,6 +452,7 @@ describe CFONB::Parser do
437
452
  value_date: Date.new(2019, 5, 16),
438
453
  original_currency: nil,
439
454
  original_amount: nil,
455
+ exchange_rate: nil,
440
456
  debtor: 'ELEC ERDF',
441
457
  )
442
458
  expect(statements[0].operations[1]).to have_attributes(
@@ -454,6 +470,7 @@ describe CFONB::Parser do
454
470
  value_date: Date.new(2019, 5, 16),
455
471
  original_currency: nil,
456
472
  original_amount: nil,
473
+ exchange_rate: nil,
457
474
  )
458
475
  end
459
476
  end
@@ -494,6 +511,7 @@ describe CFONB::Parser do
494
511
  value_date: Date.new(2019, 5, 16),
495
512
  original_currency: nil,
496
513
  original_amount: nil,
514
+ exchange_rate: nil,
497
515
  debtor: 'INTERNET SFR',
498
516
  )
499
517
  end
@@ -553,6 +571,7 @@ describe CFONB::Parser do
553
571
  value_date: Date.new(2019, 5, 16),
554
572
  original_currency: nil,
555
573
  original_amount: nil,
574
+ exchange_rate: nil,
556
575
  debtor: 'INTERNET SFR',
557
576
  )
558
577
  end
@@ -577,6 +596,7 @@ describe CFONB::Parser do
577
596
  value_date: Date.new(2019, 5, 16),
578
597
  original_currency: nil,
579
598
  original_amount: nil,
599
+ exchange_rate: nil,
580
600
  debtor: 'INTERNET SFR',
581
601
  )
582
602
  end
@@ -609,6 +629,7 @@ describe CFONB::Parser do
609
629
  value_date: Date.new(2019, 5, 16),
610
630
  original_currency: nil,
611
631
  original_amount: nil,
632
+ exchange_rate: nil,
612
633
  debtor: 'ELEC ERDF',
613
634
  )
614
635
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfonb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Le Bray
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-08 00:00:00.000000000 Z
12
+ date: 2023-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: license_finder