multicash 0.0.2 → 0.0.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/multicash/ammount.rb +1 -1
- data/lib/multicash/credit_transfer.rb +1 -1
- data/lib/multicash/payment_order.rb +10 -9
- data/lib/multicash/transfer.rb +0 -1
- data/multicash.gemspec +2 -2
- data/spec/payment_order_spec.rb +7 -2
- data/spec/payment_spec.rb +2 -2
- data/spec/transfer_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a2eb079904b7f749e89c682740f34d9cd9794c
|
4
|
+
data.tar.gz: 3847c1756f0745763e8ffbdabdb4277f699e366d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffcc2887d1a901eedafd445e45fd07583aecf4ec008218624f2b7a1c53cb9fbfd498f624512dd64bba668577d6260afd6068cce98e9ea3e88a848a6b33e61169
|
7
|
+
data.tar.gz: 305177c4f9fb018f68ff8f0d4fb5ca1dad68f605c6d4344c0a7fd33ad063f1937610a0183f78867b07d1651e81247626124b097e249245a59cb46774de320daa
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/multicash/ammount.rb
CHANGED
@@ -4,7 +4,7 @@ module Multicash
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
|
6
6
|
CURRENCIES = %w{AUD BGN CAD CHF DKK EUR GBP JPY NOK RUR SEK TRL USD}
|
7
|
-
CURRENCY_FORMAT = /\A\d{1,11}.\d{2}\z/
|
7
|
+
CURRENCY_FORMAT = /\A\d{1,11}.\d{1,2}\z/
|
8
8
|
|
9
9
|
attr_accessor :value, :currency
|
10
10
|
attr_reader :errors
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Multicash
|
2
2
|
class PaymentOrder
|
3
|
-
|
4
|
-
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
include ActiveModel::Validations
|
5
|
+
|
6
|
+
attr_accessor :reference, :transfers_number, :errors
|
7
|
+
attr_reader :transfers, :total_ammount, :currency, :ordering_bae, :date
|
5
8
|
|
6
9
|
def initialize
|
7
10
|
@currency = nil
|
8
11
|
@date = Time.now.strftime('%y%m%d')
|
9
|
-
@errors =
|
12
|
+
@errors = ActiveModel::Errors.new(self)
|
10
13
|
@ordering_bae = nil
|
11
14
|
@transfers = []
|
12
15
|
@total_ammount = 0.00
|
@@ -15,11 +18,12 @@ module Multicash
|
|
15
18
|
def << (transfer)
|
16
19
|
if transfer.valid?
|
17
20
|
@transfers << transfer
|
21
|
+
transfer.reference_counter = @transfers.size
|
18
22
|
@total_ammount += (transfer.ammount.to_f)
|
19
23
|
@currency ||= transfer.currency
|
20
24
|
@ordering_bae ||= transfer.ordering_bae
|
21
25
|
else
|
22
|
-
errors.add(
|
26
|
+
errors.add("#{transfer.reference_counter}", transfer.errors.full_messages)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
@@ -49,11 +53,8 @@ module Multicash
|
|
49
53
|
|
50
54
|
def body
|
51
55
|
lines = []
|
52
|
-
transfers.
|
53
|
-
|
54
|
-
transfer.reference_counter += 1
|
55
|
-
lines << transfer.generate
|
56
|
-
end
|
56
|
+
transfers.each do |transfer|
|
57
|
+
lines << transfer.generate
|
57
58
|
end
|
58
59
|
|
59
60
|
lines.join("\x0C")
|
data/lib/multicash/transfer.rb
CHANGED
data/multicash.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: multicash 0.0.
|
5
|
+
# stub: multicash 0.0.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "multicash"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Anton Yordanov"]
|
data/spec/payment_order_spec.rb
CHANGED
@@ -26,12 +26,17 @@ describe "Multicash::PaymentOrder" do
|
|
26
26
|
context "generate" do
|
27
27
|
subject { Multicash::PaymentOrder.new }
|
28
28
|
|
29
|
+
specify "increment transfer reference_counter" do
|
30
|
+
subject << transfer
|
31
|
+
expect(transfer.reference_counter).to eq(1)
|
32
|
+
subject << transfer
|
33
|
+
expect(transfer.reference_counter).to eq(2)
|
34
|
+
end
|
35
|
+
|
29
36
|
specify "save to file" do
|
30
37
|
subject << transfer
|
31
38
|
subject << transfer
|
32
39
|
file_name = subject.save_to_file
|
33
|
-
|
34
|
-
|
35
40
|
expect(File.exist?(file_name)).to be_true
|
36
41
|
end
|
37
42
|
end
|
data/spec/payment_spec.rb
CHANGED
@@ -13,12 +13,12 @@ describe "Multicash::Payment" do
|
|
13
13
|
expect(Multicash::Payment.new(attributes)).to be_valid
|
14
14
|
end
|
15
15
|
|
16
|
-
it "not
|
16
|
+
it "not valid if ammount is not valid" do
|
17
17
|
attributes[:ammount] = Multicash::Ammount.new(value: 222.12222222, currency: 'BGN')
|
18
18
|
expect(Multicash::Payment.new(attributes)).to_not be_valid
|
19
19
|
end
|
20
20
|
|
21
|
-
it "not
|
21
|
+
it "not valid if charges are not in allowed range" do
|
22
22
|
attributes[:charges] = 'FRR'
|
23
23
|
expect(Multicash::Payment.new(attributes)).to_not be_valid
|
24
24
|
end
|
data/spec/transfer_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe "Multicash::Transfer" do
|
|
19
19
|
let(:payment) { Multicash::Payment.new( ammount: ammount, details: 'Details', charges: 'SHA') }
|
20
20
|
|
21
21
|
context "validations" do
|
22
|
-
it "valid on valid initilization
|
22
|
+
it "valid on valid initilization attributes" do
|
23
23
|
expect(Multicash::Transfer.new( ordering_account: ordering_account,
|
24
24
|
destination_account: destination_account,
|
25
25
|
payment: payment,
|
@@ -27,7 +27,7 @@ describe "Multicash::Transfer" do
|
|
27
27
|
).to be_valid
|
28
28
|
end
|
29
29
|
|
30
|
-
it "invalid on invalid ordering_account" do
|
30
|
+
it "invalid on invalid ordering_account attribute" do
|
31
31
|
ordering_account.name = ''
|
32
32
|
|
33
33
|
expect(Multicash::Transfer.new(ordering_account: ordering_account,
|
@@ -37,7 +37,7 @@ describe "Multicash::Transfer" do
|
|
37
37
|
).to_not be_valid
|
38
38
|
end
|
39
39
|
|
40
|
-
it "invalid on invalid destination_account" do
|
40
|
+
it "invalid on invalid destination_account attribute" do
|
41
41
|
destination_account.name = ''
|
42
42
|
|
43
43
|
expect(Multicash::Transfer.new(ordering_account: ordering_account,
|
@@ -47,7 +47,7 @@ describe "Multicash::Transfer" do
|
|
47
47
|
).to_not be_valid
|
48
48
|
end
|
49
49
|
|
50
|
-
it "invalid on invalid payment" do
|
50
|
+
it "invalid on invalid payment attribute" do
|
51
51
|
payment.ammount.value = 'fffff'
|
52
52
|
|
53
53
|
expect(Multicash::Transfer.new(ordering_account: ordering_account,
|