diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 534acf8488..1f39963a53 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -131,6 +131,7 @@ abstract class Controller extends BaseController
$this->primaryCurrency = null;
// get shown-intro-preference:
if (auth()->check()) {
+ View::share('anonymous', Steam::anonymous());
$this->primaryCurrency = Amount::getPrimaryCurrency();
$language = Steam::getLanguage();
$locale = Steam::getLocale();
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index c5beecfeb4..217a400006 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -30,6 +30,7 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
+use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@@ -114,6 +115,7 @@ class JavascriptController extends Controller
'currencyCode' => $currency->code,
'currencySymbol' => $currency->symbol,
'accountingLocaleInfo' => $accounting,
+ 'anonymous' => var_export(Steam::anonymous(), true),
'language' => $lang,
'dateRangeTitle' => $dateRange['title'],
'locale' => $locale,
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 98e8aa284c..22e44a1316 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -163,6 +163,7 @@ class Amount
*/
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
{
+ $amount = Steam::anonymous() ? '0' : $amount;
$locale = Steam::getLocale();
$rounded = Steam::bcround($amount, $decimalPlaces);
$coloured ??= true;
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 586ecd4a7b..2dfc48ee3f 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -627,6 +627,19 @@ class Steam
return $locale;
}
+ public function anonymous(): bool // get preference
+ {
+ $singleton = PreferencesSingleton::getInstance();
+ $cached = $singleton->getPreference('anonymous');
+ if (null !== $cached) {
+ return $cached;
+ }
+ $anonymous = app('preferences')->get('anonymous', config('firefly.default_preferences.anonymous', false))->data;
+ $singleton->setPreference('anonymous', $anonymous);
+
+ return $anonymous;
+ }
+
public function getLocaleArray(string $locale): array
{
return [
diff --git a/config/firefly.php b/config/firefly.php
index b5e0be9d48..4801282895 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -182,6 +182,7 @@ return [
'darkMode' => 'browser',
'list_length' => 10, // to be removed if v1 is cancelled.
'default_preferences' => [
+ 'anonymous' => false,
'frontpageAccounts' => [],
'listPageSize' => 50,
'currencyPreference' => 'EUR',
@@ -409,7 +410,7 @@ return [
],
- 'rule-actions' => [
+ 'rule-actions' => [
'set_category' => SetCategory::class,
'clear_category' => ClearCategory::class,
'set_budget' => SetBudget::class,
@@ -443,7 +444,7 @@ return [
// 'set_foreign_amount' => SetForeignAmount::class,
// 'set_foreign_currency' => SetForeignCurrency::class,
],
- 'context-rule-actions' => [
+ 'context-rule-actions' => [
'set_category',
'set_budget',
'add_tag',
@@ -462,13 +463,13 @@ return [
'convert_transfer',
],
- 'test-triggers' => [
+ 'test-triggers' => [
'limit' => 10,
'range' => 200,
],
// expected source types for each transaction type, in order of preference.
- 'expected_source_types' => [
+ 'expected_source_types' => [
'source' => [
TransactionTypeEnum::WITHDRAWAL->value => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
TransactionTypeEnum::DEPOSIT->value => [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::CASH->value],
@@ -513,7 +514,7 @@ return [
TransactionTypeEnum::LIABILITY_CREDIT->value => [AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
],
],
- 'allowed_opposing_types' => [
+ 'allowed_opposing_types' => [
'source' => [
AccountTypeEnum::ASSET->value => [
AccountTypeEnum::ASSET->value,
@@ -603,7 +604,7 @@ return [
],
],
// depending on the account type, return the allowed transaction types:
- 'allowed_transaction_types' => [
+ 'allowed_transaction_types' => [
'source' => [
AccountTypeEnum::ASSET->value => [
TransactionTypeEnum::WITHDRAWAL->value,
@@ -672,7 +673,7 @@ return [
],
// having the source + dest will tell you the transaction type.
- 'account_to_transaction' => [
+ 'account_to_transaction' => [
AccountTypeEnum::ASSET->value => [
AccountTypeEnum::ASSET->value => TransactionTypeEnum::TRANSFER->value,
AccountTypeEnum::CASH->value => TransactionTypeEnum::WITHDRAWAL->value,
@@ -737,7 +738,7 @@ return [
],
// allowed source -> destination accounts.
- 'source_dests' => [
+ 'source_dests' => [
TransactionTypeEnum::WITHDRAWAL->value => [
AccountTypeEnum::ASSET->value => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CASH->value],
AccountTypeEnum::LOAN->value => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::CASH->value],
@@ -776,7 +777,7 @@ return [
],
],
// if you add fields to this array, don't forget to update the export routine (ExportDataGenerator).
- 'journal_meta_fields' => [
+ 'journal_meta_fields' => [
// sepa
'sepa_cc',
'sepa_ct_op',
@@ -810,47 +811,47 @@ return [
'recurrence_count',
'recurrence_date',
],
- 'webhooks' => [
+ 'webhooks' => [
'max_attempts' => env('WEBHOOK_MAX_ATTEMPTS', 3),
],
- 'can_have_virtual_amounts' => [AccountTypeEnum::ASSET->value],
- 'can_have_opening_balance' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
- 'dynamic_creation_allowed' => [
+ 'can_have_virtual_amounts' => [AccountTypeEnum::ASSET->value],
+ 'can_have_opening_balance' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
+ 'dynamic_creation_allowed' => [
AccountTypeEnum::EXPENSE->value,
AccountTypeEnum::REVENUE->value,
AccountTypeEnum::INITIAL_BALANCE->value,
AccountTypeEnum::RECONCILIATION->value,
AccountTypeEnum::LIABILITY_CREDIT->value,
],
- 'valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
- 'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
- 'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],
+ 'valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
+ 'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
+ 'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],
// dynamic date ranges are as follows:
- 'dynamic_date_ranges' => ['last7', 'last30', 'last90', 'last365', 'MTD', 'QTD', 'YTD'],
+ 'dynamic_date_ranges' => ['last7', 'last30', 'last90', 'last365', 'MTD', 'QTD', 'YTD'],
- 'allowed_sort_parameters' => [
+ 'allowed_sort_parameters' => [
'Account' => ['id', 'order', 'name', 'iban', 'active', 'account_type_id',
- 'current_balance',
- 'pc_current_balance',
- 'opening_balance',
- 'pc_opening_balance',
- 'virtual_balance',
- 'pc_virtual_balance',
- 'debt_amount',
- 'pc_debt_amount',
- 'balance_difference',
- 'pc_balance_difference',
+ 'current_balance',
+ 'pc_current_balance',
+ 'opening_balance',
+ 'pc_opening_balance',
+ 'virtual_balance',
+ 'pc_virtual_balance',
+ 'debt_amount',
+ 'pc_debt_amount',
+ 'balance_difference',
+ 'pc_balance_difference',
],
],
- 'allowed_db_sort_parameters' => [
+ 'allowed_db_sort_parameters' => [
'Account' => ['id', 'order', 'name', 'iban', 'active', 'account_type_id'],
],
// preselected account lists possibilities:
- 'preselected_accounts' => ['all', 'assets', 'liabilities'],
+ 'preselected_accounts' => ['all', 'assets', 'liabilities'],
// allowed to store a piggy bank in:
- 'piggy_bank_account_types' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
+ 'piggy_bank_account_types' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
];
diff --git a/public/v1/js/ff/charts.defaults.js b/public/v1/js/ff/charts.defaults.js
index 4bb308ee26..4bd57b5445 100644
--- a/public/v1/js/ff/charts.defaults.js
+++ b/public/v1/js/ff/charts.defaults.js
@@ -42,13 +42,11 @@ function formatLabel(str, maxwidth) {
if (concat.length > maxwidth) {
sections.push(temp);
temp = "";
- }
- else {
+ } else {
if (index === (words.length - 1)) {
sections.push(concat);
return;
- }
- else {
+ } else {
temp = concat;
return;
}
@@ -62,8 +60,7 @@ function formatLabel(str, maxwidth) {
if (item.length < maxwidth) {
temp = item;
- }
- else {
+ } else {
sections.push(item);
}
@@ -98,9 +95,11 @@ var defaultChartOptions = {
ticks: {
callback: function (tickValue) {
"use strict";
+ if (anonymous) {
+ return accounting.formatMoney(0);
+ }
// use first symbol or null:
return accounting.formatMoney(tickValue);
-
},
beginAtZero: true
}
@@ -112,8 +111,11 @@ var defaultChartOptions = {
callbacks: {
label: function (tooltipItem, data) {
"use strict";
- return data.datasets[tooltipItem.datasetIndex].label + ': ' +
- accounting.formatMoney(tooltipItem.yLabel, data.datasets[tooltipItem.datasetIndex].currency_symbol);
+ var string = accounting.formatMoney(tooltipItem.yLabel, data.datasets[tooltipItem.datasetIndex].currency_symbol);
+ if (anonymous) {
+ string = accounting.formatMoney(0);
+ }
+ return data.datasets[tooltipItem.datasetIndex].label + ': ' + string;
}
}
}
@@ -125,7 +127,11 @@ var pieOptionsWithCurrency = {
label: function (tooltipItem, data) {
"use strict";
var value = data.datasets[0].data[tooltipItem.index];
- return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value, data.datasets[tooltipItem.datasetIndex].currency_symbol[tooltipItem.index]);
+ var string = accounting.formatMoney(value, data.datasets[tooltipItem.datasetIndex].currency_symbol[tooltipItem.index]);
+ if (anonymous) {
+ string = accounting.formatMoney(0);
+ }
+ return data.labels[tooltipItem.index] + ': ' + string;
}
}
},
@@ -139,7 +145,11 @@ var defaultPieOptions = {
label: function (tooltipItem, data) {
"use strict";
var value = data.datasets[0].data[tooltipItem.index];
- return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value);
+ var string = accounting.formatMoney(value);
+ if (anonymous) {
+ string = accounting.formatMoney(0);
+ }
+ return data.labels[tooltipItem.index] + ': ' + string;
}
}
},
@@ -153,7 +163,11 @@ var neutralDefaultPieOptions = {
label: function (tooltipItem, data) {
"use strict";
var value = data.datasets[0].data[tooltipItem.index];
- return data.labels[tooltipItem.index] + ': ' + accounting.formatMoney(value, '¤');
+ var string = accounting.formatMoney(value, '¤');
+ if(anonymous) {
+ string = accounting.formatMoney(0);
+ }
+ return data.labels[tooltipItem.index] + ': ' + string;
}
}
},
diff --git a/public/v1/js/ff/firefly.js b/public/v1/js/ff/firefly.js
index 442fd820d1..846971fb5b 100644
--- a/public/v1/js/ff/firefly.js
+++ b/public/v1/js/ff/firefly.js
@@ -47,7 +47,6 @@ function parseToLocalDates() {
$(function () {
"use strict";
-
configAccounting(currencySymbol);
// on submit of logout button:
diff --git a/public/v1/js/ff/help.js b/public/v1/js/ff/help.js
index 36998bbfea..30c0f76c0f 100644
--- a/public/v1/js/ff/help.js
+++ b/public/v1/js/ff/help.js
@@ -17,13 +17,42 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see