Fehler bei der Berechnung der offenen Beiträge in der Liste der Beträge nach Mitglied
authorPascal Hofmann <mail@pascalhofmann.de>
Sun, 1 Aug 2010 12:31:11 +0000 (14:31 +0200)
committerPascal Hofmann <mail@pascalhofmann.de>
Sun, 1 Aug 2010 12:31:11 +0000 (14:31 +0200)
include/fees.php

index 4c1f6e2..b58122d 100644 (file)
@@ -153,8 +153,8 @@ function fees_get_list_for_month($year, $month) {
 
 function fee_next_directdebit_for_member($member_id, $max_date = NULL) {
 
-       $member = db_get_member_with_id($member_id);
-       if (!$member['directdebit']) return;
+    $member = db_get_member_with_id($member_id);
+    if (!$member['directdebit']) return;
 
     $sum_old_fees   = fees_sum_for_member($member_id, DIRECTDEBIT_DATE - 86400);
     $sum_new_paid   = finance_get_paid_fees_for_member($member_id);
@@ -246,16 +246,19 @@ function render_fees_by_member() {/*{{{*/
 <?php if (empty($members)) $members = array(); ?>
 <?php foreach ($members as $member) : ?>
 <?php
-       $total_fees = fees_sum_for_member($member['id'], time());
-       $current_fee = fees_for_member_at_date($member['id'], time());
-       $old_paid_fees = finance_get_paid_fees_for_member($member['id'], true);
-       $new_paid_fees = finance_get_paid_fees_for_member($member['id']);
-       $open_fees = bcsub(bcsub($total_fees, $old_paid_fees), $new_paid_fees);
+    $current_fee  = fees_for_member_at_date($member['id'], time());
+
+    $sum_fees     = fees_sum_for_member($member['id'], time());
+    $sum_old_fees = fees_sum_for_member($member['id'], DIRECTDEBIT_DATE - 86400);
+    $sum_old_paid = finance_get_paid_fees_for_member($member['id'], true);
+    $sum_new_paid = finance_get_paid_fees_for_member($member['id']);
+    $sum_new_fees = bcsub($sum_fees, $sum_old_fees);
+    $open_fees    = bcadd(bcsub($sum_old_fees, $sum_old_paid), max(bcsub($sum_new_fees, $sum_new_paid), 0));
 ?>
     <tr>
         <td><a href="<?=html_escape(link_to('fees', array('member_id'=> $member['id'])))?>"><?=html_escape($member['number'])?></a></td>
         <td><?=html_escape($member['nickname'])?></td>
-        <td style="text-align: right;"><?=format_money($total_fees)?></td>
+        <td style="text-align: right;"><?=format_money($sum_fees)?></td>
         <td style="text-align: right;"><?=isset($current_fee) ? format_money($current_fee) : '-' ?></td>
         <td style="text-align: right;"><?=$open_fees > 0 ? format_money($open_fees) : '-' ?></td>
     </tr>