Skip to content

Commit

Permalink
[feature] project report updates (#621)
Browse files Browse the repository at this point in the history
* Fix code formatting

* Add incomes table to project report

* Add relevant associated ids to project report

* Rename project num id to tracking number
  • Loading branch information
subiabre authored Oct 17, 2024
1 parent e659089 commit 722151c
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 152 deletions.
8 changes: 7 additions & 1 deletion Resources/templates/default/admin/projects/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

<?php $this->section('admin-project-content') ?>

<?= Goteo\Core\View::get('project/report.html.php', array('project' => $this->project, 'account' => $this->account, 'Data' => $this->data, 'admin'=>true)) ?>
<?= Goteo\Core\View::get('project/report.html.php', [
'project' => $this->project,
'account' => $this->account,
'contract' => $this->contract,
'Data' => $this->data,
'admin' => true
]) ?>

<?php $this->replace() ?>

305 changes: 156 additions & 149 deletions Resources/templates/legacy/project/report.html.php

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions Resources/templates/legacy/project/report_table.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
$project = $vars['projects'];

$account = $vars['account'];
if (!$account->vat) {
$account->vat = 21;
}

$projectFee = round($account->fee / 100, 2);

$tpvTotal = $vars['Data']['tpv']['total']['amount'];
$tpvProjectFee = $tpvTotal * $projectFee;
$tpvProjectVat = $tpvProjectFee * 0.21;
$tpvGatewayFee = $tpvTotal * 0.008;
$tpvGatewayVat = 0;

$paypalTotal = $vars['Data']['paypal']['total']['amount'];
$paypalProjectFee = $paypalTotal * $projectFee;
$paypalProjectVat = $paypalProjectFee * 0.21;
$paypalGatewayFee = ($paypalTotal * 0.034) + ($vars['Data']['paypal']['total']['invests'] * 0.35);
$paypalGatewayVat = 0;

$poolTotal = $vars['Data']['pool']['total']['amount'];
$poolProjectFee = $poolTotal * $projectFee;
$poolProjectVat = $poolProjectFee * 0.21;
$poolGatewayFee = $poolTotal * 0.02;
$poolGatewayVat = $poolGatewayFee * 0.21;

$cashTotal = $vars['Data']['cash']['total']['amount'];
$cashProjectFee = $cashTotal * $projectFee;
$cashProjectVat = $cashProjectFee * 0.21;
$cashGatewayFee = $cashTotal * 0.02;
$cashGatewayVat = $cashGatewayFee * 0.21;

$totalTotal = $cashTotal + $poolTotal + $paypalTotal + $tpvTotal;
$totalProjectFee = $cashProjectFee + $poolProjectFee + $paypalProjectFee + $tpvProjectFee;
$totalProjectVat = $cashProjectVat + $poolProjectVat + $paypalProjectVat + $tpvProjectVat;
$totalGatewayFee = $cashGatewayFee + $poolGatewayFee + $paypalGatewayFee + $tpvGatewayFee;
$totalGatewayVat = $cashGatewayVat + $poolGatewayVat + $paypalGatewayVat + $tpvGatewayVat;

$reportData = [
'TPV' => [
'base' => \amount_format($tpvTotal, 2),
'project_fee' => sprintf("%s (%s%%)", \amount_format($tpvProjectFee, 2), $account->fee,),
'project_vat' => sprintf("%s (21%%)", \amount_format($tpvProjectVat, 2),),
'gateway_fee' => sprintf("%s (0,8%%)", \amount_format($tpvGatewayFee, 2)),
'gateway_vat' => sprintf("%s (21%%)", \amount_format($tpvGatewayVat, 2))
],
'PAYPAL' => [
'base' => \amount_format($paypalTotal, 2),
'project_fee' => sprintf("%s (%s%%)", \amount_format($paypalProjectFee, 2), $account->fee),
'project_vat' => sprintf("%s (21%%)", \amount_format($paypalProjectVat, 2)),
'gateway_fee' => sprintf("%s (3,4%% + 0,35 * trx)", \amount_format($paypalGatewayFee, 2)),
'gateway_vat' => sprintf("%s (21%%)", \amount_format($paypalGatewayVat, 2))
],
'MONEDERO' => [
'base' => \amount_format($poolTotal, 2),
'project_fee' => sprintf("%s (%s%%)", \amount_format($poolProjectFee, 2), $account->fee),
'project_vat' => sprintf("%s (21%%)", \amount_format($poolProjectVat, 2)),
'gateway_fee' => sprintf("%s (2%%)", \amount_format($poolGatewayFee, 2)),
'gateway_vat' => sprintf("%s (21%%)", \amount_format($poolGatewayVat, 2))
],
'MANUAL' => [
'base' => \amount_format($cashTotal, 2),
'project_fee' => sprintf("%s (%s%%)", \amount_format($cashProjectFee, 2), $account->fee),
'project_vat' => sprintf("%s (21%%)", \amount_format($cashProjectVat, 2)),
'gateway_fee' => sprintf("%s (2%%)", \amount_format($cashGatewayFee, 2)),
'gateway_vat' => sprintf("%s (21%%)", \amount_format($cashGatewayVat, 2)),
],
'TOTAL' => [
'base' => \amount_format($totalTotal, 2),
'project_fee' => sprintf("%s", \amount_format($totalProjectFee, 2)),
'project_vat' => sprintf("%s", \amount_format($totalProjectVat, 2)),
'gateway_fee' => sprintf("%s", \amount_format($totalGatewayFee, 2)),
'gateway_vat' => sprintf("%s", \amount_format($totalGatewayVat, 2))
]
];

?>
<table>
<tr>
<td></td>
<td>RECAUDACIÓN</td>
<td>COMISIÓN DE GOTEO</td>
<td>IVA</td>
<td>COMISIONES COBRADAS A GOTEO</td>
<td>IVA</td>
</tr>
<?php foreach ($reportData as $key => $value): ?>
<tr>
<td><?= $key ?></td>
<td><?= $value['base'] ?></td>
<td><?= $value['project_fee'] ?></td>
<td><?= $value['project_vat'] ?></td>
<td><?= $value['gateway_fee'] ?></td>
<td><?= $value['gateway_vat'] ?></td>
</tr>
<?php endforeach; ?>
</table>
2 changes: 2 additions & 0 deletions src/Goteo/Controller/Admin/ProjectsSubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ public function reportAction($id) {
// Datos para el informe de transacciones correctas
$data = Model\Invest::getReportData($project->id, $project->status, $project->round, $project->passed);
$account = Model\Project\Account::get($project->id);
$contract = Model\Contract::get($project->id);

return array(
'template' => 'admin/projects/report',
'project' => $project,
'account' => $account,
'contract' => $contract,
'data' => $data
);
}
Expand Down
2 changes: 1 addition & 1 deletion translations/ca/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dashboard-menu-profile-personal: 'Dades personals'
dashboard-menu-profile-preferences: 'Preferències'
dashboard-menu-profile-profile: 'Edita el Perfil'
dashboard-menu-profile-public: 'Perfil públic'
dashboard-menu-project-nid: 'Identificador numèric de projecte'
dashboard-menu-project-nid: 'Número de seguiment'
dashboard-menu-projects: 'Projectes'
dashboard-menu-projects-analytics: Analítica
dashboard-menu-projects-commons: Retorns
Expand Down
2 changes: 1 addition & 1 deletion translations/es/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dashboard-menu-profile-personal: 'Datos personales'
dashboard-menu-profile-preferences: 'Mis preferencias'
dashboard-menu-profile-profile: 'Editar perfil'
dashboard-menu-profile-public: 'Perfil público'
dashboard-menu-project-nid: 'Identificador numérico de proyecto'
dashboard-menu-project-nid: 'Número de seguimiento'
dashboard-menu-projects: 'Mis proyectos'
dashboard-menu-projects-analytics: Analítica
dashboard-menu-projects-commons: Retornos
Expand Down

0 comments on commit 722151c

Please sign in to comment.