mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-08-16 10:54:39 +00:00
Compare commits
287 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
265d973811 | ||
|
e22ed9a69b | ||
|
fcecd5c85e | ||
|
2780cf4b20 | ||
|
7e63700ca2 | ||
|
2d9a3f5fc6 | ||
|
f5bbd445d2 | ||
|
12008fb0e9 | ||
|
5f6c84ab4c | ||
|
63184ac298 | ||
|
5f6772260d | ||
|
22a237d316 | ||
|
c47980a737 | ||
|
e43372b2ce | ||
|
395b6ecb76 | ||
|
328a1e256e | ||
|
4a31f9ce7e | ||
|
345f4903a9 | ||
|
3fe5e5ea8c | ||
|
b0da22ddf2 | ||
|
388ee14dfc | ||
|
2c53c72024 | ||
|
de260adca4 | ||
|
d8813120a7 | ||
|
989fd1adba | ||
|
a5f4793e81 | ||
|
86243131cd | ||
|
344cbe4fb7 | ||
|
44af5473a8 | ||
|
f33f9c797b | ||
|
352eedb136 | ||
|
c8d6ef3782 | ||
|
922a5fa9c7 | ||
|
c125984d55 | ||
|
a60c3165f1 | ||
|
363c849c50 | ||
|
36c9782c8f | ||
|
49847a91e3 | ||
|
516653d007 | ||
|
2743359a4e | ||
|
8055e9e927 | ||
|
702f2c3146 | ||
|
ad36082fca | ||
|
81e650986d | ||
|
f3c89e8055 | ||
|
3a8c0074b7 | ||
|
dcfcbfd9b5 | ||
|
04c71a2e9e | ||
|
2383d16e7a | ||
|
5bb7705702 | ||
|
2e3267ab9e | ||
|
d969cd72c0 | ||
|
e4894c756a | ||
|
f52044e794 | ||
|
43960a5b60 | ||
|
81b0b048db | ||
|
3278d9850e | ||
|
b13bcec61a | ||
|
21d18acabc | ||
|
4060d14de0 | ||
|
c67a71e238 | ||
|
ed330e30d0 | ||
|
7673d11673 | ||
|
e1114f720d | ||
|
b49e7d6b21 | ||
|
c9ba5f08c4 | ||
|
5aa8793e33 | ||
|
dd98549bce | ||
|
d6d53cc598 | ||
|
6516495e2b | ||
|
7fcdf85dee | ||
|
704c6055b3 | ||
|
f650dd9463 | ||
|
1b261359e6 | ||
|
8050c8cb84 | ||
|
7666960a86 | ||
|
0a7210729f | ||
|
90c9fdaf55 | ||
|
d55833cb86 | ||
|
39fbf3ce20 | ||
|
15994c8c56 | ||
|
b942f351f8 | ||
|
e05c174e6d | ||
|
05d461fb88 | ||
|
7bb2f96ae2 | ||
|
8f15bd716d | ||
|
0c6e00666b | ||
|
5ba079e71c | ||
|
b36f6741ff | ||
|
d7bbc8334e | ||
|
2b7101e362 | ||
|
e74b629dc2 | ||
|
a4f329cfc3 | ||
|
e993abc8fb | ||
|
6961365a40 | ||
|
16303515f5 | ||
|
bb5bca9cf0 | ||
|
e8a61821e9 | ||
|
5d4cf5f55e | ||
|
5e9de60c1a | ||
|
417700ef13 | ||
|
b14062b197 | ||
|
a3b4d5ff62 | ||
|
6b7fc03f02 | ||
|
b60a3be34b | ||
|
83b8fdba05 | ||
|
0b64507fd7 | ||
|
45dcd5df09 | ||
|
3bdea43744 | ||
|
b3895a04a0 | ||
|
d4738b21ab | ||
|
2f66315416 | ||
|
abdb717b37 | ||
|
f7b66a048a | ||
|
a91f6fbfaf | ||
|
f3566c609a | ||
|
904320b9b8 | ||
|
35c1ce6504 | ||
|
ddefdd5ec5 | ||
|
fd37054493 | ||
|
bf589e5c57 | ||
|
e97018cf2e | ||
|
5038ed7708 | ||
|
02081b09a2 | ||
|
a74d345ac2 | ||
|
69929bee31 | ||
|
b276b24a79 | ||
|
1b99dbab0a | ||
|
1ea0fa318c | ||
|
4066fc643f | ||
|
b7975c6a88 | ||
|
1e88b1eb88 | ||
|
88490de38f | ||
|
030b6cb281 | ||
|
896c15a7a1 | ||
|
b176308dbd | ||
|
553a9be3d5 | ||
|
187e1914e3 | ||
|
fc83565d02 | ||
|
bab4c05e5f | ||
|
5b43a2e99f | ||
|
c9f7e96450 | ||
|
ea361365f0 | ||
|
5dfb35064a | ||
|
5522e4f514 | ||
|
c1367d12a6 | ||
|
321c8fca67 | ||
|
73b98612a5 | ||
|
671e93c50f | ||
|
553c3ec17e | ||
|
94b933c7a4 | ||
|
0338010eaa | ||
|
ff91fe432c | ||
|
c4e46bf89b | ||
|
5c471059f3 | ||
|
93c83fbe7a | ||
|
4474a71e65 | ||
|
1558e87923 | ||
|
c6bc308ce7 | ||
|
c49f3fcccf | ||
|
d144392bd6 | ||
|
0671f20ab1 | ||
|
4bdc5fa3fc | ||
|
ddff192a1f | ||
|
ff55b36f32 | ||
|
8e4c772dcd | ||
|
fd7683c212 | ||
|
6f9482fc1b | ||
|
af6e70c41c | ||
|
7116c65bd7 | ||
|
9e98c52c64 | ||
|
c5e0c492a7 | ||
|
f43c74df66 | ||
|
40dbae17b1 | ||
|
3ca88adade | ||
|
c8be9ceaf5 | ||
|
52df1aad14 | ||
|
6bc73f4f55 | ||
|
4ade02efc8 | ||
|
eef14ced59 | ||
|
11ba24482f | ||
|
e5bc074e68 | ||
|
93ea86f921 | ||
|
cf8957a460 | ||
|
9c2f771bae | ||
|
d9e8f8106a | ||
|
6589f88883 | ||
|
38ebdd8249 | ||
|
6296ead897 | ||
|
ecf5cc62f9 | ||
|
b205cc87fc | ||
|
4c60473f02 | ||
|
f47464944b | ||
|
edb9480c90 | ||
|
615e789134 | ||
|
3e96bb526c | ||
|
1d21a8788c | ||
|
e420ead9e8 | ||
|
06b7f18d55 | ||
|
8659c7efbd | ||
|
80fe52f5d7 | ||
|
77358301e8 | ||
|
93ed1de23f | ||
|
a81ca5114b | ||
|
9a69b941d8 | ||
|
194ecc7ac7 | ||
|
44da3be910 | ||
|
22de6e61ff | ||
|
37f91cabf5 | ||
|
7f9d87a117 | ||
|
52e83c2ec2 | ||
|
70c08d6b50 | ||
|
0b49e9b8a8 | ||
|
73d97d90ae | ||
|
43650583fe | ||
|
3cc0e0f20f | ||
|
27d6e70469 | ||
|
ab4ee2fdb0 | ||
|
23a09825cb | ||
|
ce1e99be9a | ||
|
63440c4cb7 | ||
|
e5b30fa156 | ||
|
8c067019f7 | ||
|
bb3ceaeb0e | ||
|
b6e8144fe9 | ||
|
059df6f8ac | ||
|
6ae43aee5c | ||
|
3ea48eb6ee | ||
|
76885d2c50 | ||
|
a1f7a518e3 | ||
|
55205d6107 | ||
|
c7ce5632ea | ||
|
91cec7485a | ||
|
37fbc657a7 | ||
|
908dc15a3b | ||
|
d4bd7c0549 | ||
|
4c0d6a5259 | ||
|
48c8c5b353 | ||
|
d502c8d286 | ||
|
79c4fad922 | ||
|
b1532ab982 | ||
|
08e65887ca | ||
|
4c0934bae8 | ||
|
1670fe5e4d | ||
|
bba362fb58 | ||
|
4aa361617f | ||
|
be01b177fa | ||
|
aa3fba91d4 | ||
|
cc6a7b181a | ||
|
c460ccfad5 | ||
|
69d875d981 | ||
|
75ea1c4f4b | ||
|
cfbda09e36 | ||
|
7746f2ca19 | ||
|
a8fb463520 | ||
|
3ef732b895 | ||
|
1101af87cb | ||
|
c9e0043cc1 | ||
|
edb8bb3ce3 | ||
|
ac0f75c808 | ||
|
b39e16c51c | ||
|
23d3abbf63 | ||
|
34e5433082 | ||
|
9fbc4c2ba1 | ||
|
38ed7c1543 | ||
|
121561da3e | ||
|
5893b30da8 | ||
|
858480929c | ||
|
242fb3b498 | ||
|
47469c7082 | ||
|
18f2633810 | ||
|
c50a4ae993 | ||
|
2db32ce44f | ||
|
38b505d036 | ||
|
b03a36b87f | ||
|
fa72912349 | ||
|
7e98fac3b7 | ||
|
f14c8a2ec2 | ||
|
7c63f097c8 | ||
|
037cd75658 | ||
|
76dadd1cab | ||
|
d8506c4361 | ||
|
d49809c939 | ||
|
e8ec13ca5f | ||
|
7f694ede98 | ||
|
203ae2812f | ||
|
397c0abebe |
@@ -1,5 +1,6 @@
|
||||
bg_BG
|
||||
cs_CZ
|
||||
da_DK
|
||||
de_DE
|
||||
el_GR
|
||||
en_GB
|
||||
@@ -8,7 +9,9 @@ es_ES
|
||||
fi_FI
|
||||
fr_FR
|
||||
hu_HU
|
||||
id_ID
|
||||
it_IT
|
||||
ja_JP
|
||||
nb_NO
|
||||
nl_NL
|
||||
pl_PL
|
||||
@@ -17,7 +20,10 @@ pt_PT
|
||||
ro_RO
|
||||
ru_RU
|
||||
sk_SK
|
||||
sl_SI
|
||||
sv_SE
|
||||
tr_TR
|
||||
uk_UA
|
||||
vi_VN
|
||||
zh-hans_CN
|
||||
zh-hant_CN
|
||||
|
19
.env.example
19
.env.example
@@ -12,6 +12,9 @@ SITE_OWNER=mail@example.com
|
||||
# The encryption key for your sessions. Keep this very secure.
|
||||
# Change it to a string of exactly 32 chars or use something like `php artisan key:generate` to generate it.
|
||||
# If you use Docker or similar, you can set this variable from a file by using APP_KEY_FILE
|
||||
#
|
||||
# Avoid the "#" character in your APP_KEY, it may break things.
|
||||
#
|
||||
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||
|
||||
# Firefly III will launch using this language (for new users and unauthenticated visitors)
|
||||
@@ -111,7 +114,10 @@ REDIS_PATH=
|
||||
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=null
|
||||
|
||||
# Use only with Redis 6+ with proper ACL set. Leave empty otherwise.
|
||||
REDIS_USERNAME=
|
||||
REDIS_PASSWORD=
|
||||
|
||||
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
|
||||
REDIS_DB="0"
|
||||
@@ -189,6 +195,15 @@ AUTHENTICATION_GUARD=web
|
||||
AUTHENTICATION_GUARD_HEADER=REMOTE_USER
|
||||
AUTHENTICATION_GUARD_EMAIL=
|
||||
|
||||
#
|
||||
# Firefly III generates a basic keypair for your OAuth tokens.
|
||||
# If you want, you can overrule the key with your own (secure) value.
|
||||
# It's also possible to set PASSPORT_PUBLIC_KEY_FILE or PASSPORT_PRIVATE_KEY_FILE
|
||||
# if you're using Docker secrets or similar solutions for secret management
|
||||
#
|
||||
PASSPORT_PRIVATE_KEY=
|
||||
PASSPORT_PUBLIC_KEY=
|
||||
|
||||
#
|
||||
# Extra authentication settings
|
||||
#
|
||||
@@ -230,7 +245,7 @@ ALLOW_WEBHOOKS=false
|
||||
STATIC_CRON_TOKEN=
|
||||
|
||||
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
|
||||
# Use this at your own risk. Disabling certain checks and features may result in lots of inconsistent data.
|
||||
# However if you know what you're doing you can significantly speed up container start times.
|
||||
# Set each value to true to enable, or false to disable.
|
||||
|
||||
|
2
.github/security.md
vendored
2
.github/security.md
vendored
@@ -40,7 +40,7 @@ The Firefly III developer will respond to vulnerability reports as follows:
|
||||
9. Once the fix is confirmed, the developer will patch the vulnerability in the next patch or minor release. Upon release of the patched version of Firefly III, we will follow the **Public Disclosure Process**.
|
||||
|
||||
### Public Disclosure Process
|
||||
The developer publishes a public [advisory](https://github.com/firefly-iii/firefly-iii/security/advisories) to the Firefly III community via GitHub. In most cases, additional communication via Twitter, reddit and other channels will assist in educating Firefly III users and rolling out the patched release to affected users.
|
||||
The developer publishes a public [advisory](https://github.com/firefly-iii/firefly-iii/security/advisories) to the Firefly III community via GitHub. In most cases, additional communication via Mastodon, Gitter and other channels will assist in educating Firefly III users and rolling out the patched release to affected users.
|
||||
|
||||
The develop will also publish any mitigating steps users can take until the fix can be applied to their Firefly III instances.
|
||||
|
||||
|
1
.github/stale.yml
vendored
1
.github/stale.yml
vendored
@@ -14,6 +14,7 @@ exemptLabels:
|
||||
- feature
|
||||
- bug
|
||||
- announcement
|
||||
- "layout-v3"
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
22
.github/workflows/closed-issues.yml
vendored
Normal file
22
.github/workflows/closed-issues.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: "Reply to closed issue"
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- closed
|
||||
jobs:
|
||||
auto_comment:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
uses: aws-actions/closed-issue-message@v1
|
||||
with:
|
||||
message: |
|
||||
Hi there! This is an automatic reply. `Share and enjoy`
|
||||
|
||||
This issue is now closed. Please be aware that closed issues are not actively monitored. If you reply, you may get no response.
|
||||
|
||||
- If the original bug is not actually fixed, please feel free to open a new ticket. Please refer to this issue for clarity.
|
||||
- Follow-up questions can also be posted in a new [discussion](https://github.com/firefly-iii/firefly-iii/discussions/)
|
||||
|
||||
Thank you for your consideration.
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
5
.github/workflows/stale.yml
vendored
5
.github/workflows/stale.yml
vendored
@@ -2,6 +2,7 @@ name: "Close stale issues"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -13,7 +14,7 @@ jobs:
|
||||
pull-requests: write # for actions/stale to close stale PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
- uses: actions/stale@v6
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: >
|
||||
@@ -26,4 +27,4 @@ jobs:
|
||||
for your contributions.
|
||||
days-before-stale: 14
|
||||
days-before-close: 7
|
||||
exempt-issue-labels: 'enhancement,feature,bug,announcement'
|
||||
exempt-issue-labels: 'enhancement,feature,bug,announcement,layout-v3'
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
/.ci/php-cs-fixer/vendor
|
||||
|
@@ -127,11 +127,11 @@ class AccountController extends Controller
|
||||
];
|
||||
$currentStart = clone $start;
|
||||
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
||||
$previous = round((float) array_values($range)[0], 12);
|
||||
$previous = $range[0] ?? '0';
|
||||
while ($currentStart <= $end) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = $currentStart->toAtomString();
|
||||
$balance = array_key_exists($format, $range) ? round((float) $range[$format], 12) : $previous;
|
||||
$balance = array_key_exists($format, $range) ? $range[$format] : $previous;
|
||||
$previous = $balance;
|
||||
$currentStart->addDay();
|
||||
$currentSet['entries'][$label] = $balance;
|
||||
|
@@ -162,6 +162,7 @@ class DestroyController extends Controller
|
||||
);
|
||||
break;
|
||||
}
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ class AccountController extends Controller
|
||||
'id' => (string) $expense['id'],
|
||||
'name' => $expense['name'],
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
@@ -126,7 +126,7 @@ class AccountController extends Controller
|
||||
'id' => (string) $expense['id'],
|
||||
'name' => $expense['name'],
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
|
@@ -101,7 +101,7 @@ class BillController extends Controller
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignKey] = $response[$foreignKey] ?? [
|
||||
@@ -111,7 +111,7 @@ class BillController extends Controller
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class BillController extends Controller
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||
@@ -164,7 +164,7 @@ class BillController extends Controller
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,7 @@ class BudgetController extends Controller
|
||||
'id' => (string) $budget->id,
|
||||
'name' => $budget->name,
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
@@ -120,7 +120,7 @@ class BudgetController extends Controller
|
||||
foreach ($expenses as $expense) {
|
||||
$result[] = [
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
|
@@ -92,7 +92,7 @@ class CategoryController extends Controller
|
||||
'id' => (string) $category->id,
|
||||
'name' => $category->name,
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
@@ -121,7 +121,7 @@ class CategoryController extends Controller
|
||||
foreach ($expenses as $expense) {
|
||||
$result[] = [
|
||||
'difference' => $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'],
|
||||
'difference_float' => (float) $expense['sum'], // intentional float
|
||||
'currency_id' => (string) $expense['currency_id'],
|
||||
'currency_code' => $expense['currency_code'],
|
||||
];
|
||||
|
@@ -66,7 +66,7 @@ class PeriodController extends Controller
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||
@@ -76,7 +76,7 @@ class PeriodController extends Controller
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -171,7 +171,7 @@ class TagController extends Controller
|
||||
$response[$foreignKey]['difference'] = bcadd(
|
||||
$response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Account $account): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($account, null);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -73,6 +73,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Attachment $attachment): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($attachment);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@ class DestroyController extends Controller
|
||||
public function destroy(AvailableBudget $availableBudget): JsonResponse
|
||||
{
|
||||
$this->abRepository->destroyAvailableBudget($availableBudget);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Bill $bill): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($bill);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Budget $budget): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($budget);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -77,6 +77,7 @@ class DestroyController extends Controller
|
||||
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||
}
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Category $category): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($category);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@ class DestroyController extends Controller
|
||||
public function destroy(ObjectGroup $objectGroup): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($objectGroup);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($piggyBank);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Recurrence $recurrence): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($recurrence);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Rule $rule): JsonResponse
|
||||
{
|
||||
$this->ruleRepository->destroy($rule);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@ class DestroyController extends Controller
|
||||
public function destroy(RuleGroup $ruleGroup): JsonResponse
|
||||
{
|
||||
$this->ruleGroupRepository->destroy($ruleGroup, null);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Tag $tag): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($tag);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -25,11 +25,16 @@ namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Events\DestroyedTransactionGroup;
|
||||
use FireflyIII\Events\UpdatedAccount;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DestroyController
|
||||
@@ -37,6 +42,7 @@ use Illuminate\Http\JsonResponse;
|
||||
class DestroyController extends Controller
|
||||
{
|
||||
private JournalRepositoryInterface $repository;
|
||||
private TransactionGroupRepository $groupRepository;
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
@@ -54,6 +60,9 @@ class DestroyController extends Controller
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
$this->repository->setUser($admin);
|
||||
|
||||
$this->groupRepository = app(TransactionGroupRepository::class);
|
||||
$this->groupRepository->setUser($admin);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
@@ -72,11 +81,30 @@ class DestroyController extends Controller
|
||||
*/
|
||||
public function destroy(TransactionGroup $transactionGroup): JsonResponse
|
||||
{
|
||||
$this->repository->destroyGroup($transactionGroup);
|
||||
// trigger just after destruction
|
||||
event(new DestroyedTransactionGroup($transactionGroup));
|
||||
// grab asset account(s) from group:
|
||||
$accounts = [];
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach($transactionGroup->transactionJournals as $journal) {
|
||||
/** @var Transaction $transaction */
|
||||
foreach($journal->transactions as $transaction) {
|
||||
$type = $transaction->account->accountType->type;
|
||||
// if is valid liability, trigger event!
|
||||
if(in_array($type, config('firefly.valid_liabilities'))) {
|
||||
$accounts[] = $transaction->account;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->groupRepository->destroy($transactionGroup);
|
||||
|
||||
app('preferences')->mark();
|
||||
|
||||
/** @var Account $account */
|
||||
foreach($accounts as $account) {
|
||||
Log::debug(sprintf('Now going to trigger updated account event for account #%d', $account->id));
|
||||
event(new UpdatedAccount($account));
|
||||
}
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
@@ -94,6 +122,7 @@ class DestroyController extends Controller
|
||||
public function destroyJournal(TransactionJournal $transactionJournal): JsonResponse
|
||||
{
|
||||
$this->repository->destroyJournal($transactionJournal);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -88,6 +88,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->destroy($currency);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@ class DestroyController extends Controller
|
||||
public function destroy(TransactionJournalLink $link): JsonResponse
|
||||
{
|
||||
$this->repository->destroyLink($link);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -82,6 +82,7 @@ class DestroyController extends Controller
|
||||
throw new FireflyException('200020: Link type cannot be changed.');
|
||||
}
|
||||
$this->repository->destroy($linkType);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -188,7 +188,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('balance-in-%s', $currency->code),
|
||||
'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),
|
||||
'monetary_value' => round((float) $sums[$currencyId] ?? 0, $currency->decimal_places),
|
||||
'monetary_value' => $sums[$currencyId] ?? '0',
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -201,7 +201,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('spent-in-%s', $currency->code),
|
||||
'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),
|
||||
'monetary_value' => round((float) ($expenses[$currencyId] ?? 0), $currency->decimal_places),
|
||||
'monetary_value' => $expenses[$currencyId] ?? '0',
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -213,7 +213,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('earned-in-%s', $currency->code),
|
||||
'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),
|
||||
'monetary_value' => round((float) ($incomes[$currencyId] ?? 0), $currency->decimal_places),
|
||||
'monetary_value' => $incomes[$currencyId] ?? '0',
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -251,7 +251,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-paid-in-%s', $currency->code),
|
||||
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]),
|
||||
'monetary_value' => round((float) $amount, $currency->decimal_places),
|
||||
'monetary_value' => $amount,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -271,7 +271,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('bills-unpaid-in-%s', $currency->code),
|
||||
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $currency->symbol]),
|
||||
'monetary_value' => round((float) $amount, $currency->decimal_places),
|
||||
'monetary_value' => $amount,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -315,7 +315,7 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => sprintf('left-to-spend-in-%s', $row['currency_code']),
|
||||
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),
|
||||
'monetary_value' => round((float) $leftToSpend, $row['currency_decimal_places']),
|
||||
'monetary_value' => $leftToSpend,
|
||||
'currency_id' => $row['currency_id'],
|
||||
'currency_code' => $row['currency_code'],
|
||||
'currency_symbol' => $row['currency_symbol'],
|
||||
@@ -373,8 +373,8 @@ class BasicController extends Controller
|
||||
foreach ($netWorthSet as $data) {
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = $data['currency'];
|
||||
$amount = round((float) $data['balance'], $currency->decimal_places);
|
||||
if (0.0 === $amount) {
|
||||
$amount = $data['balance'];
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
continue;
|
||||
}
|
||||
// return stuff
|
||||
|
@@ -69,6 +69,7 @@ class DestroyController extends Controller
|
||||
public function destroy(Webhook $webhook): JsonResponse
|
||||
{
|
||||
$this->repository->destroy($webhook);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
@@ -98,6 +99,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->destroyAttempt($attempt);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
@@ -121,6 +123,7 @@ class DestroyController extends Controller
|
||||
throw new FireflyException('Webhook and webhook message are no match');
|
||||
}
|
||||
$this->repository->destroyMessage($message);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ class AutocompleteRequest extends FormRequest
|
||||
if ('' !== $types) {
|
||||
$array = explode(',', $types);
|
||||
}
|
||||
$limit = $this->integer('limit');
|
||||
$limit = $this->convertInteger('limit');
|
||||
$limit = 0 === $limit ? 10 : $limit;
|
||||
|
||||
// remove 'initial balance' from allowed types. its internal
|
||||
|
@@ -43,8 +43,8 @@ class MoveTransactionsRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
return [
|
||||
'original_account' => $this->integer('original_account'),
|
||||
'destination_account' => $this->integer('destination_account'),
|
||||
'original_account' => $this->convertInteger('original_account'),
|
||||
'destination_account' => $this->convertInteger('destination_account'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -61,8 +61,8 @@ class StoreRequest extends FormRequest
|
||||
'include_net_worth' => $includeNetWorth,
|
||||
'account_type_name' => $this->convertString('type'),
|
||||
'account_type_id' => null,
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
'order' => $this->integer('order'),
|
||||
'currency_id' => $this->convertInteger('currency_id'),
|
||||
'order' => $this->convertInteger('order'),
|
||||
'currency_code' => $this->convertString('currency_code'),
|
||||
'virtual_balance' => $this->convertString('virtual_balance'),
|
||||
'iban' => $this->convertString('iban'),
|
||||
|
@@ -67,8 +67,8 @@ class UpdateRequest extends FormRequest
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'interest' => ['interest', 'convertString'],
|
||||
'interest_period' => ['interest_period', 'convertString'],
|
||||
'order' => ['order', 'integer'],
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'currency_id' => ['currency_id', 'convertInteger'],
|
||||
'currency_code' => ['currency_code', 'convertString'],
|
||||
'liability_direction' => ['liability_direction', 'convertString'],
|
||||
'liability_amount' => ['liability_amount', 'convertString'],
|
||||
|
@@ -49,7 +49,7 @@ class StoreRequest extends FormRequest
|
||||
'title' => $this->convertString('title'),
|
||||
'notes' => $this->stringWithNewlines('notes'),
|
||||
'attachable_type' => $this->convertString('attachable_type'),
|
||||
'attachable_id' => $this->integer('attachable_id'),
|
||||
'attachable_id' => $this->convertInteger('attachable_id'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ class UpdateRequest extends FormRequest
|
||||
'title' => ['title', 'convertString'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'attachable_type' => ['attachable_type', 'convertString'],
|
||||
'attachable_id' => ['attachable_id', 'integer'],
|
||||
'attachable_id' => ['attachable_id', 'convertInteger'],
|
||||
];
|
||||
|
||||
return $this->getAllData($fields);
|
||||
|
@@ -47,7 +47,7 @@ class Request extends FormRequest
|
||||
{
|
||||
// this is the way:
|
||||
$fields = [
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'currency_id' => ['currency_id', 'convertInteger'],
|
||||
'currency_code' => ['currency_code', 'convertString'],
|
||||
'amount' => ['amount', 'convertString'],
|
||||
'start' => ['start', 'date'],
|
||||
|
@@ -52,17 +52,17 @@ class StoreRequest extends FormRequest
|
||||
'name' => ['name', 'convertString'],
|
||||
'amount_min' => ['amount_min', 'convertString'],
|
||||
'amount_max' => ['amount_max', 'convertString'],
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'currency_id' => ['currency_id', 'convertInteger'],
|
||||
'currency_code' => ['currency_code', 'convertString'],
|
||||
'date' => ['date', 'date'],
|
||||
'end_date' => ['end_date', 'date'],
|
||||
'extension_date' => ['extension_date', 'date'],
|
||||
'repeat_freq' => ['repeat_freq', 'convertString'],
|
||||
'skip' => ['skip', 'integer'],
|
||||
'skip' => ['skip', 'convertInteger'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'object_group_id' => ['object_group_id', 'integer'],
|
||||
'object_group_id' => ['object_group_id', 'convertInteger'],
|
||||
'object_group_title' => ['object_group_title', 'convertString'],
|
||||
];
|
||||
|
||||
@@ -104,9 +104,10 @@ class StoreRequest extends FormRequest
|
||||
$validator->after(
|
||||
static function (Validator $validator) {
|
||||
$data = $validator->getData();
|
||||
$min = (float) ($data['amount_min'] ?? 0);
|
||||
$max = (float) ($data['amount_max'] ?? 0);
|
||||
if ($min > $max) {
|
||||
$min = $data['amount_min'] ?? '0';
|
||||
$max = $data['amount_max'] ?? '0';
|
||||
|
||||
if (1 === bccomp($min, $max)) {
|
||||
$validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));
|
||||
}
|
||||
}
|
||||
|
@@ -50,17 +50,17 @@ class UpdateRequest extends FormRequest
|
||||
'name' => ['name', 'convertString'],
|
||||
'amount_min' => ['amount_min', 'convertString'],
|
||||
'amount_max' => ['amount_max', 'convertString'],
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'currency_id' => ['currency_id', 'convertInteger'],
|
||||
'currency_code' => ['currency_code', 'convertString'],
|
||||
'date' => ['date', 'date'],
|
||||
'end_date' => ['end_date', 'date'],
|
||||
'extension_date' => ['extension_date', 'date'],
|
||||
'repeat_freq' => ['repeat_freq', 'convertString'],
|
||||
'skip' => ['skip', 'integer'],
|
||||
'skip' => ['skip', 'convertInteger'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'object_group_id' => ['object_group_id', 'integer'],
|
||||
'object_group_id' => ['object_group_id', 'convertInteger'],
|
||||
'object_group_title' => ['object_group_title', 'convertString'],
|
||||
];
|
||||
|
||||
@@ -105,9 +105,10 @@ class UpdateRequest extends FormRequest
|
||||
static function (Validator $validator) {
|
||||
$data = $validator->getData();
|
||||
if (array_key_exists('amount_min', $data) && array_key_exists('amount_max', $data)) {
|
||||
$min = (float) ($data['amount_min'] ?? 0);
|
||||
$max = (float) ($data['amount_max'] ?? 0);
|
||||
if ($min > $max) {
|
||||
$min = $data['amount_min'] ?? '0';
|
||||
$max = $data['amount_max'] ?? '0';
|
||||
|
||||
if (1 === bccomp($min, $max)) {
|
||||
$validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));
|
||||
}
|
||||
}
|
||||
|
@@ -49,11 +49,11 @@ class StoreRequest extends FormRequest
|
||||
$fields = [
|
||||
'name' => ['name', 'convertString'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['active', 'integer'],
|
||||
'order' => ['active', 'convertInteger'],
|
||||
'notes' => ['notes', 'convertString'],
|
||||
|
||||
// auto budget currency:
|
||||
'currency_id' => ['auto_budget_currency_id', 'integer'],
|
||||
'currency_id' => ['auto_budget_currency_id', 'convertInteger'],
|
||||
'currency_code' => ['auto_budget_currency_code', 'convertString'],
|
||||
'auto_budget_type' => ['auto_budget_type', 'convertString'],
|
||||
'auto_budget_amount' => ['auto_budget_amount', 'convertString'],
|
||||
|
@@ -50,9 +50,9 @@ class UpdateRequest extends FormRequest
|
||||
$fields = [
|
||||
'name' => ['name', 'convertString'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'notes' => ['notes', 'convertString'],
|
||||
'currency_id' => ['auto_budget_currency_id', 'integer'],
|
||||
'currency_id' => ['auto_budget_currency_id', 'convertInteger'],
|
||||
'currency_code' => ['auto_budget_currency_code', 'convertString'],
|
||||
'auto_budget_type' => ['auto_budget_type', 'convertString'],
|
||||
'auto_budget_amount' => ['auto_budget_amount', 'convertString'],
|
||||
|
@@ -47,7 +47,7 @@ class StoreRequest extends FormRequest
|
||||
'start' => $this->getCarbonDate('start'),
|
||||
'end' => $this->getCarbonDate('end'),
|
||||
'amount' => $this->convertString('amount'),
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
'currency_id' => $this->convertInteger('currency_id'),
|
||||
'currency_code' => $this->convertString('currency_code'),
|
||||
];
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class UpdateRequest extends FormRequest
|
||||
'start' => ['start', 'date'],
|
||||
'end' => ['end', 'date'],
|
||||
'amount' => ['amount', 'convertString'],
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'currency_id' => ['currency_id', 'convertInteger'],
|
||||
'currency_code' => ['currency_code', 'convertString'],
|
||||
];
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
$fields = [
|
||||
'title' => ['title', 'convertString'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
];
|
||||
|
||||
return $this->getAllData($fields);
|
||||
|
@@ -44,17 +44,17 @@ class StoreRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
$fields = [
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
];
|
||||
$data = $this->getAllData($fields);
|
||||
$data['name'] = $this->convertString('name');
|
||||
$data['account_id'] = $this->integer('account_id');
|
||||
$data['account_id'] = $this->convertInteger('account_id');
|
||||
$data['targetamount'] = $this->convertString('target_amount');
|
||||
$data['current_amount'] = $this->convertString('current_amount');
|
||||
$data['startdate'] = $this->getCarbonDate('start_date');
|
||||
$data['targetdate'] = $this->getCarbonDate('target_date');
|
||||
$data['notes'] = $this->stringWithNewlines('notes');
|
||||
$data['object_group_id'] = $this->integer('object_group_id');
|
||||
$data['object_group_id'] = $this->convertInteger('object_group_id');
|
||||
$data['object_group_title'] = $this->convertString('object_group_title');
|
||||
|
||||
return $data;
|
||||
|
@@ -47,15 +47,15 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
$fields = [
|
||||
'name' => ['name', 'convertString'],
|
||||
'account_id' => ['account_id', 'integer'],
|
||||
'account_id' => ['account_id', 'convertInteger'],
|
||||
'targetamount' => ['target_amount', 'convertString'],
|
||||
'current_amount' => ['current_amount', 'convertString'],
|
||||
'startdate' => ['start_date', 'date'],
|
||||
'targetdate' => ['target_date', 'convertString'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'object_group_title' => ['object_group_title', 'convertString'],
|
||||
'object_group_id' => ['object_group_id', 'integer'],
|
||||
'object_group_id' => ['object_group_id', 'convertInteger'],
|
||||
];
|
||||
|
||||
return $this->getAllData($fields);
|
||||
|
@@ -54,7 +54,7 @@ class StoreRequest extends FormRequest
|
||||
'description' => ['description', 'convertString'],
|
||||
'first_date' => ['first_date', 'date'],
|
||||
'repeat_until' => ['repeat_until', 'date'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'integer'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||
'apply_rules' => ['apply_rules', 'boolean'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
|
@@ -55,7 +55,7 @@ class UpdateRequest extends FormRequest
|
||||
'description' => ['description', 'convertString'],
|
||||
'first_date' => ['first_date', 'date'],
|
||||
'repeat_until' => ['repeat_until', 'date'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'integer'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||
'apply_rules' => ['apply_rules', 'boolean'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'notes' => ['notes', 'convertString'],
|
||||
|
@@ -48,8 +48,8 @@ class StoreRequest extends FormRequest
|
||||
$fields = [
|
||||
'title' => ['title', 'convertString'],
|
||||
'description' => ['description', 'convertString'],
|
||||
'rule_group_id' => ['rule_group_id', 'integer'],
|
||||
'order' => ['order', 'integer'],
|
||||
'rule_group_id' => ['rule_group_id', 'convertInteger'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'rule_group_title' => ['rule_group_title', 'convertString'],
|
||||
'trigger' => ['trigger', 'convertString'],
|
||||
'strict' => ['strict', 'boolean'],
|
||||
|
@@ -84,7 +84,7 @@ class TestRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'start' => 'date',
|
||||
'end' => 'date|after:start',
|
||||
'end' => 'date|after_or_equal:start',
|
||||
'accounts' => '',
|
||||
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
|
||||
];
|
||||
|
@@ -73,7 +73,7 @@ class TriggerRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'start' => 'date',
|
||||
'end' => 'date|after:start',
|
||||
'end' => 'date|after_or_equal:start',
|
||||
'accounts' => '',
|
||||
'accounts.*' => 'exists:accounts,id|belongsToUser:accounts',
|
||||
];
|
||||
|
@@ -48,12 +48,12 @@ class UpdateRequest extends FormRequest
|
||||
$fields = [
|
||||
'title' => ['title', 'convertString'],
|
||||
'description' => ['description', 'stringWithNewlines'],
|
||||
'rule_group_id' => ['rule_group_id', 'integer'],
|
||||
'rule_group_id' => ['rule_group_id', 'convertInteger'],
|
||||
'trigger' => ['trigger', 'convertString'],
|
||||
'strict' => ['strict', 'boolean'],
|
||||
'stop_processing' => ['stop_processing', 'boolean'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
];
|
||||
|
||||
$return = $this->getAllData($fields);
|
||||
|
@@ -49,7 +49,7 @@ class StoreRequest extends FormRequest
|
||||
$active = $this->boolean('active');
|
||||
}
|
||||
if (null !== $this->get('order')) {
|
||||
$order = $this->integer('order');
|
||||
$order = $this->convertInteger('order');
|
||||
}
|
||||
|
||||
return [
|
||||
|
@@ -73,7 +73,7 @@ class TestRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'start' => 'date',
|
||||
'end' => 'date|after:start',
|
||||
'end' => 'date|after_or_equal:start',
|
||||
'accounts' => '',
|
||||
'accounts.*' => 'exists:accounts,id|belongsToUser:accounts',
|
||||
];
|
||||
|
@@ -73,7 +73,7 @@ class TriggerRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'start' => 'date',
|
||||
'end' => 'date|after:start',
|
||||
'end' => 'date|after_or_equal:start',
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ class UpdateRequest extends FormRequest
|
||||
'title' => ['title', 'convertString'],
|
||||
'description' => ['description', 'stringWithNewlines'],
|
||||
'active' => ['active', 'boolean'],
|
||||
'order' => ['order', 'integer'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
];
|
||||
|
||||
return $this->getAllData($fields);
|
||||
|
@@ -48,6 +48,7 @@ class UpdateRequest extends FormRequest
|
||||
private array $dateFields;
|
||||
private array $integerFields;
|
||||
private array $stringFields;
|
||||
private array $floatFields;
|
||||
private array $textareaFields;
|
||||
|
||||
/**
|
||||
@@ -84,12 +85,15 @@ class UpdateRequest extends FormRequest
|
||||
'notes',
|
||||
];
|
||||
|
||||
$this->convertStringFields = [
|
||||
$this->floatFields = [
|
||||
'amount',
|
||||
'foreign_amount',
|
||||
];
|
||||
|
||||
$this->stringFields = [
|
||||
'type',
|
||||
'currency_code',
|
||||
'foreign_currency_code',
|
||||
'amount',
|
||||
'foreign_amount',
|
||||
'description',
|
||||
'source_name',
|
||||
'source_iban',
|
||||
@@ -163,6 +167,7 @@ class UpdateRequest extends FormRequest
|
||||
$current = $this->getDateData($current, $transaction);
|
||||
$current = $this->getBooleanData($current, $transaction);
|
||||
$current = $this->getArrayData($current, $transaction);
|
||||
$current = $this->getFloatData($current, $transaction);
|
||||
$return[] = $current;
|
||||
}
|
||||
|
||||
@@ -196,7 +201,7 @@ class UpdateRequest extends FormRequest
|
||||
*/
|
||||
private function getStringData(array $current, array $transaction): array
|
||||
{
|
||||
foreach ($this->convertStringFields as $fieldName) {
|
||||
foreach ($this->stringFields as $fieldName) {
|
||||
if (array_key_exists($fieldName, $transaction)) {
|
||||
$current[$fieldName] = $this->clearString((string) $transaction[$fieldName], false);
|
||||
}
|
||||
@@ -389,4 +394,27 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $current
|
||||
* @param array $transaction
|
||||
* @return array
|
||||
*/
|
||||
private function getFloatData(array $current, array $transaction): array
|
||||
{
|
||||
foreach ($this->floatFields as $fieldName) {
|
||||
if (array_key_exists($fieldName, $transaction)) {
|
||||
$value = $transaction[$fieldName];
|
||||
if (is_float($value)) {
|
||||
// TODO this effectively limits the max number of decimals in currencies to 14.
|
||||
$current[$fieldName] = sprintf('%.14f', $value);
|
||||
}
|
||||
if (!is_float($value)) {
|
||||
$current[$fieldName] = (string) $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ class StoreRequest extends FormRequest
|
||||
'name' => $this->convertString('name'),
|
||||
'code' => $this->convertString('code'),
|
||||
'symbol' => $this->convertString('symbol'),
|
||||
'decimal_places' => $this->integer('decimal_places'),
|
||||
'decimal_places' => $this->convertInteger('decimal_places'),
|
||||
'default' => $default,
|
||||
'enabled' => $enabled,
|
||||
];
|
||||
|
@@ -49,7 +49,7 @@ class UpdateRequest extends FormRequest
|
||||
'name' => ['name', 'convertString'],
|
||||
'code' => ['code', 'convertString'],
|
||||
'symbol' => ['symbol', 'convertString'],
|
||||
'decimal_places' => ['decimal_places', 'integer'],
|
||||
'decimal_places' => ['decimal_places', 'convertInteger'],
|
||||
'default' => ['default', 'boolean'],
|
||||
'enabled' => ['enabled', 'boolean'],
|
||||
];
|
||||
|
@@ -46,10 +46,10 @@ class StoreRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
return [
|
||||
'link_type_id' => $this->integer('link_type_id'),
|
||||
'link_type_id' => $this->convertInteger('link_type_id'),
|
||||
'link_type_name' => $this->convertString('link_type_name'),
|
||||
'inward_id' => $this->integer('inward_id'),
|
||||
'outward_id' => $this->integer('outward_id'),
|
||||
'inward_id' => $this->convertInteger('inward_id'),
|
||||
'outward_id' => $this->convertInteger('outward_id'),
|
||||
'notes' => $this->stringWithNewlines('notes'),
|
||||
];
|
||||
}
|
||||
|
@@ -46,10 +46,10 @@ class UpdateRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
return [
|
||||
'link_type_id' => $this->integer('link_type_id'),
|
||||
'link_type_id' => $this->convertInteger('link_type_id'),
|
||||
'link_type_name' => $this->convertString('link_type_name'),
|
||||
'inward_id' => $this->integer('inward_id'),
|
||||
'outward_id' => $this->integer('outward_id'),
|
||||
'inward_id' => $this->convertInteger('inward_id'),
|
||||
'outward_id' => $this->convertInteger('outward_id'),
|
||||
'notes' => $this->stringWithNewlines('notes'),
|
||||
];
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ class UpdateRequest extends FormRequest
|
||||
return ['value' => $this->boolean('value')];
|
||||
case 'configuration.permission_update_check':
|
||||
case 'configuration.last_update_check':
|
||||
return ['value' => $this->integer('value')];
|
||||
return ['value' => $this->convertInteger('value')];
|
||||
}
|
||||
|
||||
return ['value' => $this->convertString('value')];
|
||||
|
@@ -46,6 +46,7 @@ class PreferenceStoreRequest extends FormRequest
|
||||
if ('false' === $array['data']) {
|
||||
$array['data'] = false;
|
||||
}
|
||||
// TODO remove float
|
||||
if (is_numeric($array['data'])) {
|
||||
$array['data'] = (float) $array['data'];
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ class PreferenceUpdateRequest extends FormRequest
|
||||
if ('false' === $array['data']) {
|
||||
$array['data'] = false;
|
||||
}
|
||||
// TODO remove float
|
||||
if (is_numeric($array['data'])) {
|
||||
$array['data'] = (float) $array['data'];
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ class CorrectDatabase extends Command
|
||||
'firefly-iii:create-link-types',
|
||||
'firefly-iii:create-access-tokens',
|
||||
'firefly-iii:remove-bills',
|
||||
'firefly-iii:fix-negative-limits',
|
||||
'firefly-iii:enable-currencies',
|
||||
'firefly-iii:fix-transfer-budgets',
|
||||
'firefly-iii:fix-uneven-amount',
|
||||
|
67
app/Console/Commands/Correction/FixBudgetLimits.php
Normal file
67
app/Console/Commands/Correction/FixBudgetLimits.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* FixBudgetLimits.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CorrectionSkeleton
|
||||
*/
|
||||
class FixBudgetLimits extends Command
|
||||
{
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fixes negative budget limits';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:fix-negative-limits';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$set = BudgetLimit::where('amount', '<', '0')->get();
|
||||
if (0 === $set->count()) {
|
||||
$this->info('All budget limits are OK.');
|
||||
return 0;
|
||||
}
|
||||
$count = BudgetLimit::where('amount', '<', '0')->update(['amount' => DB::raw('amount * -1')]);
|
||||
|
||||
$this->info(sprintf('Fixed %d budget limit(s)', $count));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -330,7 +330,7 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
$set = $journal->transactions->filter(
|
||||
static function (Transaction $subject) use ($transaction) {
|
||||
$amount = (float) $transaction->amount * -1 === (float) $subject->amount;
|
||||
$amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float
|
||||
$identifier = $transaction->identifier === $subject->identifier;
|
||||
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
|
@@ -82,6 +82,7 @@ class UpgradeDatabase extends Command
|
||||
'firefly-iii:create-link-types',
|
||||
'firefly-iii:create-access-tokens',
|
||||
'firefly-iii:remove-bills',
|
||||
'firefly-iii:fix-negative-limits',
|
||||
'firefly-iii:enable-currencies',
|
||||
'firefly-iii:fix-transfer-budgets',
|
||||
'firefly-iii:fix-uneven-amount',
|
||||
|
59
app/Events/ChangedPiggyBankAmount.php
Normal file
59
app/Events/ChangedPiggyBankAmount.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* ChangedPiggyBankAmount.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class ChangedPiggyBankAmount
|
||||
*/
|
||||
class ChangedPiggyBankAmount extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public PiggyBank $piggyBank;
|
||||
public ?TransactionJournal $transactionJournal;
|
||||
public ?TransactionGroup $transactionGroup;
|
||||
public string $amount;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param string $amount
|
||||
* @param TransactionJournal|null $transactionJournal
|
||||
* @param TransactionGroup|null $transactionGroup
|
||||
*/
|
||||
public function __construct(PiggyBank $piggyBank, string $amount, ?TransactionJournal $transactionJournal, ?TransactionGroup $transactionGroup)
|
||||
{
|
||||
Log::debug(sprintf('Created piggy bank event for piggy bank #%d with amount %s', $piggyBank->id, $amount));
|
||||
$this->piggyBank = $piggyBank;
|
||||
$this->transactionJournal = $transactionJournal;
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
}
|
@@ -39,6 +39,7 @@ use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException as LaravelValidationException;
|
||||
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Throwable;
|
||||
@@ -62,6 +63,7 @@ class Handler extends ExceptionHandler
|
||||
LaravelOAuthException::class,
|
||||
TokenMismatchException::class,
|
||||
HttpException::class,
|
||||
SuspiciousOperationException::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -288,18 +288,27 @@ class AccountFactory
|
||||
$fields = $this->validCCFields;
|
||||
}
|
||||
|
||||
// remove currency_id if necessary.
|
||||
$type = $account->accountType->type;
|
||||
$list = config('firefly.valid_currency_account_types');
|
||||
if (!in_array($type, $list, true)) {
|
||||
$pos = array_search('currency_id', $fields);
|
||||
if ($pos !== false) {
|
||||
unset($fields[$pos]);
|
||||
}
|
||||
}
|
||||
|
||||
/** @var AccountMetaFactory $factory */
|
||||
$factory = app(AccountMetaFactory::class);
|
||||
foreach ($fields as $field) {
|
||||
// if the field is set but NULL, skip it.
|
||||
// if the field is set but "", update it.
|
||||
if (array_key_exists($field, $data) && null !== $data[$field]) {
|
||||
|
||||
// convert boolean value:
|
||||
if (is_bool($data[$field]) && false === $data[$field]) {
|
||||
$data[$field] = 0;
|
||||
}
|
||||
if (is_bool($data[$field]) && true === $data[$field]) {
|
||||
if (true === $data[$field]) {
|
||||
$data[$field] = 1;
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Events\ChangedPiggyBankAmount;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -40,22 +41,20 @@ class PiggyBankEventFactory
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param PiggyBank|null $piggyBank
|
||||
*
|
||||
* @return PiggyBankEvent|null
|
||||
*/
|
||||
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
|
||||
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): void
|
||||
{
|
||||
Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type));
|
||||
if (null === $piggyBank) {
|
||||
Log::debug('Piggy bank is null');
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (TransactionType::TRANSFER !== $journal->transactionType->type) {
|
||||
Log::info(sprintf('Will not connect %s #%d to a piggy bank.', $journal->transactionType->type, $journal->id));
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var PiggyBankRepositoryInterface $piggyRepos */
|
||||
@@ -66,20 +65,16 @@ class PiggyBankEventFactory
|
||||
if (null === $repetition) {
|
||||
Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d')));
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
Log::debug('Found repetition');
|
||||
$amount = $piggyRepos->getExactAmount($piggyBank, $repetition, $journal);
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
Log::debug('Amount is zero, will not create event.');
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$piggyRepos->addAmountToRepetition($repetition, $amount);
|
||||
$event = $piggyRepos->createEventWithJournal($piggyBank, $amount, $journal);
|
||||
Log::debug(sprintf('Created piggy bank event #%d', $event->id));
|
||||
|
||||
return $event;
|
||||
// amount can be negative here
|
||||
$piggyRepos->addAmountToRepetition($repetition, $amount, $journal);
|
||||
}
|
||||
}
|
||||
|
@@ -81,8 +81,8 @@ class TagFactory
|
||||
public function create(array $data): ?Tag
|
||||
{
|
||||
$zoomLevel = 0 === (int) $data['zoom_level'] ? null : (int) $data['zoom_level'];
|
||||
$latitude = 0.0 === (float) $data['latitude'] ? null : (float) $data['latitude'];
|
||||
$longitude = 0.0 === (float) $data['longitude'] ? null : (float) $data['longitude'];
|
||||
$latitude = 0.0 === (float) $data['latitude'] ? null : (float) $data['latitude']; // intentional float
|
||||
$longitude = 0.0 === (float) $data['longitude'] ? null : (float) $data['longitude']; // intentional float
|
||||
$array = [
|
||||
'user_id' => $this->user->id,
|
||||
'tag' => trim($data['tag']),
|
||||
|
@@ -92,7 +92,7 @@ class TransactionJournalFactory
|
||||
/**
|
||||
* Store a new (set of) transaction journals.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return Collection
|
||||
* @throws DuplicateTransactionException
|
||||
@@ -143,7 +143,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NullArrayObject $row
|
||||
* @param NullArrayObject $row
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
* @throws DuplicateTransactionException
|
||||
@@ -160,11 +160,11 @@ class TransactionJournalFactory
|
||||
$type = $this->typeRepository->findTransactionType(null, $row['type']);
|
||||
$carbon = $row['date'] ?? today(config('app.timezone'));
|
||||
$order = $row['order'] ?? 0;
|
||||
$currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']);
|
||||
$currency = $this->currencyRepository->findCurrency((int)$row['currency_id'], $row['currency_code']);
|
||||
$foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']);
|
||||
$bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']);
|
||||
$bill = $this->billRepository->findBill((int)$row['bill_id'], $row['bill_name']);
|
||||
$billId = TransactionType::WITHDRAWAL === $type->type && null !== $bill ? $bill->id : null;
|
||||
$description = (string) $row['description'];
|
||||
$description = (string)$row['description'];
|
||||
|
||||
/** Manipulate basic fields */
|
||||
$carbon->setTimezone(config('app.timezone'));
|
||||
@@ -237,7 +237,7 @@ class TransactionJournalFactory
|
||||
$transactionFactory->setForeignCurrency($foreignCurrency);
|
||||
$transactionFactory->setReconciled($row['reconciled'] ?? false);
|
||||
try {
|
||||
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
||||
$negative = $transactionFactory->createNegative((string)$row['amount'], (string)$row['foreign_amount']);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error('Exception creating negative transaction.');
|
||||
Log::error($e->getMessage());
|
||||
@@ -256,7 +256,7 @@ class TransactionJournalFactory
|
||||
$transactionFactory->setForeignCurrency($foreignCurrency);
|
||||
$transactionFactory->setReconciled($row['reconciled'] ?? false);
|
||||
try {
|
||||
$transactionFactory->createPositive((string) $row['amount'], (string) $row['foreign_amount']);
|
||||
$transactionFactory->createPositive((string)$row['amount'], (string)$row['foreign_amount']);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error('Exception creating positive transaction.');
|
||||
Log::error($e->getMessage());
|
||||
@@ -294,7 +294,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NullArrayObject $row
|
||||
* @param NullArrayObject $row
|
||||
*
|
||||
* @return string
|
||||
* @throws JsonException
|
||||
@@ -306,10 +306,8 @@ class TransactionJournalFactory
|
||||
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
|
||||
$json = json_encode($dataRow, JSON_THROW_ON_ERROR);
|
||||
if (false === $json) {
|
||||
|
||||
$json = json_encode((string) microtime(), JSON_THROW_ON_ERROR);
|
||||
$json = json_encode((string)microtime(), JSON_THROW_ON_ERROR);
|
||||
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
|
||||
|
||||
}
|
||||
$hash = hash('sha256', $json);
|
||||
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
|
||||
@@ -320,7 +318,7 @@ class TransactionJournalFactory
|
||||
/**
|
||||
* If this transaction already exists, throw an error.
|
||||
*
|
||||
* @param string $hash
|
||||
* @param string $hash
|
||||
*
|
||||
* @throws DuplicateTransactionException
|
||||
* @throws JsonException
|
||||
@@ -353,7 +351,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NullArrayObject $data
|
||||
* @param NullArrayObject $data
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -366,10 +364,10 @@ class TransactionJournalFactory
|
||||
|
||||
// validate source account.
|
||||
$array = [
|
||||
'id' => $data['source_id'] ? (int) $data['source_id'] : null,
|
||||
'name' => $data['source_name'] ? (string) $data['source_name'] : null,
|
||||
'iban' => $data['source_iban'] ? (string) $data['source_iban'] : null,
|
||||
'number' => $data['source_number'] ? (string) $data['source_number'] : null,
|
||||
'id' => $data['source_id'] ? (int)$data['source_id'] : null,
|
||||
'name' => $data['source_name'] ? (string)$data['source_name'] : null,
|
||||
'iban' => $data['source_iban'] ? (string)$data['source_iban'] : null,
|
||||
'number' => $data['source_number'] ? (string)$data['source_number'] : null,
|
||||
];
|
||||
$validSource = $this->accountValidator->validateSource($array);
|
||||
|
||||
@@ -381,10 +379,10 @@ class TransactionJournalFactory
|
||||
|
||||
// validate destination account
|
||||
$array = [
|
||||
'id' => $data['destination_id'] ? (int) $data['destination_id'] : null,
|
||||
'name' => $data['destination_name'] ? (string) $data['destination_name'] : null,
|
||||
'iban' => $data['destination_iban'] ? (string) $data['destination_iban'] : null,
|
||||
'number' => $data['destination_number'] ? (string) $data['destination_number'] : null,
|
||||
'id' => $data['destination_id'] ? (int)$data['destination_id'] : null,
|
||||
'name' => $data['destination_name'] ? (string)$data['destination_name'] : null,
|
||||
'iban' => $data['destination_iban'] ? (string)$data['destination_iban'] : null,
|
||||
'number' => $data['destination_number'] ? (string)$data['destination_number'] : null,
|
||||
];
|
||||
|
||||
$validDestination = $this->accountValidator->validateDestination($array);
|
||||
@@ -395,10 +393,10 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param Account $source
|
||||
* @param Account $destination
|
||||
* @param string $type
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param Account $source
|
||||
* @param Account $destination
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
@@ -413,8 +411,8 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param Account $account
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @throws FireflyException
|
||||
@@ -437,8 +435,8 @@ class TransactionJournalFactory
|
||||
/**
|
||||
* Set foreign currency to NULL if it's the same as the normal currency:
|
||||
*
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param TransactionCurrency|null $foreignCurrency
|
||||
* @param TransactionCurrency|null $currency
|
||||
* @param TransactionCurrency|null $foreignCurrency
|
||||
*
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
@@ -455,9 +453,9 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param TransactionCurrency|null $foreignCurrency
|
||||
* @param Account $destination
|
||||
* @param string $type
|
||||
* @param TransactionCurrency|null $foreignCurrency
|
||||
* @param Account $destination
|
||||
*
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
@@ -471,7 +469,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* @param string $description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -486,7 +484,7 @@ class TransactionJournalFactory
|
||||
* Force the deletion of an entire set of transaction journals and their meta object in case of
|
||||
* an error creating a group.
|
||||
*
|
||||
* @param Collection $collection
|
||||
* @param Collection $collection
|
||||
*/
|
||||
private function forceDeleteOnError(Collection $collection): void
|
||||
{
|
||||
@@ -500,7 +498,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param Transaction $transaction
|
||||
*/
|
||||
private function forceTrDelete(Transaction $transaction): void
|
||||
{
|
||||
@@ -516,8 +514,8 @@ class TransactionJournalFactory
|
||||
/**
|
||||
* Link a piggy bank to this journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $data
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $data
|
||||
*/
|
||||
private function storePiggyEvent(TransactionJournal $journal, NullArrayObject $data): void
|
||||
{
|
||||
@@ -528,7 +526,7 @@ class TransactionJournalFactory
|
||||
return;
|
||||
}
|
||||
|
||||
$piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']);
|
||||
$piggyBank = $this->piggyRepository->findPiggyBank((int)$data['piggy_bank_id'], $data['piggy_bank_name']);
|
||||
|
||||
if (null !== $piggyBank) {
|
||||
$this->piggyEventFactory->create($journal, $piggyBank);
|
||||
@@ -540,8 +538,8 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $transaction
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $transaction
|
||||
*/
|
||||
private function storeMetaFields(TransactionJournal $journal, NullArrayObject $transaction): void
|
||||
{
|
||||
@@ -551,16 +549,16 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $data
|
||||
* @param string $field
|
||||
* @param TransactionJournal $journal
|
||||
* @param NullArrayObject $data
|
||||
* @param string $field
|
||||
*/
|
||||
protected function storeMeta(TransactionJournal $journal, NullArrayObject $data, string $field): void
|
||||
{
|
||||
$set = [
|
||||
'journal' => $journal,
|
||||
'name' => $field,
|
||||
'data' => (string) ($data[$field] ?? ''),
|
||||
'data' => (string)($data[$field] ?? ''),
|
||||
];
|
||||
|
||||
//Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data']));
|
||||
@@ -571,7 +569,7 @@ class TransactionJournalFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $errorOnHash
|
||||
* @param bool $errorOnHash
|
||||
*/
|
||||
public function setErrorOnHash(bool $errorOnHash): void
|
||||
{
|
||||
@@ -584,7 +582,7 @@ class TransactionJournalFactory
|
||||
/**
|
||||
* Set the user.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
|
@@ -59,7 +59,7 @@ class ChartJsGenerator implements GeneratorInterface
|
||||
$index = 0;
|
||||
foreach ($data as $key => $valueArray) {
|
||||
// make larger than 0
|
||||
$chartData['datasets'][0]['data'][] = (float) app('steam')->positive((string) $valueArray['amount']);
|
||||
$chartData['datasets'][0]['data'][] = app('steam')->positive((string) $valueArray['amount']);
|
||||
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
|
||||
$chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol'];
|
||||
$chartData['labels'][] = $key;
|
||||
@@ -174,7 +174,7 @@ class ChartJsGenerator implements GeneratorInterface
|
||||
$index = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
// make larger than 0
|
||||
$chartData['datasets'][0]['data'][] = (float) app('steam')->positive((string) $value);
|
||||
$chartData['datasets'][0]['data'][] = app('steam')->positive((string) $value);
|
||||
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
|
||||
|
||||
$chartData['labels'][] = $key;
|
||||
|
70
app/Handlers/Events/PiggyBankEventHandler.php
Normal file
70
app/Handlers/Events/PiggyBankEventHandler.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* PiggyBankEventHandler.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Events\ChangedPiggyBankAmount;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class PiggyBankEventHandler
|
||||
*/
|
||||
class PiggyBankEventHandler
|
||||
{
|
||||
/**
|
||||
* @param ChangedPiggyBankAmount $event
|
||||
* @return void
|
||||
*/
|
||||
public function changePiggyAmount(ChangedPiggyBankAmount $event): void
|
||||
{
|
||||
// find journal if group is present.
|
||||
$journal = $event->transactionJournal;
|
||||
if (null !== $event->transactionGroup) {
|
||||
$journal = $event->transactionGroup->transactionJournals()->first();
|
||||
}
|
||||
$date = $journal?->date ?? Carbon::now();
|
||||
|
||||
// sanity check: event must not already exist for this journal and piggy bank.
|
||||
if (null !== $journal) {
|
||||
$exists = PiggyBankEvent::where('piggy_bank_id', $event->piggyBank->id)
|
||||
->where('transaction_journal_id', $journal->id)
|
||||
->exists();
|
||||
if($exists) {
|
||||
Log::warning('Already have event for this journal and piggy, will not create another.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PiggyBankEvent::create(
|
||||
[
|
||||
'piggy_bank_id' => $event->piggyBank->id,
|
||||
'transaction_journal_id' => $journal?->id,
|
||||
'date' => $date->format('Y-m-d'),
|
||||
'amount' => $event->amount,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -72,6 +72,7 @@ trait AttachmentCollection
|
||||
Log::debug('Add filter on attachment ID.');
|
||||
$this->joinAttachmentTables();
|
||||
$this->query->whereNotNull('attachments.attachable_id');
|
||||
$this->query->whereNull('attachments.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -699,4 +699,17 @@ trait MetaCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSepaCT(string $sepaCT): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -135,6 +135,7 @@ class EditController extends Controller
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$virtualBalance = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||
$preFilled = [
|
||||
'account_number' => $repository->getMetaValue($account, 'account_number'),
|
||||
'account_role' => $repository->getMetaValue($account, 'account_role'),
|
||||
@@ -143,9 +144,9 @@ class EditController extends Controller
|
||||
'BIC' => $repository->getMetaValue($account, 'BIC'),
|
||||
'opening_balance_date' => $openingBalanceDate,
|
||||
'liability_type_id' => $account->account_type_id,
|
||||
'opening_balance' => number_format((float) $openingBalanceAmount, $currency->decimal_places, '.', ''),
|
||||
'opening_balance' => app('steam')->bcround($openingBalanceAmount, $currency->decimal_places),
|
||||
'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),
|
||||
'virtual_balance' => number_format((float) $account->virtual_balance, $currency->decimal_places, '.', ''),
|
||||
'virtual_balance' => app('steam')->bcround($virtualBalance, $currency->decimal_places),
|
||||
'currency_id' => $currency->id,
|
||||
'include_net_worth' => $includeNetWorth,
|
||||
'interest' => $repository->getMetaValue($account, 'interest'),
|
||||
|
@@ -108,7 +108,7 @@ class IndexController extends Controller
|
||||
$account->startBalance = $this->isInArray($startBalances, $account->id);
|
||||
$account->endBalance = $this->isInArray($endBalances, $account->id);
|
||||
$account->difference = bcsub($account->endBalance, $account->startBalance);
|
||||
$account->interest = number_format((float) $this->repository->getMetaValue($account, 'interest'), 4, '.', '');
|
||||
$account->interest = app('steam')->bcround($this->repository->getMetaValue($account, 'interest'), 4);
|
||||
$account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->current_debt = '0';
|
||||
@@ -167,14 +167,19 @@ class IndexController extends Controller
|
||||
$endBalances = app('steam')->balancesByAccounts($accounts, $end);
|
||||
$activities = app('steam')->getLastActivities($ids);
|
||||
|
||||
|
||||
$accounts->each(
|
||||
function (Account $account) use ($activities, $startBalances, $endBalances) {
|
||||
|
||||
$interest = (string)$this->repository->getMetaValue($account, 'interest');
|
||||
$interest = '' === $interest ? '0' : $interest;
|
||||
|
||||
// See reference nr. 68
|
||||
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
||||
$account->startBalance = $this->isInArray($startBalances, $account->id);
|
||||
$account->endBalance = $this->isInArray($endBalances, $account->id);
|
||||
$account->difference = bcsub($account->endBalance, $account->startBalance);
|
||||
$account->interest = number_format((float) $this->repository->getMetaValue($account, 'interest'), 4, '.', '');
|
||||
$account->interest = app('steam')->bcround($interest, 4);
|
||||
$account->interestPeriod = (string) trans(
|
||||
sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))
|
||||
);
|
||||
|
@@ -128,8 +128,8 @@ class ReconcileController extends Controller
|
||||
|
||||
$startDate = clone $start;
|
||||
$startDate->subDay();
|
||||
$startBalance = number_format((float) app('steam')->balance($account, $startDate), $currency->decimal_places, '.', '');
|
||||
$endBalance = number_format((float) app('steam')->balance($account, $end), $currency->decimal_places, '.', '');
|
||||
$startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||
$endBalance = app('steam')->bcround( app('steam')->balance($account, $end), $currency->decimal_places);
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
$subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);
|
||||
|
||||
|
@@ -148,7 +148,7 @@ class RegisterController extends Controller
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
|
||||
if (false === $allowRegistration) {
|
||||
$message = 'Registration is currently not available.';
|
||||
$message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
@@ -89,8 +89,8 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$bill->amount_min = round((float) $bill->amount_min, $currency->decimal_places);
|
||||
$bill->amount_max = round((float) $bill->amount_max, $currency->decimal_places);
|
||||
$bill->amount_min = app('steam')->bcround($bill->amount_min, $currency->decimal_places);
|
||||
$bill->amount_max = app('steam')->bcround($bill->amount_max, $currency->decimal_places);
|
||||
$rules = $this->repository->getRulesForBill($bill);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
|
||||
|
@@ -162,7 +162,7 @@ class AvailableBudgetController extends Controller
|
||||
*/
|
||||
public function edit(AvailableBudget $availableBudget, Carbon $start, Carbon $end)
|
||||
{
|
||||
$availableBudget->amount = number_format((float) $availableBudget->amount, $availableBudget->transactionCurrency->decimal_places, '.', '');
|
||||
$availableBudget->amount = app('steam')->bcround($availableBudget->amount, $availableBudget->transactionCurrency->decimal_places);
|
||||
|
||||
return view('budgets.available-budgets.edit', compact('availableBudget', 'start', 'end'));
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ class BudgetLimitController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
@@ -78,9 +78,9 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -107,8 +107,8 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param Request $request
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -130,14 +130,14 @@ class BudgetLimitController extends Controller
|
||||
{
|
||||
Log::debug('Going to store new budget-limit.', $request->all());
|
||||
// first search for existing one and update it if necessary.
|
||||
$currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->find((int) $request->get('budget_id'));
|
||||
$currency = $this->currencyRepos->find((int)$request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->find((int)$request->get('budget_id'));
|
||||
if (null === $currency || null === $budget) {
|
||||
throw new FireflyException('No valid currency or budget.');
|
||||
}
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$amount = (string) $request->get('amount');
|
||||
$amount = (string)$request->get('amount');
|
||||
$start->startOfDay();
|
||||
$end->startOfDay();
|
||||
|
||||
@@ -148,6 +148,22 @@ class BudgetLimitController extends Controller
|
||||
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
|
||||
$limit = $this->blRepository->find($budget, $currency, $start, $end);
|
||||
|
||||
// sanity check on amount:
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
if (null !== $limit) {
|
||||
$this->blRepository->destroyBudgetLimit($limit);
|
||||
}
|
||||
// return empty=ish array:
|
||||
return response()->json([]);
|
||||
}
|
||||
if ((int)$amount > 268435456) { // intentional cast to integer
|
||||
$amount = '268435456';
|
||||
}
|
||||
if (-1 === bccomp($amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
if (null !== $limit) {
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
@@ -156,7 +172,7 @@ class BudgetLimitController extends Controller
|
||||
$limit = $this->blRepository->store(
|
||||
[
|
||||
'budget_id' => $request->get('budget_id'),
|
||||
'currency_id' => (int) $request->get('transaction_currency_id'),
|
||||
'currency_id' => (int)$request->get('transaction_currency_id'),
|
||||
'start_date' => $start,
|
||||
'end_date' => $end,
|
||||
'amount' => $amount,
|
||||
@@ -166,12 +182,12 @@ class BudgetLimitController extends Controller
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
$array = $limit->toArray();
|
||||
// add some extra meta data:
|
||||
// add some extra metadata:
|
||||
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency);
|
||||
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], $array['amount']));
|
||||
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['days_left'] = (string) $this->activeDaysLeft($start, $end);
|
||||
$array['days_left'] = (string)$this->activeDaysLeft($start, $end);
|
||||
// left per day:
|
||||
$array['left_per_day'] = bcdiv(bcadd($array['spent'], $array['amount']), $array['days_left']);
|
||||
|
||||
@@ -185,18 +201,38 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param Request $request
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, BudgetLimit $budgetLimit): JsonResponse
|
||||
{
|
||||
$amount = (string) $request->get('amount');
|
||||
$amount = (string)$request->get('amount');
|
||||
if ('' === $amount) {
|
||||
$amount = '0';
|
||||
}
|
||||
|
||||
// sanity check on amount:
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
$budgetId = $budgetLimit->budget_id;
|
||||
$currency = $budgetLimit->transactionCurrency;
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
$array = [
|
||||
'budget_id' => $budgetId,
|
||||
'left_formatted' => app('amount')->formatAnything($currency, '0'),
|
||||
'left_per_day_formatted' => app('amount')->formatAnything($currency, '0'),
|
||||
'transaction_currency_id' => $currency->id,
|
||||
];
|
||||
return response()->json($array);
|
||||
}
|
||||
if ((int)$amount > 268435456) { // 268 million, intentional integer
|
||||
$amount = '268435456';
|
||||
}
|
||||
if (-1 === bccomp($amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
||||
$array = $limit->toArray();
|
||||
|
||||
@@ -210,12 +246,12 @@ class BudgetLimitController extends Controller
|
||||
$array['spent'] = $spentArr[$budgetLimit->transactionCurrency->id]['sum'] ?? '0';
|
||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], $array['amount']));
|
||||
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['days_left'] = (string) $this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||
$array['days_left'] = (string)$this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||
// left per day:
|
||||
$array['left_per_day'] = bcdiv(bcadd($array['spent'], $array['amount']), $array['days_left']);
|
||||
|
||||
// left per day formatted.
|
||||
$array['amount'] = number_format((float) $limit['amount'], $limit->transactionCurrency->decimal_places, '.', '');
|
||||
$array['amount'] = app('steam')->bcround($limit['amount'], $limit->transactionCurrency->decimal_places);
|
||||
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||
|
||||
return response()->json($array);
|
||||
|
@@ -56,7 +56,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -69,41 +69,41 @@ class EditController extends Controller
|
||||
/**
|
||||
* Budget edit form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Request $request, Budget $budget)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
$subTitle = (string)trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
$autoBudget = $this->repository->getAutoBudget($budget);
|
||||
|
||||
// auto budget types
|
||||
$autoBudgetTypes = [
|
||||
0 => (string) trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
|
||||
0 => (string)trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
|
||||
];
|
||||
$autoBudgetPeriods = [
|
||||
'daily' => (string) trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string) trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string) trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string) trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string) trans('firefly.auto_budget_period_yearly'),
|
||||
'daily' => (string)trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string)trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string)trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string)trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string)trans('firefly.auto_budget_period_yearly'),
|
||||
];
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
|
||||
];
|
||||
if ($autoBudget) {
|
||||
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
$preFilled['auto_budget_amount'] = number_format((float) $amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
|
||||
$preFilled['auto_budget_amount'] = app('steam')->bcround($amount, $autoBudget->transactionCurrency->decimal_places);
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
@@ -119,8 +119,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Budget update routine.
|
||||
*
|
||||
* @param BudgetFormUpdateRequest $request
|
||||
* @param Budget $budget
|
||||
* @param BudgetFormUpdateRequest $request
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -129,7 +129,7 @@ class EditController extends Controller
|
||||
$data = $request->getBudgetData();
|
||||
$this->repository->update($budget, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_budget', ['name' => $budget->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));
|
||||
$this->repository->cleanupBudgets();
|
||||
app('preferences')->mark();
|
||||
|
||||
@@ -141,19 +141,17 @@ class EditController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
$request->session()->put('budgets.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
}
|
||||
|
||||
return $redirect;
|
||||
|
@@ -210,7 +210,7 @@ class IndexController extends Controller
|
||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||
$array['budgeted'][] = [
|
||||
'id' => $limit->id,
|
||||
'amount' => number_format((float) $limit->amount, $currency->decimal_places, '.', ''),
|
||||
'amount' => app('steam')->bcround($limit->amount, $currency->decimal_places),
|
||||
'start_date' => $limit->start_date->isoFormat($this->monthAndDayFormat),
|
||||
'end_date' => $limit->end_date->isoFormat($this->monthAndDayFormat),
|
||||
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
|
||||
|
@@ -119,15 +119,15 @@ class AccountController extends Controller
|
||||
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
||||
$diff = bcsub($endAmount, $startAmount);
|
||||
$startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string)$endAmount, $startAmount);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float) $diff,
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
@@ -438,7 +438,7 @@ class AccountController extends Controller
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$currencies = $this->accountRepository->getUsedCurrencies($account);
|
||||
|
||||
@@ -492,7 +492,7 @@ class AccountController extends Controller
|
||||
$theDate = $current->format('Y-m-d');
|
||||
$balance = $range[$theDate] ?? $previous;
|
||||
$label = $current->isoFormat($format);
|
||||
$entries[$label] = (float) $balance;
|
||||
$entries[$label] = $balance;
|
||||
$previous = $balance;
|
||||
$current->addDay();
|
||||
}
|
||||
@@ -502,7 +502,7 @@ class AccountController extends Controller
|
||||
case '1M':
|
||||
case '1Y':
|
||||
while ($end >= $current) {
|
||||
$balance = (float) app('steam')->balance($account, $current, $currency);
|
||||
$balance = app('steam')->balance($account, $current, $currency);
|
||||
$label = app('navigation')->periodShow($current, $step);
|
||||
$entries[$label] = $balance;
|
||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||
@@ -578,15 +578,15 @@ class AccountController extends Controller
|
||||
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
||||
$diff = bcsub($endAmount, $startAmount);
|
||||
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string) $endAmount, $startAmount);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float) $diff,
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class BillController.
|
||||
@@ -134,7 +133,7 @@ class BillController extends Controller
|
||||
}
|
||||
);
|
||||
|
||||
$chartData = [
|
||||
$chartData = [
|
||||
['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
|
||||
['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
@@ -142,7 +141,7 @@ class BillController extends Controller
|
||||
['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
|
||||
];
|
||||
|
||||
$currencyId = (int) $bill->transaction_currency_id;
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
|
||||
@@ -152,7 +151,12 @@ class BillController extends Controller
|
||||
if (!array_key_exists($date, $chartData[2]['entries'])) {
|
||||
$chartData[2]['entries'][$date] = '0';
|
||||
}
|
||||
$amount = bcmul($journal['amount'], '-1');
|
||||
$amount = bcmul($journal['amount'], '-1');
|
||||
if ($currencyId === $journal['foreign_currency_id']) {
|
||||
$amount = bcmul($journal['foreign_amount'], '-1');
|
||||
}
|
||||
|
||||
|
||||
$chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
||||
$collection = new Collection([$budget]);
|
||||
@@ -483,13 +483,13 @@ class BudgetController extends Controller
|
||||
// get budget limit in this period for this currency.
|
||||
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
||||
if (null !== $limit) {
|
||||
$chartData[1]['entries'][$title] = round((float) $limit->amount, $currency->decimal_places);
|
||||
$chartData[1]['entries'][$title] = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
||||
}
|
||||
|
||||
// get spent amount in this period for this currency.
|
||||
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency);
|
||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
||||
$chartData[0]['entries'][$title] = round((float) $amount, $currency->decimal_places);
|
||||
$chartData[0]['entries'][$title] = app('steam')->bcround($amount, $currency->decimal_places);
|
||||
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay()->startOfDay();
|
||||
@@ -534,7 +534,7 @@ class BudgetController extends Controller
|
||||
$title = $currentStart->isoFormat($titleFormat);
|
||||
$sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency);
|
||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
||||
$chartData[$title] = round((float) $amount, $currency->decimal_places);
|
||||
$chartData[$title] = app('steam')->bcround($amount, $currency->decimal_places);
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||
}
|
||||
|
||||
|
@@ -181,28 +181,31 @@ class ReportController extends Controller
|
||||
$period = $journal['date']->format($format);
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$data[$currencyId] = $data[$currencyId] ?? [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_decimal_places' => (int) $journal['currency_decimal_places'],
|
||||
];
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_decimal_places' => (int) $journal['currency_decimal_places'],
|
||||
];
|
||||
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
|
||||
'period' => $period,
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
];
|
||||
'period' => $period,
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
];
|
||||
// in our outgoing?
|
||||
$key = 'spent';
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
|
||||
// deposit = incoming
|
||||
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||
if (
|
||||
TransactionType::DEPOSIT === $journal['transaction_type_type']
|
||||
|| // deposit = incoming
|
||||
// transfer or opening balance, and these accounts are the destination.
|
||||
||
|
||||
|
||||
(
|
||||
(
|
||||
TransactionType::TRANSFER === $journal['transaction_type_type']
|
||||
|| TransactionType::RECONCILIATION === $journal['transaction_type_type']
|
||||
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
||||
)
|
||||
&& in_array($journal['destination_account_id'], $ids, true)
|
||||
@@ -240,8 +243,8 @@ class ReportController extends Controller
|
||||
while ($currentStart <= $end) {
|
||||
$key = $currentStart->format($format);
|
||||
$title = $currentStart->isoFormat($titleFormat);
|
||||
$income['entries'][$title] = round((float) ($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']);
|
||||
$expense['entries'][$title] = round((float) ($currency[$key]['spent'] ?? '0'), $currency['currency_decimal_places']);
|
||||
$income['entries'][$title] = app('steam')->bcround(($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']);
|
||||
$expense['entries'][$title] = app('steam')->bcround(($currency[$key]['spent'] ?? '0'), $currency['currency_decimal_places']);
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||
}
|
||||
|
||||
|
@@ -258,7 +258,7 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,7 +308,7 @@ class CurrencyController extends Controller
|
||||
* @param Request $request
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function enableCurrency(Request $request)
|
||||
public function enableCurrency(Request $request): JsonResponse
|
||||
{
|
||||
$currencyId = (int) $request->get('id');
|
||||
if ($currencyId > 0) {
|
||||
@@ -323,7 +323,7 @@ class CurrencyController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -88,7 +88,7 @@ class DebugController extends Controller
|
||||
public function flush(Request $request)
|
||||
{
|
||||
app('preferences')->mark();
|
||||
$request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range']);
|
||||
$request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range','temp-mfa-secret','temp-mfa-codes']);
|
||||
Log::debug('Call cache:clear...');
|
||||
Artisan::call('cache:clear');
|
||||
Log::debug('Call config:clear...');
|
||||
|
@@ -73,7 +73,7 @@ class BoxController extends Controller
|
||||
$cache->addProperty($today);
|
||||
$cache->addProperty('box-available');
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$leftPerDayAmount = '0';
|
||||
$leftToSpendAmount = '0';
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FrontpageController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -37,7 +38,7 @@ class FrontpageController extends Controller
|
||||
/**
|
||||
* Piggy bank pie chart.
|
||||
*
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -51,7 +52,7 @@ class FrontpageController extends Controller
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
// percentage!
|
||||
$pct = 0;
|
||||
if (0.0 !== (float) $piggyBank->targetamount) {
|
||||
if (0 !== bccomp($piggyBank->targetamount, '0')) {
|
||||
$pct = round(($amount / $piggyBank->targetamount) * 100);
|
||||
}
|
||||
|
||||
@@ -70,12 +71,10 @@ class FrontpageController extends Controller
|
||||
if (!empty($info)) {
|
||||
try {
|
||||
$html = view('json.piggy-banks', compact('info'))->render();
|
||||
|
||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
||||
Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
|
||||
$html = 'Could not render view.';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return response()->json(['html' => $html]);
|
||||
|
@@ -238,8 +238,8 @@ class ReconcileController extends Controller
|
||||
$startDate->subDay();
|
||||
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
$startBalance = round((float) app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||
$endBalance = round((float) app('steam')->balance($account, $end), $currency->decimal_places);
|
||||
$startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||
$endBalance = app('steam')->bcround(app('steam')->balance($account, $end), $currency->decimal_places);
|
||||
|
||||
// get the transactions
|
||||
$selectionStart = clone $start;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user