質問編集履歴
1
payment_helperの記載追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -369,3 +369,49 @@
|
|
369
369
|
</div>
|
370
370
|
|
371
371
|
```
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
payments_helper.rb
|
376
|
+
|
377
|
+
```
|
378
|
+
|
379
|
+
module PaymentsHelper
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
def this_month
|
384
|
+
|
385
|
+
Date.today
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
def payments_this_month
|
392
|
+
|
393
|
+
@payments_this_month = current_user.payments.where(created_at: this_month.in_time_zone.all_month)
|
394
|
+
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
def sum_payment_this_month
|
400
|
+
|
401
|
+
sum = 0
|
402
|
+
|
403
|
+
payments_this_month
|
404
|
+
|
405
|
+
@payments_this_month.each { |n| sum += n.price}
|
406
|
+
|
407
|
+
sum
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
```
|