Skip to content

Commit

Permalink
✨ Add getInfo action route
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianlivella committed Jun 8, 2022
1 parent 8914ffb commit b806707
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/Controllers/WebAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WebAppController
const ACTION_PDF_MODELLO_REDDITI = 'pdf_modello_redditi';
const ACTION_PDF_MODELLO_F24 = 'pdf_modello_f24';
const ACTION_UPLOAD = 'upload';
const ACTION_GET_INFO = 'get_info';
const ACTION_SET_SETTINGS = 'set_settings';

public static function run() {
Expand All @@ -36,6 +37,9 @@ public static function run() {
case self::ACTION_UPLOAD:
self::upload();
break;
case self::ACTION_GET_INFO:
self::getInfo();
break;
case self::ACTION_SET_SETTINGS:
self::setSettings();
break;
Expand Down Expand Up @@ -109,6 +113,18 @@ public static function upload() {
echo json_encode(['report_id' => $reportId] + $reportWrapper->getSummary(true));
}

public static function getInfo() {
$reportId = self::getSelectedReportId();

$exchangeSettings = $settings['exchanges'] ?? [];
$considerEarningsAndExpensesAsInvestment = $settings['consider_earnings_and_expenses_as_investment'] ?? true;

$reportWrapper = new ReportWrapper(self::getSelectedReportContent(), $exchangeSettings, $considerEarningsAndExpensesAsInvestment);

header('Content-type: application/json');
echo json_encode(['report_id' => $reportId] + $reportWrapper->getSummary(true));
}

public static function setSettings() {
$reportId = self::getSelectedReportId();
$settings = self::getSelectedReportSettings();
Expand Down

0 comments on commit b806707

Please sign in to comment.