adherent 0.3.3 → 0.3.4
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/app/helpers/adherent/application_helper.rb +5 -8
- data/app/models/adherent/payment.rb +11 -1
- data/app/models/adherent/query_member.rb +15 -3
- data/app/views/adherent/payments/_form.html.haml +13 -13
- data/lib/adherent/version.rb +3 -1
- data/spec/dummy/log/development.log +10640 -0
- data/spec/dummy/log/test.log +4210 -0
- data/spec/models/adherent/payment_spec.rb +87 -6
- data/spec/models/adherent/query_member_spec.rb +6 -2
- metadata +1 -1
@@ -94,18 +94,99 @@ describe 'Payment', :type => :model do
|
|
94
94
|
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
|
98
|
+
describe 'Imputation on adh' do
|
98
99
|
|
100
|
+
# soit un paiement et une adhésion, lorsqu'on impute le paiement
|
101
|
+
# sur cette adhésion, il est créé un réglement pour le montant adapté,
|
102
|
+
# soit la totalité de l'adhésion si le non imputé est supérieur
|
103
|
+
# soit le montant non imputé si le non imputé est inférieur
|
99
104
|
before(:each) do
|
100
|
-
|
105
|
+
@m = create_members(1).first # on créé un member
|
106
|
+
@p = create_payment(@m) # un payement de 50€ par défaut
|
107
|
+
end
|
108
|
+
|
109
|
+
after(:each) do
|
110
|
+
Adherent::Adhesion.delete_all
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'avec un adhésion de 50' do
|
114
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:50,
|
115
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
116
|
+
@p.imputation_on_adh(@a.id)
|
117
|
+
expect(@p.non_impute).to eq 0
|
118
|
+
expect(@a).to be_is_paid
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'avec un adhésion de 60' do
|
122
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:60,
|
123
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
124
|
+
@p.imputation_on_adh(@a.id)
|
125
|
+
expect(@p.non_impute).to eq 0
|
126
|
+
expect(@a).not_to be_is_paid
|
127
|
+
expect(@a.due).to eq 10
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'avec un adhésion de 60' do
|
131
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:40,
|
132
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
133
|
+
@p.imputation_on_adh(@a.id)
|
134
|
+
expect(@p.non_impute).to eq 10
|
135
|
+
expect(@a).to be_is_paid
|
136
|
+
expect(@a.due).to eq 0
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'list_imputations', wip:true do
|
143
|
+
|
144
|
+
# la liste des imputations donne un Array d'information sur les
|
145
|
+
# règlements associés à un paiement, array construit avec la méthode
|
146
|
+
# member.to_s.
|
147
|
+
# La méthode ne doit pas créer d'erreur même si l'adhésion ou le membre
|
148
|
+
# n'existe plus
|
149
|
+
before(:each) do
|
150
|
+
@m = create_members(1).first # on créé un member
|
151
|
+
@p = create_payment(@m) # un payement de 50€ par défaut
|
152
|
+
end
|
153
|
+
|
154
|
+
after(:each) do
|
155
|
+
Adherent::Adhesion.delete_all
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'avec une seule imputation' do
|
159
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:50,
|
160
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
161
|
+
@p.imputation_on_adh(@a.id)
|
162
|
+
@p.reglements(true)
|
163
|
+
expect(@p.list_imputations).to eq [member:@m.to_s, amount:50, r_id:@p.reglements.first.id]
|
101
164
|
end
|
102
165
|
|
103
|
-
it '
|
104
|
-
|
105
|
-
|
106
|
-
@
|
166
|
+
it 'avec deux imputations' do
|
167
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:10,
|
168
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
169
|
+
@p.imputation_on_adh(@a.id)
|
170
|
+
@a2 = Adherent::Adhesion.create!(member_id:@m.id, amount:10,
|
171
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
172
|
+
@p.imputation_on_adh(@a2.id)
|
173
|
+
@p.reglements(true)
|
174
|
+
expect(@p.list_imputations).
|
175
|
+
to eq([{member:@m.to_s, amount:10, r_id:@p.reglements.first.id},
|
176
|
+
{member:@m.to_s, amount:10, r_id:@p.reglements.last.id}])
|
107
177
|
end
|
108
178
|
|
179
|
+
it 'avec un adhérent effacé, affiche Adhésion inconnue' do
|
180
|
+
@a = Adherent::Adhesion.create!(member_id:@m.id, amount:50,
|
181
|
+
from_date:Date.today, to_date:(Date.today.years_since(1)))
|
182
|
+
@p.imputation_on_adh(@a.id)
|
183
|
+
@p.reglements(true)
|
184
|
+
@a.delete
|
185
|
+
expect(@p.list_imputations).
|
186
|
+
to eq [{member:'Inconnue', amount:50, r_id:@p.reglements.first.id}]
|
187
|
+
end
|
188
|
+
|
189
|
+
|
109
190
|
|
110
191
|
end
|
111
192
|
|
@@ -124,6 +124,10 @@ describe Adherent::QueryMember, :type => :model do
|
|
124
124
|
[Adherent::QueryMember.new(number:'Adh 001', name:'Dupont', forname:'Jules',
|
125
125
|
birthdate:Date.civil(1955,6,6), mail:'bonjour@example.com',
|
126
126
|
tel:'01.02.03.04.05', t_adhesions:22.26, t_reglements:0,
|
127
|
+
office:'03.20.14.64.30',
|
128
|
+
zip:'59000',
|
129
|
+
address:'Place de la Mairie',
|
130
|
+
city:'LILLE',
|
127
131
|
m_to_date:((Date.today.beginning_of_year >> 2) -1))
|
128
132
|
]
|
129
133
|
end
|
@@ -139,11 +143,11 @@ describe Adherent::QueryMember, :type => :model do
|
|
139
143
|
@lignes = csv.split("\n")
|
140
144
|
end
|
141
145
|
it 'la ligne de titre' do
|
142
|
-
expect(@lignes[0]).to eq("Numero\tNom\tPrénom\tDate de naissance\tMail\tTél\tDoit\tFin Adh.")
|
146
|
+
expect(@lignes[0]).to eq("Numero\tNom\tPrénom\tDate de naissance\tMail\tTél\tGsm\tBureau\tAdresse\tCode Postal\tVille\tDoit\tFin Adh.")
|
143
147
|
end
|
144
148
|
|
145
149
|
it 'une ligne de valeurs' do
|
146
|
-
expect(@lignes[1]).to eq("Adh 001\tDupont\tJules\t06/06/1955\tbonjour@example.com\t01.02.03.04.05\t22,26\t#{I18n::l((Date.today.beginning_of_year>>2) -1)}")
|
150
|
+
expect(@lignes[1]).to eq("Adh 001\tDupont\tJules\t06/06/1955\tbonjour@example.com\t01.02.03.04.05\t\t03.20.14.64.30\tPlace de la Mairie\t59000\tLILLE\t22,26\t#{I18n::l((Date.today.beginning_of_year>>2) -1)}")
|
147
151
|
end
|
148
152
|
|
149
153
|
end
|