Skip to content

Commit

Permalink
Merge pull request #46 from systopia/master
Browse files Browse the repository at this point in the history
CiviBanking 0.3.7
  • Loading branch information
bjendres committed May 2, 2014
2 parents 281547e + 4d17e20 commit 07ccf22
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 24 deletions.
8 changes: 4 additions & 4 deletions extension/CRM/Banking/Page/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function run() {
$weeks[] = date('YW', strtotime("now -$i weeks"));
$account_based_data_sql = "
SELECT
COUNT(*) AS count,
YEARWEEK(value_date) AS year_week,
ba_id AS bank_account_id,
status_id AS status_id
COUNT(*) AS count,
YEARWEEK(value_date,3) AS year_week,
ba_id AS bank_account_id,
status_id AS status_id
FROM
civicrm_bank_tx
GROUP BY
Expand Down
27 changes: 20 additions & 7 deletions extension/CRM/Banking/Page/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,17 @@ function build_statementPage($payment_states) {
if ($_REQUEST['status_ids']==$payment_states['new']['id']) {
// 'NEW' mode will show all that have not been completely analysed
$this->assign('rows', $statements_new);
$this->assign('status_message', sizeof($statements_new).' incomplete statements.');
$this->assign('status_message', sprintf(ts("%d incomplete statments."), sizeof($statements_new)));

} elseif ($_REQUEST['status_ids']==$payment_states['suggestions']['id']) {
// 'ANALYSED' mode will show all that have been partially analysed, but not all completed
$this->assign('rows', $statements_analysed);
$this->assign('status_message', sizeof($statements_analysed).' analysed statements.');
$this->assign('status_message', sprintf(ts("%d analysed statments."), sizeof($statements_analysed)));

} else {
// 'COMPLETE' mode will show all that have been entirely processed
$this->assign('rows', $statements_completed);
$this->assign('status_message', sizeof($statements_completed).' completed statements.');
$this->assign('status_message', sprintf(ts("%d completed statments."), sizeof($statements_completed)));
}

$this->assign('target_accounts', $target_accounts);
Expand Down Expand Up @@ -224,14 +224,16 @@ function build_paymentPage($payment_states) {
$params = array('version' => 3, 'id' => $ba_id);
$result = civicrm_api('BankingAccount', 'getsingle', $params);

$contact = null;
$attached_ba = null;
$party = null;
if (!empty($entry['party_ba_id'])) {
$pba_id = $entry['party_ba_id'];
$params = array('version' => 3, 'id' => $pba_id);
$attached_ba = civicrm_api('BankingAccount', 'getsingle', $params);
}

$cid = isset($attached_ba['contact_id']) ? $attached_ba['contact_id'] : null;
$contact = null;
if ($cid) {
$params = array('version' => 3, 'id' => $cid);
$contact = civicrm_api('Contact', 'getsingle', $params);
Expand Down Expand Up @@ -265,8 +267,19 @@ function build_paymentPage($payment_states) {
}

$this->assign('rows', $payment_rows);
$this->assign('status_message', sizeof($payment_rows).' unprocessed payments.');
$this->assign('show', 'payments');
if ($_REQUEST['status_ids']==$payment_states['new']['id']) {
// 'NEW' mode will show all that have not been completely analysed
$this->assign('status_message', sprintf(ts("%d new payments."), count($payment_rows)));

} elseif ($_REQUEST['status_ids']==$payment_states['suggestions']['id']) {
// 'ANALYSED' mode will show all that have been partially analysed, but not all completed
$this->assign('status_message', sprintf(ts("%d analysed payments."), count($payment_rows)));

} else {
// 'COMPLETE' mode will show all that have been entirely processed
$this->assign('status_message', sprintf(ts("%d completed payments."), count($payment_rows)));
}
}


Expand Down Expand Up @@ -371,8 +384,8 @@ function investigate($stmt_id, $payment_states) {
}

return array(
'analysed' => round(($analysed_count+$completed_count) / $count * 100.0),
'completed' => round($completed_count / $count * 100.0),
'analysed' => floor(($analysed_count+$completed_count) / $count * 100.0),
'completed' => floor($completed_count / $count * 100.0),
'target_account' => "Unknown"
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_
foreach ($config->required_values as $required_key) {
if ($this->getPropagationValue($btx, $required_key)==NULL) {
// there is no value given for this key => bail
error_log("Missing: $required_key");
//error_log("Missing: $required_key");
return null;
}
}
Expand Down Expand Up @@ -120,8 +120,8 @@ public function update_parameters(CRM_Banking_Matcher_Suggestion $match, $parame
*/
function visualize_match( CRM_Banking_Matcher_Suggestion $match, $btx) {

$contribution = $this->get_contribution_data($btx, $contact_id);
$contact_id = $match->getParameter('contact_id');
$contribution = $this->get_contribution_data($btx, $contact_id);
$contact_link = CRM_Utils_System::url("civicrm/contact/view", "&reset=1&cid=$contact_id");

// load contact
Expand Down Expand Up @@ -174,6 +174,9 @@ function get_contribution_data($btx, $contact_id) {
$contribution['contact_id'] = $contact_id;
$contribution['total_amount'] = $btx->amount;
$contribution['receive_date'] = $btx->value_date;
if (empty($contribution['currency'])) {
$contribution['currency'] = 'EUR';
}
return $contribution;
}
}
Expand Down
9 changes: 9 additions & 0 deletions extension/CRM/Banking/PluginImpl/Matcher/RegexAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ function processMatch($match_data, $match_index, &$data_parsed, $rule) {
// SET value regardless of the match contect
$data_parsed[$action->to] = $action->value;

} elseif ($action->action=='map') {
// SET value regardless of the match contect
$value = $match_data[$action->from][$match_index];
if (isset($action->mapping->$value)) {
$data_parsed[$action->to] = $action->mapping->$value;
} else {
error_log("org.project60.banking: RegexAnalyser - incomplete mapping: '".$action->action."'");
}

} elseif (substr($action->action, 0, 7) =='lookup:') {
// LOOK UP values via API::getsingle
// parameters are in format: "EntityName,result_field,lookup_field"
Expand Down
2 changes: 1 addition & 1 deletion extension/CRM/Banking/PluginModel/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function checkAndStoreBTX($btx, $progress, $params = array()) {
// check for dry run
if (isset($params['dry_run']) && $params['dry_run'] == "on") {
// DRY RUN ENABLED
$this->reportProgress($progress, sprintf(ts("DRY RUN: Did not create bank transaction '%d' (%s %s on %s)"), $result['id'], number_format((float) $btx['amount'], 2), $btx['currency'], $btx['booking_date']));
$this->reportProgress($progress, sprintf(ts("DRY RUN: Did not create bank transaction (%s %s on %s)"), number_format((float) $btx['amount'], 2), $btx['currency'], $btx['booking_date']));
return TRUE;
} else {
// attach to the transaction batch, if there is an open one
Expand Down
4 changes: 2 additions & 2 deletions extension/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<author>CiviCRM banking integration working group ("Project 60")</author>
<email>endres@systopia.de</email>
</maintainer>
<releaseDate>2014-04-03</releaseDate>
<version>0.3.5</version>
<releaseDate>2014-05-01</releaseDate>
<version>0.3.7</version>
<develStage>alpha</develStage>
<compatibility>
<ver>4.4</ver>
Expand Down
25 changes: 17 additions & 8 deletions extension/templates/CRM/Banking/Page/Dashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,31 @@ td.week_incomplete {
{foreach from=$account_week_data item=account_data key=account_id}
<tr>
<td>{$account_names.$account_id}</td>
{assign var=done value=$account_data.before.done}
{if not $done}{assign var=done value=0}{/if}
{assign var=sum value=$account_data.before.sum}
{if not $sum}{assign var=sum value=0}{/if}
{if $account_data.before.sum == 0}
{if $sum == 0}
<td class="week_none" title="{ts}There are no records for this time span.{/ts}"><i>{ts}no records{/ts}</i></td>
{elseif $account_data.before.sum == $account_data.before.done}
<td class="week_complete" title="{$account_data.before.done} / {$account_data.before.sum}">100&nbsp;%</td>
{elseif $sum == $done}
<td class="week_complete" title="{$done} / {$sum}">100&nbsp;%</td>
{else}
<td class="week_incomplete" title="{$account_data.before.done} / {$account_data.before.sum}">{math equation="floor(done/count*100.0)" done=$account_data.before.done count=$account_data.before.sum}&nbsp;%</td>
<td class="week_incomplete" title="{$done} / {$sum}">{math equation="floor(done/count*100.0)" done=$done count=$sum}&nbsp;%</td>
{/if}
{foreach from=$weeks item=week}
{if $account_data.$week.sum == 0}
{assign var=done value=$account_data.$week.done}
{if not $done}{assign var=done value=0}{/if}
{assign var=sum value=$account_data.$week.sum}
{if not $sum}{assign var=sum value=0}{/if}
{if $sum == 0}
<td class="week_none" title="{ts}There are no records for this time span.{/ts}"><i>{ts}no records{/ts}</i></td>
{elseif $account_data.$week.sum == $account_data.$week.done}
<td class="week_complete" title="{$account_data.$week.done} / {$account_data.$week.sum}">100&nbsp;%</td>
{elseif $sum == $done}
<td class="week_complete" title="{$done} / {$sum}">100&nbsp;%</td>
{else}
<td class="week_incomplete" title="{$account_data.$week.done} / {$account_data.$week.sum}">{math equation="floor(done/count*100.0)" done=$account_data.$week.done count=$account_data.$week.sum}&nbsp;%</td>
<td class="week_incomplete" title="{$done} / {$sum}">{math equation="floor(done/count*100.0)" done=$done count=$sum}&nbsp;%</td>
{/if}
{/foreach}
<tr>
Expand Down
15 changes: 15 additions & 0 deletions extension/versions.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Version History
===============

version 0.3.7
=============
- FIX: payment view same contact shown repeatedly
- FIX: payment view title wrong
- FIX: dashboard was one week off
- FIX: minor fixes in matcher_create
- RegexAnalyser: added mapping action


version 0.3.6
=============
- FIX: php warning in dashboard (when no payments completeted)
- FIX: percentages in statment view


version 0.3.5
=============
- added dashboard
Expand Down
28 changes: 28 additions & 0 deletions l10n/CiviBanking.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1295,3 +1295,31 @@ msgstr ""
#: templates/CRM/Banking/Page/Dashboard.tpl
msgid "There are no records for this time span."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d incomplete statments."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d analysed statments."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d completed statments."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d new payments."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d analysed payments."
msgstr ""

#: on/CRM/Banking/Page/Payments.php
msgid "%d completed payments."
msgstr ""

#: on/CRM/Banking/PluginModel/Importer.php
msgid "DRY RUN: Did not create bank transaction (%s %s on %s)"
msgstr ""
Binary file modified l10n/CiviBanking_de_DE.mo
Binary file not shown.
28 changes: 28 additions & 0 deletions l10n/CiviBanking_de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,34 @@ msgstr "Das Konfigurationsinterface ist leider noch nicht funktional."
msgid "There are no records for this time span."
msgstr "Für diesen Zeitraum gibt es keine Einträge"

#: on/CRM/Banking/Page/Payments.php
msgid "%d incomplete statments."
msgstr "%d neue oder unvollständige Kontoauszüge."

#: on/CRM/Banking/Page/Payments.php
msgid "%d analysed statments."
msgstr "%d analysierte Kontoauszüge."

#: on/CRM/Banking/Page/Payments.php
msgid "%d completed statments."
msgstr "%d abgeschlossene Kontoauszüge."

#: on/CRM/Banking/Page/Payments.php
msgid "%d new payments."
msgstr "%d neue Zahlungen."

#: on/CRM/Banking/Page/Payments.php
msgid "%d analysed payments."
msgstr "%d analysierte Zahlungen."

#: on/CRM/Banking/Page/Payments.php
msgid "%d completed payments."
msgstr "%d abgeschlossene Zahlungen."

#: on/CRM/Banking/PluginModel/Importer.php
msgid "DRY RUN: Did not create bank transaction (%s %s on %s)"
msgstr "TESTLAUF: Keine Zahlung angelegt '%d' (%s %s on %s)"

#, fuzzy
#~ msgid "Payment count<"
#~ msgstr "Anzahl"
Expand Down

0 comments on commit 07ccf22

Please sign in to comment.