adherent 0.3.5 → 0.3.6

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
  SHA1:
3
- metadata.gz: c9453a892990d0b8f648539d14f09ba379a24067
4
- data.tar.gz: 3fb67efc34fd4e646e8243fa3b7d5ef33934673d
3
+ metadata.gz: bcb31a14740d77a176e63a7f0d07182c1084cf77
4
+ data.tar.gz: 9554bf9e5da5cf3dff4a991fb18065f663dd7e2c
5
5
  SHA512:
6
- metadata.gz: d7a94e6b21b12fbe84b25352282c773a0aa7866b86c1479505a30bc51ac3bbd724f4f52d2a92fbd22a3ae11deb824bb5bb4d22f9425acd807d9438ca00eb088a
7
- data.tar.gz: 6ac210132b30cc57195784567bfc49f6a193f0f08f5b65b02c5e5715b06503507476c92e2c72211b4aa93ab9ff3f32dc9a0a0a600a5e481c04108ae0ec4c45a5
6
+ metadata.gz: 46a4a5da98bac79da37c61fac452c73c15e7b98a9903cd776fe6112fd0ee33fd88bfc570a63924ca31dfc05e33f4041f9045f7a1710e8e4b61aae9c26a8c4766
7
+ data.tar.gz: 0ff293aa381e091f8e7f59660c7d397ba6e4dd2f08d06c7a44c9de6044a1a3b7aa4ee7e4e4bbb12dbe6aed39bb6b163d78cd690f1db2c524baf1eefcc1baaca1
@@ -38,8 +38,11 @@ module Adherent
38
38
  end
39
39
 
40
40
  def imputation_with_actions(pay, r)
41
+ # on gère le cas où l'adhésion a disparu (car le membre a disparu)
42
+ a = r.adhesion
43
+ mem = a ? a.member : 'supprimée'
41
44
  html = ''
42
- html << "Adhésion #{r.adhesion.member} pour #{number_to_currency(r.adhesion.amount, locale: :fr)}"
45
+ html << "Adhésion #{mem} pour #{number_to_currency(r.amount, locale: :fr)}"
43
46
  html << "&nbsp;&nbsp;"
44
47
  html << "#{icon_to 'detail.png', payment_reglement_path(pay.id, r.id)}"
45
48
  html.html_safe
@@ -14,23 +14,22 @@ module Adherent
14
14
  # TODO A voir, il peut y avoir des paiements partiels ou total
15
15
  def recu_cotisation(payment, member)
16
16
  rs = payment.reglements
17
- if rs.count == 1 && rs.first.adhesion.member == member
17
+ if rs.count == 1 && rs.first.try(:adhesion).try(:member) == member
18
18
  adh = rs.first.adhesion
19
- "votre adhésion pour la période #{du_au(adh.from_date, adh.to_date)}"
19
+ "Adhésion pour la période #{du_au(adh.from_date, adh.to_date)}"
20
20
 
21
21
  elsif rs.size == 1
22
22
  # une seule adhésion mais pas pour lui
23
23
  adh = rs.first.adhesion
24
- m = adh.member
25
- "l'adhésion de #{m.forname} #{m.name} pour la période #{du_au(adh.from_date, adh.to_date)}"
24
+ "l'adhésion de #{coords(adh)} pour la période #{pour(adh)}"
26
25
  else
27
26
  # plusieurs adhésions
28
27
  str = "les adhésions de <ul>"
29
28
  rs.each do |r|
30
29
  str+='<li>'
31
30
  adh = r.adhesion
32
- m = adh.member
33
- str += "#{m.forname} #{m.name} pour la période #{du_au(adh.from_date, adh.to_date)}"
31
+
32
+ str += "#{coords(adh)} pour la période #{pour(adh)}"
34
33
  str += '</li>'
35
34
  end
36
35
  str += '</ul>'
@@ -44,5 +43,21 @@ module Adherent
44
43
  def du_au(from_date, to_date)
45
44
  "du #{from_date} au #{to_date}"
46
45
  end
46
+
47
+ def coords(adh)
48
+ if adh && m = adh.member
49
+ "#{m.name} #{m.forname}"
50
+ else
51
+ 'Effacé'
52
+ end
53
+ end
54
+
55
+ def pour(adh)
56
+ if adh
57
+ "#{du_au(adh.from_date, adh.to_date)}"
58
+ else
59
+ 'du ??? au ???'
60
+ end
61
+ end
47
62
  end
48
63
  end
@@ -19,12 +19,10 @@ module Adherent
19
19
 
20
20
  has_many :reglements, :dependent=>:destroy
21
21
  belongs_to :member
22
-
23
-
24
- # attr_accessible :amount, :date, :mode
25
-
22
+
26
23
  validates :amount, :date, :mode, :member_id, presence:true
27
- validates :amount, :over_imputations=>true
24
+ # le validator over_imputations est défini dans config/initializers/validators.rb
25
+ validates :amount, :over_imputations=>true, :if=>'amount'
28
26
  validates :comment, :format=>{with:NAME_REGEX},
29
27
  :length=>{:maximum=>LONG_NAME_LENGTH_MAX}, allow_blank: true
30
28
 
@@ -21,5 +21,6 @@ module Adherent
21
21
  # VERSION = '0.3.2' # find_member est maintenant défini dans ApplicationController
22
22
  # VERSION = '0.3.3' # retour en arrière car find_member(id) et find_member(member_id)
23
23
  # VERSION = '0.3.4' # les règlements sans adhésion s'affichent
24
- VERSION = '0.3.5' # Affichage plus rapide des paiements
24
+ # VERSION = '0.3.5' # Affichage plus rapide des paiements
25
+ VERSION = '0.3.6' # Affichage plus rapide des paiements
25
26
  end
@@ -118252,3 +118252,23 @@ Started GET "/assets/adherent/reglements.js?body=1" for 127.0.0.1 at 2015-10-12
118252
118252
 
118253
118253
 
118254
118254
  Started GET "/assets/adherent/icones/supprimer.png" for 127.0.0.1 at 2015-10-12 19:37:10 +0200
118255
+ Adherent::Reglement Load (163.4ms) SELECT "adherent_reglements".* FROM "adherent_reglements" WHERE (amount = 10)
118256
+ Adherent::Reglement Load (2.4ms) SELECT "adherent_reglements".* FROM "adherent_reglements" WHERE (amount = 26.66)
118257
+ Adherent::Reglement Load (2.1ms) SELECT "adherent_reglements".* FROM "adherent_reglements" WHERE (amount = 10.0)
118258
+  (432.0ms) DROP DATABASE IF EXISTS "adh_test"
118259
+  (5625.3ms) CREATE DATABASE "adh_test" ENCODING = 'unicode'
118260
+ SQL (4.0ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
118261
+  (130.3ms) CREATE TABLE "adherent_adhesions" ("id" serial primary key, "from_date" date, "to_date" date, "amount" decimal(10,2), "member_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
118262
+  (38.9ms) CREATE INDEX "index_adherent_adhesions_on_member_id" ON "adherent_adhesions" USING btree ("member_id")
118263
+  (55.9ms) CREATE TABLE "adherent_coords" ("id" serial primary key, "mail" character varying(255), "tel" character varying(255), "gsm" character varying(255), "office" character varying(255), "address" text, "zip" character varying(255), "city" character varying(255), "member_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
118264
+  (49.4ms) CREATE TABLE "adherent_members" ("id" serial primary key, "number" character varying(255), "name" character varying(255), "forname" character varying(255), "birthdate" date, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "organism_id" integer) 
118265
+  (175.8ms) CREATE TABLE "adherent_payments" ("id" serial primary key, "date" date, "amount" decimal(10,2), "mode" character varying(255), "member_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "comment" character varying(255))
118266
+  (9.2ms) CREATE INDEX "index_adherent_payments_on_member_id" ON "adherent_payments" USING btree ("member_id")
118267
+  (32.3ms) CREATE TABLE "adherent_reglements" ("id" serial primary key, "amount" decimal(10,2), "adhesion_id" integer, "payment_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
118268
+  (22.0ms) CREATE INDEX "index_adherent_reglements_on_adhesion_id" ON "adherent_reglements" USING btree ("adhesion_id")
118269
+  (4.9ms) CREATE INDEX "index_adherent_reglements_on_payment_id" ON "adherent_reglements" USING btree ("payment_id")
118270
+  (13.6ms) CREATE TABLE "organisms" ("id" serial primary key, "title" character varying(255), "status" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
118271
+  (2.6ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL)
118272
+  (5.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
118273
+  (0.6ms) SELECT version FROM "schema_migrations"
118274
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20130810074112')