mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-23 19:51:24 +00:00
Compare commits
330 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7b66a048a | ||
|
|
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 | ||
|
|
20dfeae653 | ||
|
|
397c0abebe | ||
|
|
9f8e33a1ec | ||
|
|
0b378b51f8 | ||
|
|
b138812e1a | ||
|
|
dcfd4d6672 | ||
|
|
11b109d425 | ||
|
|
ba1f0d9a24 | ||
|
|
3cdae5a851 | ||
|
|
7c162fe87f | ||
|
|
b4feb27118 | ||
|
|
2e8ea7493a | ||
|
|
d26a5a6e9c | ||
|
|
29dce924cf | ||
|
|
2bd068211b | ||
|
|
c97792d1d1 | ||
|
|
ef23948b41 | ||
|
|
b97988a597 | ||
|
|
2f20bac734 | ||
|
|
4b23ca1186 | ||
|
|
cb7e766321 | ||
|
|
a63f1c30d9 | ||
|
|
9d75ac221c | ||
|
|
e610c3d6ab | ||
|
|
96d70a84ab | ||
|
|
3f6abdb457 | ||
|
|
00d19241d9 | ||
|
|
7c44cae83c | ||
|
|
4e6dc3bcef | ||
|
|
c1cd322f8f | ||
|
|
0995d78506 | ||
|
|
34c9823096 | ||
|
|
040ba2cf8b | ||
|
|
08896c5813 | ||
|
|
ebe67b14c1 | ||
|
|
75ed1fbbfc | ||
|
|
e39c0c8414 | ||
|
|
769fb7c218 | ||
|
|
359a5656e8 | ||
|
|
8e3b5f9cbc | ||
|
|
a9747d668a | ||
|
|
9c815c916f | ||
|
|
faa995fd01 | ||
|
|
be224367bb | ||
|
|
609ff7d2aa | ||
|
|
10544e5fbd | ||
|
|
812e767ba4 | ||
|
|
134f0cfcd1 | ||
|
|
e46adb6539 | ||
|
|
97c1233e89 | ||
|
|
3e0d8e024c | ||
|
|
1f7fbf57af | ||
|
|
ade653c393 | ||
|
|
016395fe8a | ||
|
|
07fe4400ed | ||
|
|
cc7db2b614 | ||
|
|
d3314e0130 | ||
|
|
75b033c563 | ||
|
|
f451efd90c | ||
|
|
81f2c59ae4 | ||
|
|
ef67355e3b | ||
|
|
4201bc16a1 | ||
|
|
14d58c9834 | ||
|
|
8ac9fe7e69 | ||
|
|
0ab92114a5 | ||
|
|
66310b494b | ||
|
|
805d3ec975 | ||
|
|
f83ab0a7dc | ||
|
|
ced55b5065 | ||
|
|
986863f1d2 | ||
|
|
d1529a0cfc | ||
|
|
f3ceba5325 | ||
|
|
711b4c62b5 | ||
|
|
f441f68da6 | ||
|
|
2cf8bb2537 | ||
|
|
bf434e5d42 | ||
|
|
b1ea36ae5b | ||
|
|
5f3524c5aa | ||
|
|
2f75437ac1 | ||
|
|
6c945bfd60 | ||
|
|
82f993f0ff | ||
|
|
08f3f2aeb9 | ||
|
|
099fc49c4b | ||
|
|
6f2c46cb36 | ||
|
|
135424f8b8 | ||
|
|
9534fa59d6 | ||
|
|
51ae15a650 | ||
|
|
29776fa98c | ||
|
|
7ddffb9251 | ||
|
|
069770b39e | ||
|
|
626119d774 | ||
|
|
993d18d508 | ||
|
|
7b84c7c2dc | ||
|
|
76429c923e | ||
|
|
ca1b048758 | ||
|
|
fb11971b84 | ||
|
|
465542b0f5 | ||
|
|
5185a3ed5a | ||
|
|
4d1615197d | ||
|
|
83c6887ed0 | ||
|
|
9d1e20192d | ||
|
|
ad17837593 | ||
|
|
40ec63ddb9 | ||
|
|
bc3c019d03 | ||
|
|
35f8ecf9bf | ||
|
|
4c649a7099 | ||
|
|
1abf214141 | ||
|
|
8cb748745b | ||
|
|
f3df783ed3 | ||
|
|
50d6234089 | ||
|
|
baa1da3e8e | ||
|
|
89af363ba1 | ||
|
|
df5aff279e | ||
|
|
249b2c63d8 | ||
|
|
6d8f5b88fe | ||
|
|
2579750ba3 | ||
|
|
5e7ee8c5bf | ||
|
|
610bc9f4bc | ||
|
|
3d1233314a | ||
|
|
a258b35236 | ||
|
|
51e23dae21 | ||
|
|
13f2e6537e | ||
|
|
cba3590dec | ||
|
|
613a02fa52 | ||
|
|
2b615cf757 | ||
|
|
52a593e2e0 | ||
|
|
cf89d93cec | ||
|
|
295724c4e9 | ||
|
|
39fbd545ad | ||
|
|
3373961143 | ||
|
|
7f5b50d1f6 | ||
|
|
04267f1388 | ||
|
|
cddba20499 | ||
|
|
791833ab61 | ||
|
|
0ad9a75274 | ||
|
|
172d78f810 | ||
|
|
d2018ad3ec | ||
|
|
97124bcbce | ||
|
|
27dd30785f | ||
|
|
093794f7a5 | ||
|
|
a67bad11b2 | ||
|
|
91a53032b9 | ||
|
|
a87ce030d8 | ||
|
|
799da3597f | ||
|
|
663bf22a2a | ||
|
|
5d3abb315c | ||
|
|
a6ce34b67e | ||
|
|
75f5b5b51d | ||
|
|
555b358b80 | ||
|
|
7772190d45 | ||
|
|
311effb518 | ||
|
|
d2ccb33c54 | ||
|
|
5b312708f9 | ||
|
|
f4ae1e6c79 | ||
|
|
a91298d045 | ||
|
|
0fea3a5a85 | ||
|
|
7b830a69d9 | ||
|
|
22af0b373e |
@@ -1,5 +1,6 @@
|
|||||||
bg_BG
|
bg_BG
|
||||||
cs_CZ
|
cs_CZ
|
||||||
|
da_DK
|
||||||
de_DE
|
de_DE
|
||||||
el_GR
|
el_GR
|
||||||
en_GB
|
en_GB
|
||||||
@@ -8,7 +9,9 @@ es_ES
|
|||||||
fi_FI
|
fi_FI
|
||||||
fr_FR
|
fr_FR
|
||||||
hu_HU
|
hu_HU
|
||||||
|
id_ID
|
||||||
it_IT
|
it_IT
|
||||||
|
ja_JP
|
||||||
nb_NO
|
nb_NO
|
||||||
nl_NL
|
nl_NL
|
||||||
pl_PL
|
pl_PL
|
||||||
@@ -17,7 +20,10 @@ pt_PT
|
|||||||
ro_RO
|
ro_RO
|
||||||
ru_RU
|
ru_RU
|
||||||
sk_SK
|
sk_SK
|
||||||
|
sl_SI
|
||||||
sv_SE
|
sv_SE
|
||||||
|
tr_TR
|
||||||
|
uk_UA
|
||||||
vi_VN
|
vi_VN
|
||||||
zh-hans_CN
|
zh-hans_CN
|
||||||
zh-hant_CN
|
zh-hant_CN
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ SITE_OWNER=mail@example.com
|
|||||||
# The encryption key for your sessions. Keep this very secure.
|
# 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.
|
# 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
|
# 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
|
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||||
|
|
||||||
# Firefly III will launch using this language (for new users and unauthenticated visitors)
|
# 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.
|
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=127.0.0.1
|
||||||
REDIS_PORT=6379
|
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.
|
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
|
||||||
REDIS_DB="0"
|
REDIS_DB="0"
|
||||||
|
|||||||
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
@@ -19,3 +19,10 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: develop
|
||||||
|
labels: ["bug"]
|
||||||
|
versioning-strategy: increase
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
|||||||
1
.github/stale.yml
vendored
1
.github/stale.yml
vendored
@@ -14,6 +14,7 @@ exemptLabels:
|
|||||||
- feature
|
- feature
|
||||||
- bug
|
- bug
|
||||||
- announcement
|
- announcement
|
||||||
|
- "layout-v3"
|
||||||
|
|
||||||
# Set to true to ignore issues in a project (defaults to false)
|
# Set to true to ignore issues in a project (defaults to false)
|
||||||
exemptProjects: false
|
exemptProjects: false
|
||||||
|
|||||||
99
.github/workflows/cleanup.yml
vendored
Normal file
99
.github/workflows/cleanup.yml
vendored
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# This workflow prunes old workflow runs for an entire repository.
|
||||||
|
|
||||||
|
name: Prune old builds
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
prune:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- name: Prune cancelled/skipped runs
|
||||||
|
uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const cancelled = await github.actions.listWorkflowRunsForRepo({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
per_page: 100,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
status: 'cancelled',
|
||||||
|
});
|
||||||
|
|
||||||
|
const skipped = await github.actions.listWorkflowRunsForRepo({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
per_page: 100,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
status: 'skipped',
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const response of [cancelled, skipped]) {
|
||||||
|
for (const run of response.data.workflow_runs) {
|
||||||
|
console.log(`Run id ${run.id} of '${run.name}' is a cancelled/skipped run. Deleting...`);
|
||||||
|
await github.actions.deleteWorkflowRun({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: run.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Prune runs older than 3 days
|
||||||
|
uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const days_to_expiration = 3;
|
||||||
|
const ms_in_day = 86400000;
|
||||||
|
const now = Date.now();
|
||||||
|
const pages = 5;
|
||||||
|
|
||||||
|
// we don't want to prune old runs from test.yml
|
||||||
|
// because we track the duration of runs over time
|
||||||
|
|
||||||
|
const workflows = [
|
||||||
|
'build.yml',
|
||||||
|
'cleanup.yml',
|
||||||
|
'depsreview.yaml',
|
||||||
|
'laravel.yml',
|
||||||
|
'lock.yml',
|
||||||
|
'stale.yml'
|
||||||
|
]
|
||||||
|
|
||||||
|
let runs_to_delete = [];
|
||||||
|
|
||||||
|
for (const workflow of workflows) {
|
||||||
|
for (let page = 0; page < pages; page += 1) {
|
||||||
|
let response = await github.actions.listWorkflowRuns({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
page: page,
|
||||||
|
per_page: 100,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
workflow_id: workflow
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data.workflow_runs.length > 0) {
|
||||||
|
for (const run of response.data.workflow_runs) {
|
||||||
|
if (now - Date.parse(run.created_at) > ms_in_day * days_to_expiration) {
|
||||||
|
runs_to_delete.push([run.id, run.name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const run of runs_to_delete) {
|
||||||
|
console.log(`Run id ${run[0]} of '${run[1]}' is older than ${days_to_expiration} days. Deleting...`);
|
||||||
|
try {
|
||||||
|
await github.actions.deleteWorkflowRun({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: run[0]
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// ignore errors
|
||||||
|
}
|
||||||
|
}
|
||||||
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 }}"
|
||||||
14
.github/workflows/depsreview.yaml
vendored
Normal file
14
.github/workflows/depsreview.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: 'Dependency Review'
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
dependency-review:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 'Checkout Repository'
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: 'Dependency Review'
|
||||||
|
uses: actions/dependency-review-action@v1
|
||||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -26,4 +26,4 @@ jobs:
|
|||||||
for your contributions.
|
for your contributions.
|
||||||
days-before-stale: 14
|
days-before-stale: 14
|
||||||
days-before-close: 7
|
days-before-close: 7
|
||||||
exempt-issue-labels: 'enhancement,feature,bug,announcement'
|
exempt-issue-labels: 'enhancement,feature,bug,announcement,layout-v3'
|
||||||
|
|||||||
@@ -25,11 +25,16 @@ namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
|
|||||||
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Events\DestroyedTransactionGroup;
|
use FireflyIII\Events\DestroyedTransactionGroup;
|
||||||
|
use FireflyIII\Events\UpdatedAccount;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DestroyController
|
* Class DestroyController
|
||||||
@@ -37,6 +42,7 @@ use Illuminate\Http\JsonResponse;
|
|||||||
class DestroyController extends Controller
|
class DestroyController extends Controller
|
||||||
{
|
{
|
||||||
private JournalRepositoryInterface $repository;
|
private JournalRepositoryInterface $repository;
|
||||||
|
private TransactionGroupRepository $groupRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransactionController constructor.
|
* TransactionController constructor.
|
||||||
@@ -54,6 +60,9 @@ class DestroyController extends Controller
|
|||||||
$this->repository = app(JournalRepositoryInterface::class);
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
$this->repository->setUser($admin);
|
$this->repository->setUser($admin);
|
||||||
|
|
||||||
|
$this->groupRepository = app(TransactionGroupRepository::class);
|
||||||
|
$this->groupRepository->setUser($admin);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -72,11 +81,32 @@ class DestroyController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(TransactionGroup $transactionGroup): JsonResponse
|
public function destroy(TransactionGroup $transactionGroup): JsonResponse
|
||||||
{
|
{
|
||||||
$this->repository->destroyGroup($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);
|
||||||
|
|
||||||
// trigger just after destruction
|
// trigger just after destruction
|
||||||
event(new DestroyedTransactionGroup($transactionGroup));
|
event(new DestroyedTransactionGroup($transactionGroup));
|
||||||
app('preferences')->mark();
|
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);
|
return response()->json([], 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class StoreController extends Controller
|
|||||||
|
|
||||||
$selectedGroup = $collector->getGroups()->first();
|
$selectedGroup = $collector->getGroups()->first();
|
||||||
if (null === $selectedGroup) {
|
if (null === $selectedGroup) {
|
||||||
throw new FireflyException('Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||||
}
|
}
|
||||||
/** @var TransactionGroupTransformer $transformer */
|
/** @var TransactionGroupTransformer $transformer */
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
$transformer = app(TransactionGroupTransformer::class);
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ class AutocompleteRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function getData(): array
|
public function getData(): array
|
||||||
{
|
{
|
||||||
$types = $this->string('types');
|
$types = $this->convertString('types');
|
||||||
$array = [];
|
$array = [];
|
||||||
if ('' !== $types) {
|
if ('' !== $types) {
|
||||||
$array = explode(',', $types);
|
$array = explode(',', $types);
|
||||||
}
|
}
|
||||||
$limit = $this->integer('limit');
|
$limit = $this->convertInteger('limit');
|
||||||
$limit = 0 === $limit ? 10 : $limit;
|
$limit = 0 === $limit ? 10 : $limit;
|
||||||
|
|
||||||
// remove 'initial balance' from allowed types. its internal
|
// remove 'initial balance' from allowed types. its internal
|
||||||
@@ -53,7 +53,7 @@ class AutocompleteRequest extends FormRequest
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'types' => $array,
|
'types' => $array,
|
||||||
'query' => $this->string('query'),
|
'query' => $this->convertString('query'),
|
||||||
'date' => $this->getCarbonDate('date'),
|
'date' => $this->getCarbonDate('date'),
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class MoveTransactionsRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'original_account' => $this->integer('original_account'),
|
'original_account' => $this->convertInteger('original_account'),
|
||||||
'destination_account' => $this->integer('destination_account'),
|
'destination_account' => $this->convertInteger('destination_account'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ class ExportRequest extends FormRequest
|
|||||||
$result = [
|
$result = [
|
||||||
'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(),
|
'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(),
|
||||||
'end' => $this->getCarbonDate('end') ?? Carbon::now(),
|
'end' => $this->getCarbonDate('end') ?? Carbon::now(),
|
||||||
'type' => $this->string('type'),
|
'type' => $this->convertString('type'),
|
||||||
];
|
];
|
||||||
$parts = explode(',', $this->string('accounts'));
|
$parts = explode(',', $this->convertString('accounts'));
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser(auth()->user());
|
$repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
|||||||
@@ -56,35 +56,35 @@ class StoreRequest extends FormRequest
|
|||||||
$includeNetWorth = $this->boolean('include_net_worth');
|
$includeNetWorth = $this->boolean('include_net_worth');
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
'include_net_worth' => $includeNetWorth,
|
'include_net_worth' => $includeNetWorth,
|
||||||
'account_type_name' => $this->string('type'),
|
'account_type_name' => $this->convertString('type'),
|
||||||
'account_type_id' => null,
|
'account_type_id' => null,
|
||||||
'currency_id' => $this->integer('currency_id'),
|
'currency_id' => $this->convertInteger('currency_id'),
|
||||||
'order' => $this->integer('order'),
|
'order' => $this->convertInteger('order'),
|
||||||
'currency_code' => $this->string('currency_code'),
|
'currency_code' => $this->convertString('currency_code'),
|
||||||
'virtual_balance' => $this->string('virtual_balance'),
|
'virtual_balance' => $this->convertString('virtual_balance'),
|
||||||
'iban' => $this->string('iban'),
|
'iban' => $this->convertString('iban'),
|
||||||
'BIC' => $this->string('bic'),
|
'BIC' => $this->convertString('bic'),
|
||||||
'account_number' => $this->string('account_number'),
|
'account_number' => $this->convertString('account_number'),
|
||||||
'account_role' => $this->string('account_role'),
|
'account_role' => $this->convertString('account_role'),
|
||||||
'opening_balance' => $this->string('opening_balance'),
|
'opening_balance' => $this->convertString('opening_balance'),
|
||||||
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
|
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
|
||||||
'cc_type' => $this->string('credit_card_type'),
|
'cc_type' => $this->convertString('credit_card_type'),
|
||||||
'cc_monthly_payment_date' => $this->string('monthly_payment_date'),
|
'cc_monthly_payment_date' => $this->convertString('monthly_payment_date'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'interest' => $this->string('interest'),
|
'interest' => $this->convertString('interest'),
|
||||||
'interest_period' => $this->string('interest_period'),
|
'interest_period' => $this->convertString('interest_period'),
|
||||||
];
|
];
|
||||||
// append location information.
|
// append location information.
|
||||||
$data = $this->appendLocationData($data, null);
|
$data = $this->appendLocationData($data, null);
|
||||||
|
|
||||||
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
|
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
|
||||||
$data['opening_balance'] = app('steam')->negative($this->string('liability_amount'));
|
$data['opening_balance'] = app('steam')->negative($this->convertString('liability_amount'));
|
||||||
$data['opening_balance_date'] = $this->getCarbonDate('liability_start_date');
|
$data['opening_balance_date'] = $this->getCarbonDate('liability_start_date');
|
||||||
$data['account_type_name'] = $this->string('liability_type');
|
$data['account_type_name'] = $this->convertString('liability_type');
|
||||||
$data['liability_direction'] = $this->string('liability_direction');
|
$data['liability_direction'] = $this->convertString('liability_direction');
|
||||||
$data['account_type_id'] = null;
|
$data['account_type_id'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ class StoreRequest extends FormRequest
|
|||||||
$accountRoles = implode(',', config('firefly.accountRoles'));
|
$accountRoles = implode(',', config('firefly.accountRoles'));
|
||||||
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||||
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
||||||
$type = $this->string('type');
|
$type = $this->convertString('type');
|
||||||
$rules = [
|
$rules = [
|
||||||
'name' => 'required|min:1|uniqueAccountForUser',
|
'name' => 'required|min:1|uniqueAccountForUser',
|
||||||
'type' => 'required|' . sprintf('in:%s', $types),
|
'type' => 'required|' . sprintf('in:%s', $types),
|
||||||
|
|||||||
@@ -50,28 +50,28 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getUpdateData(): array
|
public function getUpdateData(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'include_net_worth' => ['include_net_worth', 'boolean'],
|
'include_net_worth' => ['include_net_worth', 'boolean'],
|
||||||
'account_type_name' => ['type', 'string'],
|
'account_type_name' => ['type', 'convertString'],
|
||||||
'virtual_balance' => ['virtual_balance', 'string'],
|
'virtual_balance' => ['virtual_balance', 'convertString'],
|
||||||
'iban' => ['iban', 'string'],
|
'iban' => ['iban', 'convertString'],
|
||||||
'BIC' => ['bic', 'string'],
|
'BIC' => ['bic', 'convertString'],
|
||||||
'account_number' => ['account_number', 'string'],
|
'account_number' => ['account_number', 'convertString'],
|
||||||
'account_role' => ['account_role', 'string'],
|
'account_role' => ['account_role', 'convertString'],
|
||||||
'liability_type' => ['liability_type', 'string'],
|
'liability_type' => ['liability_type', 'convertString'],
|
||||||
'opening_balance' => ['opening_balance', 'string'],
|
'opening_balance' => ['opening_balance', 'convertString'],
|
||||||
'opening_balance_date' => ['opening_balance_date', 'date'],
|
'opening_balance_date' => ['opening_balance_date', 'date'],
|
||||||
'cc_type' => ['credit_card_type', 'string'],
|
'cc_type' => ['credit_card_type', 'convertString'],
|
||||||
'cc_monthly_payment_date' => ['monthly_payment_date', 'string'],
|
'cc_monthly_payment_date' => ['monthly_payment_date', 'convertString'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'interest' => ['interest', 'string'],
|
'interest' => ['interest', 'convertString'],
|
||||||
'interest_period' => ['interest_period', 'string'],
|
'interest_period' => ['interest_period', 'convertString'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'currency_id' => ['currency_id', 'integer'],
|
'currency_id' => ['currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['currency_code', 'string'],
|
'currency_code' => ['currency_code', 'convertString'],
|
||||||
'liability_direction' => ['liability_direction', 'string'],
|
'liability_direction' => ['liability_direction', 'convertString'],
|
||||||
'liability_amount' => ['liability_amount', 'string'],
|
'liability_amount' => ['liability_amount', 'convertString'],
|
||||||
'liability_start_date' => ['liability_start_date', 'date'],
|
'liability_start_date' => ['liability_start_date', 'date'],
|
||||||
];
|
];
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
@@ -107,9 +107,9 @@ class UpdateRequest extends FormRequest
|
|||||||
$rules = [
|
$rules = [
|
||||||
'name' => sprintf('min:1|uniqueAccountForUser:%d', $account->id),
|
'name' => sprintf('min:1|uniqueAccountForUser:%d', $account->id),
|
||||||
'type' => sprintf('in:%s', $types),
|
'type' => sprintf('in:%s', $types),
|
||||||
'iban' => ['iban', 'nullable', new UniqueIban($account, $this->string('type'))],
|
'iban' => ['iban', 'nullable', new UniqueIban($account, $this->convertString('type'))],
|
||||||
'bic' => 'bic|nullable',
|
'bic' => 'bic|nullable',
|
||||||
'account_number' => ['between:1,255', 'nullable', new UniqueAccountNumber($account, $this->string('type'))],
|
'account_number' => ['between:1,255', 'nullable', new UniqueAccountNumber($account, $this->convertString('type'))],
|
||||||
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
|
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
|
||||||
'opening_balance_date' => 'date|required_with:opening_balance|nullable',
|
'opening_balance_date' => 'date|required_with:opening_balance|nullable',
|
||||||
'virtual_balance' => 'numeric|nullable',
|
'virtual_balance' => 'numeric|nullable',
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'filename' => $this->string('filename'),
|
'filename' => $this->convertString('filename'),
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'attachable_type' => $this->string('attachable_type'),
|
'attachable_type' => $this->convertString('attachable_type'),
|
||||||
'attachable_id' => $this->integer('attachable_id'),
|
'attachable_id' => $this->convertInteger('attachable_id'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class StoreRequest extends FormRequest
|
|||||||
}, $models
|
}, $models
|
||||||
);
|
);
|
||||||
$models = implode(',', $models);
|
$models = implode(',', $models);
|
||||||
$model = $this->string('attachable_type');
|
$model = $this->convertString('attachable_type');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'filename' => 'required|between:1,255',
|
'filename' => 'required|between:1,255',
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'filename' => ['filename', 'string'],
|
'filename' => ['filename', 'convertString'],
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'attachable_type' => ['attachable_type', 'string'],
|
'attachable_type' => ['attachable_type', 'convertString'],
|
||||||
'attachable_id' => ['attachable_id', 'integer'],
|
'attachable_id' => ['attachable_id', 'convertInteger'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
@@ -70,7 +70,7 @@ class UpdateRequest extends FormRequest
|
|||||||
}, $models
|
}, $models
|
||||||
);
|
);
|
||||||
$models = implode(',', $models);
|
$models = implode(',', $models);
|
||||||
$model = $this->string('attachable_type');
|
$model = $this->convertString('attachable_type');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'filename' => 'between:1,255',
|
'filename' => 'between:1,255',
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ class Request extends FormRequest
|
|||||||
{
|
{
|
||||||
// this is the way:
|
// this is the way:
|
||||||
$fields = [
|
$fields = [
|
||||||
'currency_id' => ['currency_id', 'integer'],
|
'currency_id' => ['currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['currency_code', 'string'],
|
'currency_code' => ['currency_code', 'convertString'],
|
||||||
'amount' => ['amount', 'string'],
|
'amount' => ['amount', 'convertString'],
|
||||||
'start' => ['start', 'date'],
|
'start' => ['start', 'date'],
|
||||||
'end' => ['end', 'date'],
|
'end' => ['end', 'date'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -49,21 +49,21 @@ class StoreRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
Log::debug('Raw fields in Bill StoreRequest', $this->all());
|
Log::debug('Raw fields in Bill StoreRequest', $this->all());
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'amount_min' => ['amount_min', 'string'],
|
'amount_min' => ['amount_min', 'convertString'],
|
||||||
'amount_max' => ['amount_max', 'string'],
|
'amount_max' => ['amount_max', 'convertString'],
|
||||||
'currency_id' => ['currency_id', 'integer'],
|
'currency_id' => ['currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['currency_code', 'string'],
|
'currency_code' => ['currency_code', 'convertString'],
|
||||||
'date' => ['date', 'date'],
|
'date' => ['date', 'date'],
|
||||||
'end_date' => ['end_date', 'date'],
|
'end_date' => ['end_date', 'date'],
|
||||||
'extension_date' => ['extension_date', 'date'],
|
'extension_date' => ['extension_date', 'date'],
|
||||||
'repeat_freq' => ['repeat_freq', 'string'],
|
'repeat_freq' => ['repeat_freq', 'convertString'],
|
||||||
'skip' => ['skip', 'integer'],
|
'skip' => ['skip', 'convertInteger'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'object_group_id' => ['object_group_id', 'integer'],
|
'object_group_id' => ['object_group_id', 'convertInteger'],
|
||||||
'object_group_title' => ['object_group_title', 'string'],
|
'object_group_title' => ['object_group_title', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -47,21 +47,21 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'amount_min' => ['amount_min', 'string'],
|
'amount_min' => ['amount_min', 'convertString'],
|
||||||
'amount_max' => ['amount_max', 'string'],
|
'amount_max' => ['amount_max', 'convertString'],
|
||||||
'currency_id' => ['currency_id', 'integer'],
|
'currency_id' => ['currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['currency_code', 'string'],
|
'currency_code' => ['currency_code', 'convertString'],
|
||||||
'date' => ['date', 'date'],
|
'date' => ['date', 'date'],
|
||||||
'end_date' => ['end_date', 'date'],
|
'end_date' => ['end_date', 'date'],
|
||||||
'extension_date' => ['extension_date', 'date'],
|
'extension_date' => ['extension_date', 'date'],
|
||||||
'repeat_freq' => ['repeat_freq', 'string'],
|
'repeat_freq' => ['repeat_freq', 'convertString'],
|
||||||
'skip' => ['skip', 'integer'],
|
'skip' => ['skip', 'convertInteger'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'object_group_id' => ['object_group_id', 'integer'],
|
'object_group_id' => ['object_group_id', 'convertInteger'],
|
||||||
'object_group_title' => ['object_group_title', 'string'],
|
'object_group_title' => ['object_group_title', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -47,17 +47,17 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['active', 'integer'],
|
'order' => ['active', 'convertInteger'],
|
||||||
'notes' => ['notes', 'string'],
|
'notes' => ['notes', 'convertString'],
|
||||||
|
|
||||||
// auto budget currency:
|
// auto budget currency:
|
||||||
'currency_id' => ['auto_budget_currency_id', 'integer'],
|
'currency_id' => ['auto_budget_currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['auto_budget_currency_code', 'string'],
|
'currency_code' => ['auto_budget_currency_code', 'convertString'],
|
||||||
'auto_budget_type' => ['auto_budget_type', 'string'],
|
'auto_budget_type' => ['auto_budget_type', 'convertString'],
|
||||||
'auto_budget_amount' => ['auto_budget_amount', 'string'],
|
'auto_budget_amount' => ['auto_budget_amount', 'convertString'],
|
||||||
'auto_budget_period' => ['auto_budget_period', 'string'],
|
'auto_budget_period' => ['auto_budget_period', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
// this is the way:
|
// this is the way:
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'notes' => ['notes', 'string'],
|
'notes' => ['notes', 'convertString'],
|
||||||
'currency_id' => ['auto_budget_currency_id', 'integer'],
|
'currency_id' => ['auto_budget_currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['auto_budget_currency_code', 'string'],
|
'currency_code' => ['auto_budget_currency_code', 'convertString'],
|
||||||
'auto_budget_type' => ['auto_budget_type', 'string'],
|
'auto_budget_type' => ['auto_budget_type', 'convertString'],
|
||||||
'auto_budget_amount' => ['auto_budget_amount', 'string'],
|
'auto_budget_amount' => ['auto_budget_amount', 'convertString'],
|
||||||
'auto_budget_period' => ['auto_budget_period', 'string'],
|
'auto_budget_period' => ['auto_budget_period', 'convertString'],
|
||||||
];
|
];
|
||||||
$allData = $this->getAllData($fields);
|
$allData = $this->getAllData($fields);
|
||||||
if (array_key_exists('auto_budget_type', $allData)) {
|
if (array_key_exists('auto_budget_type', $allData)) {
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ class StoreRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'start' => $this->getCarbonDate('start'),
|
'start' => $this->getCarbonDate('start'),
|
||||||
'end' => $this->getCarbonDate('end'),
|
'end' => $this->getCarbonDate('end'),
|
||||||
'amount' => $this->string('amount'),
|
'amount' => $this->convertString('amount'),
|
||||||
'currency_id' => $this->integer('currency_id'),
|
'currency_id' => $this->convertInteger('currency_id'),
|
||||||
'currency_code' => $this->string('currency_code'),
|
'currency_code' => $this->convertString('currency_code'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ class UpdateRequest extends FormRequest
|
|||||||
$fields = [
|
$fields = [
|
||||||
'start' => ['start', 'date'],
|
'start' => ['start', 'date'],
|
||||||
'end' => ['end', 'date'],
|
'end' => ['end', 'date'],
|
||||||
'amount' => ['amount', 'string'],
|
'amount' => ['amount', 'convertString'],
|
||||||
'currency_id' => ['currency_id', 'integer'],
|
'currency_id' => ['currency_id', 'convertInteger'],
|
||||||
'currency_code' => ['currency_code', 'string'],
|
'currency_code' => ['currency_code', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getUpdateData(): array
|
public function getUpdateData(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -44,18 +44,18 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
];
|
];
|
||||||
$data = $this->getAllData($fields);
|
$data = $this->getAllData($fields);
|
||||||
$data['name'] = $this->string('name');
|
$data['name'] = $this->convertString('name');
|
||||||
$data['account_id'] = $this->integer('account_id');
|
$data['account_id'] = $this->convertInteger('account_id');
|
||||||
$data['targetamount'] = $this->string('target_amount');
|
$data['targetamount'] = $this->convertString('target_amount');
|
||||||
$data['current_amount'] = $this->string('current_amount');
|
$data['current_amount'] = $this->convertString('current_amount');
|
||||||
$data['startdate'] = $this->getCarbonDate('start_date');
|
$data['startdate'] = $this->getCarbonDate('start_date');
|
||||||
$data['targetdate'] = $this->getCarbonDate('target_date');
|
$data['targetdate'] = $this->getCarbonDate('target_date');
|
||||||
$data['notes'] = $this->stringWithNewlines('notes');
|
$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->string('object_group_title');
|
$data['object_group_title'] = $this->convertString('object_group_title');
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
|
|||||||
@@ -46,16 +46,16 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'account_id' => ['account_id', 'integer'],
|
'account_id' => ['account_id', 'convertInteger'],
|
||||||
'targetamount' => ['target_amount', 'string'],
|
'targetamount' => ['target_amount', 'convertString'],
|
||||||
'current_amount' => ['current_amount', 'string'],
|
'current_amount' => ['current_amount', 'convertString'],
|
||||||
'startdate' => ['start_date', 'date'],
|
'startdate' => ['start_date', 'date'],
|
||||||
'targetdate' => ['target_date', 'string'],
|
'targetdate' => ['target_date', 'convertString'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'object_group_title' => ['object_group_title', 'string'],
|
'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);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'type' => ['type', 'string'],
|
'type' => ['type', 'convertString'],
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'string'],
|
'description' => ['description', 'convertString'],
|
||||||
'first_date' => ['first_date', 'date'],
|
'first_date' => ['first_date', 'date'],
|
||||||
'repeat_until' => ['repeat_until', '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'],
|
'apply_rules' => ['apply_rules', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
// this is the way:
|
// this is the way:
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'string'],
|
'description' => ['description', 'convertString'],
|
||||||
'first_date' => ['first_date', 'date'],
|
'first_date' => ['first_date', 'date'],
|
||||||
'repeat_until' => ['repeat_until', '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'],
|
'apply_rules' => ['apply_rules', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'notes' => ['notes', 'string'],
|
'notes' => ['notes', 'convertString'],
|
||||||
];
|
];
|
||||||
$reps = $this->getRepetitionData();
|
$reps = $this->getRepetitionData();
|
||||||
$transactions = $this->getTransactionData();
|
$transactions = $this->getTransactionData();
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'string'],
|
'description' => ['description', 'convertString'],
|
||||||
'rule_group_id' => ['rule_group_id', 'integer'],
|
'rule_group_id' => ['rule_group_id', 'convertInteger'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'rule_group_title' => ['rule_group_title', 'string'],
|
'rule_group_title' => ['rule_group_title', 'convertString'],
|
||||||
'trigger' => ['trigger', 'string'],
|
'trigger' => ['trigger', 'convertString'],
|
||||||
'strict' => ['strict', 'boolean'],
|
'strict' => ['strict', 'boolean'],
|
||||||
'stop_processing' => ['stop_processing', 'boolean'],
|
'stop_processing' => ['stop_processing', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'stringWithNewlines'],
|
'description' => ['description', 'stringWithNewlines'],
|
||||||
'rule_group_id' => ['rule_group_id', 'integer'],
|
'rule_group_id' => ['rule_group_id', 'convertInteger'],
|
||||||
'trigger' => ['trigger', 'string'],
|
'trigger' => ['trigger', 'convertString'],
|
||||||
'strict' => ['strict', 'boolean'],
|
'strict' => ['strict', 'boolean'],
|
||||||
'stop_processing' => ['stop_processing', 'boolean'],
|
'stop_processing' => ['stop_processing', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$return = $this->getAllData($fields);
|
$return = $this->getAllData($fields);
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ class StoreRequest extends FormRequest
|
|||||||
$active = $this->boolean('active');
|
$active = $this->boolean('active');
|
||||||
}
|
}
|
||||||
if (null !== $this->get('order')) {
|
if (null !== $this->get('order')) {
|
||||||
$order = $this->integer('order');
|
$order = $this->convertInteger('order');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'description' => $this->string('description'),
|
'description' => $this->convertString('description'),
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
// This is the way.
|
// This is the way.
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'stringWithNewlines'],
|
'description' => ['description', 'stringWithNewlines'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'order' => ['order', 'integer'],
|
'order' => ['order', 'convertInteger'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'tag' => $this->string('tag'),
|
'tag' => $this->convertString('tag'),
|
||||||
'date' => $this->getCarbonDate('date'),
|
'date' => $this->getCarbonDate('date'),
|
||||||
'description' => $this->string('description'),
|
'description' => $this->convertString('description'),
|
||||||
'has_location' => true,
|
'has_location' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
// This is the way.
|
// This is the way.
|
||||||
$fields = [
|
$fields = [
|
||||||
'tag' => ['tag', 'string'],
|
'tag' => ['tag', 'convertString'],
|
||||||
'date' => ['date', 'date'],
|
'date' => ['date', 'date'],
|
||||||
'description' => ['description', 'string'],
|
'description' => ['description', 'convertString'],
|
||||||
];
|
];
|
||||||
$data = $this->getAllData($fields);
|
$data = $this->getAllData($fields);
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class StoreRequest extends FormRequest
|
|||||||
Log::debug('get all data in TransactionStoreRequest');
|
Log::debug('get all data in TransactionStoreRequest');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'group_title' => $this->string('group_title'),
|
'group_title' => $this->convertString('group_title'),
|
||||||
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
|
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
|
||||||
'apply_rules' => $this->boolean('apply_rules', true),
|
'apply_rules' => $this->boolean('apply_rules', true),
|
||||||
'fire_webhooks' => $this->boolean('fire_webhooks', true),
|
'fire_webhooks' => $this->boolean('fire_webhooks', true),
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class UpdateRequest extends FormRequest
|
|||||||
private array $dateFields;
|
private array $dateFields;
|
||||||
private array $integerFields;
|
private array $integerFields;
|
||||||
private array $stringFields;
|
private array $stringFields;
|
||||||
|
private array $floatFields;
|
||||||
private array $textareaFields;
|
private array $textareaFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,12 +85,15 @@ class UpdateRequest extends FormRequest
|
|||||||
'notes',
|
'notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->floatFields = [
|
||||||
|
'amount',
|
||||||
|
'foreign_amount',
|
||||||
|
];
|
||||||
|
|
||||||
$this->stringFields = [
|
$this->stringFields = [
|
||||||
'type',
|
'type',
|
||||||
'currency_code',
|
'currency_code',
|
||||||
'foreign_currency_code',
|
'foreign_currency_code',
|
||||||
'amount',
|
|
||||||
'foreign_amount',
|
|
||||||
'description',
|
'description',
|
||||||
'source_name',
|
'source_name',
|
||||||
'source_iban',
|
'source_iban',
|
||||||
@@ -133,7 +137,7 @@ class UpdateRequest extends FormRequest
|
|||||||
$data['fire_webhooks'] = $this->boolean('fire_webhooks', true);
|
$data['fire_webhooks'] = $this->boolean('fire_webhooks', true);
|
||||||
}
|
}
|
||||||
if ($this->has('group_title')) {
|
if ($this->has('group_title')) {
|
||||||
$data['group_title'] = $this->string('group_title');
|
$data['group_title'] = $this->convertString('group_title');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -163,6 +167,7 @@ class UpdateRequest extends FormRequest
|
|||||||
$current = $this->getDateData($current, $transaction);
|
$current = $this->getDateData($current, $transaction);
|
||||||
$current = $this->getBooleanData($current, $transaction);
|
$current = $this->getBooleanData($current, $transaction);
|
||||||
$current = $this->getArrayData($current, $transaction);
|
$current = $this->getArrayData($current, $transaction);
|
||||||
|
$current = $this->getFloatData($current, $transaction);
|
||||||
$return[] = $current;
|
$return[] = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ class StoreRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'code' => $this->string('code'),
|
'code' => $this->convertString('code'),
|
||||||
'symbol' => $this->string('symbol'),
|
'symbol' => $this->convertString('symbol'),
|
||||||
'decimal_places' => $this->integer('decimal_places'),
|
'decimal_places' => $this->convertInteger('decimal_places'),
|
||||||
'default' => $default,
|
'default' => $default,
|
||||||
'enabled' => $enabled,
|
'enabled' => $enabled,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
// return nothing that isn't explicitely in the array:
|
// return nothing that isn't explicitely in the array:
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => ['name', 'string'],
|
'name' => ['name', 'convertString'],
|
||||||
'code' => ['code', 'string'],
|
'code' => ['code', 'convertString'],
|
||||||
'symbol' => ['symbol', 'string'],
|
'symbol' => ['symbol', 'convertString'],
|
||||||
'decimal_places' => ['decimal_places', 'integer'],
|
'decimal_places' => ['decimal_places', 'convertInteger'],
|
||||||
'default' => ['default', 'boolean'],
|
'default' => ['default', 'boolean'],
|
||||||
'enabled' => ['enabled', 'boolean'],
|
'enabled' => ['enabled', 'boolean'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'link_type_id' => $this->integer('link_type_id'),
|
'link_type_id' => $this->convertInteger('link_type_id'),
|
||||||
'link_type_name' => $this->string('link_type_name'),
|
'link_type_name' => $this->convertString('link_type_name'),
|
||||||
'inward_id' => $this->integer('inward_id'),
|
'inward_id' => $this->convertInteger('inward_id'),
|
||||||
'outward_id' => $this->integer('outward_id'),
|
'outward_id' => $this->convertInteger('outward_id'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'link_type_id' => $this->integer('link_type_id'),
|
'link_type_id' => $this->convertInteger('link_type_id'),
|
||||||
'link_type_name' => $this->string('link_type_name'),
|
'link_type_name' => $this->convertString('link_type_name'),
|
||||||
'inward_id' => $this->integer('inward_id'),
|
'inward_id' => $this->convertInteger('inward_id'),
|
||||||
'outward_id' => $this->integer('outward_id'),
|
'outward_id' => $this->convertInteger('outward_id'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ class StoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'outward' => $this->string('outward'),
|
'outward' => $this->convertString('outward'),
|
||||||
'inward' => $this->string('inward'),
|
'inward' => $this->convertString('inward'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'outward' => $this->string('outward'),
|
'outward' => $this->convertString('outward'),
|
||||||
'inward' => $this->string('inward'),
|
'inward' => $this->convertString('inward'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ class CreateRequest extends FormRequest
|
|||||||
$deliveries = array_flip(config('firefly.webhooks.deliveries'));
|
$deliveries = array_flip(config('firefly.webhooks.deliveries'));
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'trigger' => ['trigger', 'string'],
|
'trigger' => ['trigger', 'convertString'],
|
||||||
'response' => ['response', 'string'],
|
'response' => ['response', 'convertString'],
|
||||||
'delivery' => ['delivery', 'string'],
|
'delivery' => ['delivery', 'convertString'],
|
||||||
'url' => ['url', 'string'],
|
'url' => ['url', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// this is the way.
|
// this is the way.
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ class UpdateRequest extends FormRequest
|
|||||||
$deliveries = array_flip(config('firefly.webhooks.deliveries'));
|
$deliveries = array_flip(config('firefly.webhooks.deliveries'));
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'string'],
|
'title' => ['title', 'convertString'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
'trigger' => ['trigger', 'string'],
|
'trigger' => ['trigger', 'convertString'],
|
||||||
'response' => ['response', 'string'],
|
'response' => ['response', 'convertString'],
|
||||||
'delivery' => ['delivery', 'string'],
|
'delivery' => ['delivery', 'convertString'],
|
||||||
'url' => ['url', 'string'],
|
'url' => ['url', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// this is the way.
|
// this is the way.
|
||||||
@@ -66,7 +66,7 @@ class UpdateRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
$return['secret'] = null !== $this->get('secret');
|
$return['secret'] = null !== $this->get('secret');
|
||||||
if (null !== $this->get('title')) {
|
if (null !== $this->get('title')) {
|
||||||
$return['title'] = $this->string('title');
|
$return['title'] = $this->convertString('title');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ class UpdateRequest extends FormRequest
|
|||||||
return ['value' => $this->boolean('value')];
|
return ['value' => $this->boolean('value')];
|
||||||
case 'configuration.permission_update_check':
|
case 'configuration.permission_update_check':
|
||||||
case 'configuration.last_update_check':
|
case 'configuration.last_update_check':
|
||||||
return ['value' => $this->integer('value')];
|
return ['value' => $this->convertInteger('value')];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['value' => $this->string('value')];
|
return ['value' => $this->convertString('value')];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ class UserStoreRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'email' => $this->string('email'),
|
'email' => $this->convertString('email'),
|
||||||
'blocked' => $blocked,
|
'blocked' => $blocked,
|
||||||
'blocked_code' => $this->string('blocked_code'),
|
'blocked_code' => $this->convertString('blocked_code'),
|
||||||
'role' => $this->string('role'),
|
'role' => $this->convertString('role'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ class UserUpdateRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'email' => $this->string('email'),
|
'email' => $this->convertString('email'),
|
||||||
'blocked' => $blocked,
|
'blocked' => $blocked,
|
||||||
'blocked_code' => $this->string('blocked_code'),
|
'blocked_code' => $this->convertString('blocked_code'),
|
||||||
'role' => $this->string('role'),
|
'role' => $this->convertString('role'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class PreferenceStoreRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'data' => $this->get('data'),
|
'data' => $this->get('data'),
|
||||||
];
|
];
|
||||||
if ('true' === $array['data']) {
|
if ('true' === $array['data']) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class PreferenceUpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'data' => $this->get('data'),
|
'data' => $this->get('data'),
|
||||||
];
|
];
|
||||||
if ('true' === $array['data']) {
|
if ('true' === $array['data']) {
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class CorrectDatabase extends Command
|
|||||||
'firefly-iii:create-link-types',
|
'firefly-iii:create-link-types',
|
||||||
'firefly-iii:create-access-tokens',
|
'firefly-iii:create-access-tokens',
|
||||||
'firefly-iii:remove-bills',
|
'firefly-iii:remove-bills',
|
||||||
|
'firefly-iii:fix-negative-limits',
|
||||||
'firefly-iii:enable-currencies',
|
'firefly-iii:enable-currencies',
|
||||||
'firefly-iii:fix-transfer-budgets',
|
'firefly-iii:fix-transfer-budgets',
|
||||||
'firefly-iii:fix-uneven-amount',
|
'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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,7 +108,11 @@ class FixTransactionTypes extends Command
|
|||||||
}
|
}
|
||||||
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||||
if ($expectedType !== $type) {
|
if ($expectedType !== $type) {
|
||||||
$this->line(sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s"', $journal->id, $type, $expectedType));
|
$this->line(
|
||||||
|
sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
|
||||||
|
$journal->id, $type, $expectedType,
|
||||||
|
$source->accountType->type, $destination->accountType->type,
|
||||||
|
));
|
||||||
$this->changeJournal($journal, $expectedType);
|
$this->changeJournal($journal, $expectedType);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class UpgradeDatabase extends Command
|
|||||||
'firefly-iii:create-link-types',
|
'firefly-iii:create-link-types',
|
||||||
'firefly-iii:create-access-tokens',
|
'firefly-iii:create-access-tokens',
|
||||||
'firefly-iii:remove-bills',
|
'firefly-iii:remove-bills',
|
||||||
|
'firefly-iii:fix-negative-limits',
|
||||||
'firefly-iii:enable-currencies',
|
'firefly-iii:enable-currencies',
|
||||||
'firefly-iii:fix-transfer-budgets',
|
'firefly-iii:fix-transfer-budgets',
|
||||||
'firefly-iii:fix-uneven-amount',
|
'firefly-iii:fix-uneven-amount',
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ use Illuminate\Support\Arr;
|
|||||||
use Illuminate\Validation\ValidationException as LaravelValidationException;
|
use Illuminate\Validation\ValidationException as LaravelValidationException;
|
||||||
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
|
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
@@ -62,6 +63,7 @@ class Handler extends ExceptionHandler
|
|||||||
LaravelOAuthException::class,
|
LaravelOAuthException::class,
|
||||||
TokenMismatchException::class,
|
TokenMismatchException::class,
|
||||||
HttpException::class,
|
HttpException::class,
|
||||||
|
SuspiciousOperationException::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class TransactionGroupFactory
|
class TransactionGroupFactory
|
||||||
{
|
{
|
||||||
/** @var TransactionJournalFactory */
|
private TransactionJournalFactory $journalFactory;
|
||||||
private $journalFactory;
|
private User $user;
|
||||||
/** @var User The user */
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransactionGroupFactory constructor.
|
* TransactionGroupFactory constructor.
|
||||||
|
|||||||
@@ -338,6 +338,12 @@ class UserEventHandler
|
|||||||
Log::debug('Now in storeUserIPAddress');
|
Log::debug('Now in storeUserIPAddress');
|
||||||
$user = $event->user;
|
$user = $event->user;
|
||||||
/** @var array $preference */
|
/** @var array $preference */
|
||||||
|
|
||||||
|
if($user->hasRole('demo')) {
|
||||||
|
Log::debug('Do not log demo user logins');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$preference = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
|
$preference = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Helpers\Collector\Extensions;
|
|||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@@ -299,7 +300,19 @@ trait AttachmentCollection
|
|||||||
{
|
{
|
||||||
Log::debug('Add filter on no attachments.');
|
Log::debug('Add filter on no attachments.');
|
||||||
$this->joinAttachmentTables();
|
$this->joinAttachmentTables();
|
||||||
$this->query->whereNull('attachments.attachable_id');
|
|
||||||
|
$this->query->where(function (Builder $q1) {
|
||||||
|
$q1
|
||||||
|
->whereNull('attachments.attachable_id')
|
||||||
|
->orWhere(function (Builder $q2) {
|
||||||
|
$q2
|
||||||
|
->whereNotNull('attachments.attachable_id')
|
||||||
|
->whereNotNull('attachments.deleted_at');
|
||||||
|
// id is not null
|
||||||
|
// deleted at is not null.
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
trait CollectorProperties
|
trait CollectorProperties
|
||||||
{
|
{
|
||||||
private array $fields;
|
private array $fields;
|
||||||
|
private array $stringFields;
|
||||||
private bool $hasAccountInfo;
|
private bool $hasAccountInfo;
|
||||||
private bool $hasBillInformation;
|
private bool $hasBillInformation;
|
||||||
private bool $hasBudgetInformation;
|
private bool $hasBudgetInformation;
|
||||||
|
|||||||
@@ -555,7 +555,9 @@ trait TimeCollection
|
|||||||
*/
|
*/
|
||||||
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
|
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
die('a');
|
$afterStr = $date->format('Y-m-d 00:00:00');
|
||||||
|
$this->query->where(sprintf('transaction_journals.%s', $field), '<=', $afterStr);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'category_id',
|
'category_id',
|
||||||
'budget_id',
|
'budget_id',
|
||||||
];
|
];
|
||||||
|
$this->stringFields = ['amount', 'foreign_amount'];
|
||||||
$this->total = 0;
|
$this->total = 0;
|
||||||
$this->fields = [
|
$this->fields = [
|
||||||
# group
|
# group
|
||||||
@@ -375,6 +376,9 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
// convert values to integers:
|
// convert values to integers:
|
||||||
$result = $this->convertToInteger($result);
|
$result = $this->convertToInteger($result);
|
||||||
|
|
||||||
|
// convert back to strings because SQLite is dumb like that.
|
||||||
|
$result = $this->convertToStrings($result);
|
||||||
|
|
||||||
$result['reconciled'] = 1 === (int) $result['reconciled'];
|
$result['reconciled'] = 1 === (int) $result['reconciled'];
|
||||||
if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.
|
if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.
|
||||||
$tagId = (int) $augumentedJournal['tag_id'];
|
$tagId = (int) $augumentedJournal['tag_id'];
|
||||||
@@ -506,7 +510,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['currency_decimal_places'];
|
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['currency_decimal_places'];
|
||||||
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
||||||
}
|
}
|
||||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount'] ?? '0');
|
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||||
|
|
||||||
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
||||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
$currencyId = (int) $transaction['foreign_currency_id'];
|
||||||
@@ -815,4 +819,17 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $array
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function convertToStrings(array $array): array
|
||||||
|
{
|
||||||
|
foreach ($this->stringFields as $field) {
|
||||||
|
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string) $array[$field] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,9 +217,9 @@ class LinkController extends Controller
|
|||||||
public function store(LinkTypeFormRequest $request)
|
public function store(LinkTypeFormRequest $request)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $request->string('name'),
|
'name' => $request->convertString('name'),
|
||||||
'inward' => $request->string('inward'),
|
'inward' => $request->convertString('inward'),
|
||||||
'outward' => $request->string('outward'),
|
'outward' => $request->convertString('outward'),
|
||||||
];
|
];
|
||||||
$linkType = $this->repository->store($data);
|
$linkType = $this->repository->store($data);
|
||||||
|
|
||||||
@@ -255,9 +255,9 @@ class LinkController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $request->string('name'),
|
'name' => $request->convertString('name'),
|
||||||
'inward' => $request->string('inward'),
|
'inward' => $request->convertString('inward'),
|
||||||
'outward' => $request->string('outward'),
|
'outward' => $request->convertString('outward'),
|
||||||
];
|
];
|
||||||
$this->repository->update($linkType, $data);
|
$this->repository->update($linkType, $data);
|
||||||
|
|
||||||
|
|||||||
@@ -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')));
|
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);
|
$limit = $this->blRepository->find($budget, $currency, $start, $end);
|
||||||
|
|
||||||
|
// sanity check on amount:
|
||||||
|
if ((float) $amount === 0.0) {
|
||||||
|
if (null !== $limit) {
|
||||||
|
$this->blRepository->destroyBudgetLimit($limit);
|
||||||
|
}
|
||||||
|
// return empty=ish array:
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
if ((int) $amount > 268435456) {
|
||||||
|
$amount = '268435456';
|
||||||
|
}
|
||||||
|
if((float) $amount < 0.0) {
|
||||||
|
$amount = bcmul($amount, '-1');
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $limit) {
|
if (null !== $limit) {
|
||||||
$limit->amount = $amount;
|
$limit->amount = $amount;
|
||||||
$limit->save();
|
$limit->save();
|
||||||
@@ -166,7 +182,7 @@ class BudgetLimitController extends Controller
|
|||||||
|
|
||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
$array = $limit->toArray();
|
$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);
|
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency);
|
||||||
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
||||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], $array['amount']));
|
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], $array['amount']));
|
||||||
@@ -197,6 +213,26 @@ class BudgetLimitController extends Controller
|
|||||||
$amount = '0';
|
$amount = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sanity check on amount:
|
||||||
|
if ((float) $amount === 0.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
|
||||||
|
$amount = '268435456';
|
||||||
|
}
|
||||||
|
if((float) $amount < 0.0) {
|
||||||
|
$amount = bcmul($amount, '-1');
|
||||||
|
}
|
||||||
|
|
||||||
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
||||||
$array = $limit->toArray();
|
$array = $limit->toArray();
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class NoCategoryController extends Controller
|
|||||||
->withAccountInformation()->withBudgetInformation()
|
->withAccountInformation()->withBudgetInformation()
|
||||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
|
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
|
||||||
$groups = $collector->getPaginatedGroups();
|
$groups = $collector->getPaginatedGroups();
|
||||||
$groups->setPath(route('categories.no-category'));
|
$groups->setPath(route('categories.no-category', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||||
|
|
||||||
return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
|
return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
$startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');
|
||||||
$diff = bcsub($endAmount, $startAmount);
|
$diff = bcsub((string)$endAmount, $startAmount);
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||||
if (0 !== bccomp($diff, '0')) {
|
if (0 !== bccomp($diff, '0')) {
|
||||||
// store the values in a temporary array.
|
// store the values in a temporary array.
|
||||||
@@ -438,7 +438,7 @@ class AccountController extends Controller
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
//return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$currencies = $this->accountRepository->getUsedCurrencies($account);
|
$currencies = $this->accountRepository->getUsedCurrencies($account);
|
||||||
|
|
||||||
@@ -578,8 +578,8 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
// see if there is an accompanying start amount.
|
// see if there is an accompanying start amount.
|
||||||
// grab the difference and find the currency.
|
// grab the difference and find the currency.
|
||||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||||
$diff = bcsub($endAmount, $startAmount);
|
$diff = bcsub((string) $endAmount, $startAmount);
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||||
if (0 !== bccomp($diff, '0')) {
|
if (0 !== bccomp($diff, '0')) {
|
||||||
// store the values in a temporary array.
|
// store the values in a temporary array.
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($budget->id);
|
$cache->addProperty($budget->id);
|
||||||
|
|
||||||
if ($cache->has()) {
|
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.
|
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
||||||
$collection = new Collection([$budget]);
|
$collection = new Collection([$budget]);
|
||||||
|
|||||||
@@ -196,13 +196,16 @@ class ReportController extends Controller
|
|||||||
$key = 'spent';
|
$key = 'spent';
|
||||||
$amount = app('steam')->positive($journal['amount']);
|
$amount = app('steam')->positive($journal['amount']);
|
||||||
|
|
||||||
|
// deposit = incoming
|
||||||
|
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||||
if (
|
if (
|
||||||
TransactionType::DEPOSIT === $journal['transaction_type_type']
|
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::TRANSFER === $journal['transaction_type_type']
|
||||||
|
|| TransactionType::RECONCILIATION === $journal['transaction_type_type']
|
||||||
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
||||||
)
|
)
|
||||||
&& in_array($journal['destination_account_id'], $ids, true)
|
&& in_array($journal['destination_account_id'], $ids, true)
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
|
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
|
* @param Request $request
|
||||||
* @return RedirectResponse|Redirector
|
* @return RedirectResponse|Redirector
|
||||||
*/
|
*/
|
||||||
public function enableCurrency(Request $request)
|
public function enableCurrency(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$currencyId = (int) $request->get('id');
|
$currencyId = (int) $request->get('id');
|
||||||
if ($currencyId > 0) {
|
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)
|
public function flush(Request $request)
|
||||||
{
|
{
|
||||||
app('preferences')->mark();
|
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...');
|
Log::debug('Call cache:clear...');
|
||||||
Artisan::call('cache:clear');
|
Artisan::call('cache:clear');
|
||||||
Log::debug('Call config:clear...');
|
Log::debug('Call config:clear...');
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class BoxController extends Controller
|
|||||||
$cache->addProperty($today);
|
$cache->addProperty($today);
|
||||||
$cache->addProperty('box-available');
|
$cache->addProperty('box-available');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
//return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$leftPerDayAmount = '0';
|
$leftPerDayAmount = '0';
|
||||||
$leftToSpendAmount = '0';
|
$leftToSpendAmount = '0';
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class NewUserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository)
|
public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository)
|
||||||
{
|
{
|
||||||
$language = $request->string('language');
|
$language = $request->convertString('language');
|
||||||
if (!array_key_exists($language, config('firefly.languages'))) {
|
if (!array_key_exists($language, config('firefly.languages'))) {
|
||||||
$language = 'en_US';
|
$language = 'en_US';
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ use FireflyIII\Http\Requests\ProfileFormRequest;
|
|||||||
use FireflyIII\Http\Requests\TokenFormRequest;
|
use FireflyIII\Http\Requests\TokenFormRequest;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Facades\Preferences;
|
||||||
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Google2FA;
|
use Google2FA;
|
||||||
@@ -158,36 +159,35 @@ class ProfileController extends Controller
|
|||||||
return redirect(route('profile.index'));
|
return redirect(route('profile.index'));
|
||||||
}
|
}
|
||||||
$domain = $this->getDomain();
|
$domain = $this->getDomain();
|
||||||
$secret = null;
|
$secretPreference = Preferences::get('temp-mfa-secret');
|
||||||
|
$codesPreference = Preferences::get('temp-mfa-codes');
|
||||||
|
|
||||||
// generate secret if not in session
|
// generate secret if not in session
|
||||||
if (!session()->has('temp-mfa-secret')) {
|
if (null === $secretPreference) {
|
||||||
// generate secret + store + flash
|
// generate secret + store + flash
|
||||||
$secret = Google2FA::generateSecretKey();
|
$secret = Google2FA::generateSecretKey();
|
||||||
session()->put('temp-mfa-secret', $secret);
|
Preferences::set('temp-mfa-secret', $secret);
|
||||||
session()->flash('two-factor-secret', $secret);
|
|
||||||
}
|
|
||||||
// re-use secret if in session
|
|
||||||
if (session()->has('temp-mfa-secret')) {
|
|
||||||
// get secret from session and flash
|
|
||||||
$secret = session()->get('temp-mfa-secret');
|
|
||||||
session()->flash('two-factor-secret', $secret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate codes if not in session:
|
// re-use secret if in session
|
||||||
|
if (null !== $secretPreference) {
|
||||||
|
// get secret from session and flash
|
||||||
|
$secret = $secretPreference->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate recovery codes if not in session:
|
||||||
$recoveryCodes = '';
|
$recoveryCodes = '';
|
||||||
if (!session()->has('temp-mfa-codes')) {
|
|
||||||
|
if (null === $codesPreference) {
|
||||||
// generate codes + store + flash:
|
// generate codes + store + flash:
|
||||||
$recovery = app(Recovery::class);
|
$recovery = app(Recovery::class);
|
||||||
$recoveryCodes = $recovery->lowercase()->setCount(8)->setBlocks(2)->setChars(6)->toArray();
|
$recoveryCodes = $recovery->lowercase()->setCount(8)->setBlocks(2)->setChars(6)->toArray();
|
||||||
session()->put('temp-mfa-codes', $recoveryCodes);
|
Preferences::set('temp-mfa-codes', $recoveryCodes);
|
||||||
session()->flash('two-factor-codes', $recoveryCodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get codes from session if there already:
|
// get codes from session if present already:
|
||||||
if (session()->has('temp-mfa-codes')) {
|
if (null !== $codesPreference) {
|
||||||
$recoveryCodes = session()->get('temp-mfa-codes');
|
$recoveryCodes = $codesPreference->data;
|
||||||
session()->flash('two-factor-codes', $recoveryCodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$codes = implode("\r\n", $recoveryCodes);
|
$codes = implode("\r\n", $recoveryCodes);
|
||||||
@@ -275,7 +275,11 @@ class ProfileController extends Controller
|
|||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
|
Preferences::delete('temp-mfa-secret');
|
||||||
|
Preferences::delete('temp-mfa-codes');
|
||||||
$repository->setMFACode($user, null);
|
$repository->setMFACode($user, null);
|
||||||
|
app('preferences')->mark();
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.pref_two_factor_auth_disabled'));
|
session()->flash('success', (string) trans('firefly.pref_two_factor_auth_disabled'));
|
||||||
session()->flash('info', (string) trans('firefly.pref_two_factor_auth_remove_it'));
|
session()->flash('info', (string) trans('firefly.pref_two_factor_auth_remove_it'));
|
||||||
|
|
||||||
@@ -410,7 +414,7 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$newEmail = $request->string('email');
|
$newEmail = $request->convertString('email');
|
||||||
$oldEmail = $user->email;
|
$oldEmail = $user->email;
|
||||||
if ($newEmail === $user->email) {
|
if ($newEmail === $user->email) {
|
||||||
session()->flash('error', (string) trans('firefly.email_not_changed'));
|
session()->flash('error', (string) trans('firefly.email_not_changed'));
|
||||||
@@ -498,10 +502,13 @@ class ProfileController extends Controller
|
|||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
/** @var UserRepositoryInterface $repository */
|
/** @var UserRepositoryInterface $repository */
|
||||||
$repository = app(UserRepositoryInterface::class);
|
$repository = app(UserRepositoryInterface::class);
|
||||||
/** @var string $secret */
|
$secret = Preferences::get('temp-mfa-secret')?->data;
|
||||||
$secret = session()->get('two-factor-secret');
|
|
||||||
$repository->setMFACode($user, $secret);
|
$repository->setMFACode($user, $secret);
|
||||||
|
|
||||||
|
Preferences::delete('temp-mfa-secret');
|
||||||
|
Preferences::delete('temp-mfa-codes');
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.saved_preferences'));
|
session()->flash('success', (string) trans('firefly.saved_preferences'));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ class CreateController extends Controller
|
|||||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
public function createFromJournal(Request $request, TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||||
|
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
$tomorrow = today(config('app.timezone'));
|
$tomorrow = today(config('app.timezone'));
|
||||||
$oldRepetitionType = $request->old('repetition_type');
|
$oldRepetitionType = $request->old('repetition_type');
|
||||||
@@ -213,7 +214,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'recurring.create',
|
'recurring.create',
|
||||||
compact('tomorrow', 'oldRepetitionType', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
|
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class EditController extends Controller
|
|||||||
public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup)
|
public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $request->string('title'),
|
'title' => $request->convertString('title'),
|
||||||
'description' => $request->stringWithNewlines('description'),
|
'description' => $request->stringWithNewlines('description'),
|
||||||
'active' => 1 === (int) $request->input('active'),
|
'active' => 1 === (int) $request->input('active'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class InstallController extends Controller
|
|||||||
'firefly-iii:create-link-types' => [],
|
'firefly-iii:create-link-types' => [],
|
||||||
'firefly-iii:create-access-tokens' => [],
|
'firefly-iii:create-access-tokens' => [],
|
||||||
'firefly-iii:remove-bills' => [],
|
'firefly-iii:remove-bills' => [],
|
||||||
|
'firefly-iii:fix-negative-limits' => [],
|
||||||
'firefly-iii:enable-currencies' => [],
|
'firefly-iii:enable-currencies' => [],
|
||||||
'firefly-iii:fix-transfer-budgets' => [],
|
'firefly-iii:fix-transfer-budgets' => [],
|
||||||
'firefly-iii:fix-uneven-amount' => [],
|
'firefly-iii:fix-uneven-amount' => [],
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
|
use FireflyIII\Events\UpdatedTransactionGroup;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\BulkEditJournalRequest;
|
use FireflyIII\Http\Requests\BulkEditJournalRequest;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
@@ -32,6 +33,7 @@ use Illuminate\Contracts\Foundation\Application;
|
|||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ class BulkController extends Controller
|
|||||||
$ignoreCategory = 1 === (int) $request->get('ignore_category');
|
$ignoreCategory = 1 === (int) $request->get('ignore_category');
|
||||||
$ignoreBudget = 1 === (int) $request->get('ignore_budget');
|
$ignoreBudget = 1 === (int) $request->get('ignore_budget');
|
||||||
$tagsAction = $request->get('tags_action');
|
$tagsAction = $request->get('tags_action');
|
||||||
|
$collection = new Collection;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
foreach ($journalIds as $journalId) {
|
foreach ($journalIds as $journalId) {
|
||||||
@@ -110,13 +112,21 @@ class BulkController extends Controller
|
|||||||
$journal = $this->repository->find($journalId);
|
$journal = $this->repository->find($journalId);
|
||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
||||||
$resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->string('tags')));
|
$resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->convertString('tags')));
|
||||||
$resultC = $this->updateJournalCategory($journal, $ignoreCategory, $request->string('category'));
|
$resultC = $this->updateJournalCategory($journal, $ignoreCategory, $request->convertString('category'));
|
||||||
if ($resultA || $resultB || $resultC) {
|
if ($resultA || $resultB || $resultC) {
|
||||||
$count++;
|
$count++;
|
||||||
|
$collection->push($journal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run rules on changed journals:
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($collection as $journal) {
|
||||||
|
event(new UpdatedTransactionGroup($journal->transactionGroup));
|
||||||
|
}
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$request->session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));
|
$request->session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
|
use FireflyIII\Events\UpdatedAccount;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
@@ -111,10 +115,32 @@ class DeleteController extends Controller
|
|||||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
session()->flash('success', (string) trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
session()->flash('success', (string) trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
||||||
|
|
||||||
|
// grab asset account(s) from group:
|
||||||
|
$accounts = [];
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach($group->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->repository->destroy($group);
|
$this->repository->destroy($group);
|
||||||
|
|
||||||
app('preferences')->mark();
|
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 redirect($this->getPreviousUrl('transactions.delete.url'));
|
return redirect($this->getPreviousUrl('transactions.delete.url'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ use FireflyIII\Transformers\TransactionGroupTransformer;
|
|||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ShowController
|
* Class ShowController
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +148,7 @@ class ShowController extends Controller
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
|
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
|
||||||
if (null !== $transaction['foreign_amount']) {
|
if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && bccomp('0', $transaction['foreign_amount']) !== 0) {
|
||||||
// same for foreign currency:
|
// same for foreign currency:
|
||||||
$foreignSymbol = $transaction['foreign_currency_symbol'];
|
$foreignSymbol = $transaction['foreign_currency_symbol'];
|
||||||
if (!array_key_exists($foreignSymbol, $amounts)) {
|
if (!array_key_exists($foreignSymbol, $amounts)) {
|
||||||
|
|||||||
@@ -45,24 +45,24 @@ class AccountFormRequest extends FormRequest
|
|||||||
public function getAccountData(): array
|
public function getAccountData(): array
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'account_type_name' => $this->string('objectType'),
|
'account_type_name' => $this->convertString('objectType'),
|
||||||
'currency_id' => $this->integer('currency_id'),
|
'currency_id' => $this->convertInteger('currency_id'),
|
||||||
'virtual_balance' => $this->string('virtual_balance'),
|
'virtual_balance' => $this->convertString('virtual_balance'),
|
||||||
'iban' => $this->string('iban'),
|
'iban' => $this->convertString('iban'),
|
||||||
'BIC' => $this->string('BIC'),
|
'BIC' => $this->convertString('BIC'),
|
||||||
'account_number' => $this->string('account_number'),
|
'account_number' => $this->convertString('account_number'),
|
||||||
'account_role' => $this->string('account_role'),
|
'account_role' => $this->convertString('account_role'),
|
||||||
'opening_balance' => $this->string('opening_balance'),
|
'opening_balance' => $this->convertString('opening_balance'),
|
||||||
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
|
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
|
||||||
'cc_type' => $this->string('cc_type'),
|
'cc_type' => $this->convertString('cc_type'),
|
||||||
'cc_monthly_payment_date' => $this->string('cc_monthly_payment_date'),
|
'cc_monthly_payment_date' => $this->convertString('cc_monthly_payment_date'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'interest' => $this->string('interest'),
|
'interest' => $this->convertString('interest'),
|
||||||
'interest_period' => $this->string('interest_period'),
|
'interest_period' => $this->convertString('interest_period'),
|
||||||
'include_net_worth' => '1',
|
'include_net_worth' => '1',
|
||||||
'liability_direction' => $this->string('liability_direction'),
|
'liability_direction' => $this->convertString('liability_direction'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = $this->appendLocationData($data, 'location');
|
$data = $this->appendLocationData($data, 'location');
|
||||||
@@ -77,7 +77,7 @@ class AccountFormRequest extends FormRequest
|
|||||||
// that could have been selected.
|
// that could have been selected.
|
||||||
if ('liabilities' === $data['account_type_name']) {
|
if ('liabilities' === $data['account_type_name']) {
|
||||||
$data['account_type_name'] = null;
|
$data['account_type_name'] = null;
|
||||||
$data['account_type_id'] = $this->integer('liability_type_id');
|
$data['account_type_id'] = $this->convertInteger('liability_type_id');
|
||||||
if ('' !== $data['opening_balance']) {
|
if ('' !== $data['opening_balance']) {
|
||||||
$data['opening_balance'] = app('steam')->negative($data['opening_balance']);
|
$data['opening_balance'] = app('steam')->negative($data['opening_balance']);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ class AccountFormRequest extends FormRequest
|
|||||||
'name' => 'required|min:1|uniqueAccountForUser',
|
'name' => 'required|min:1|uniqueAccountForUser',
|
||||||
'opening_balance' => 'numeric|nullable|max:1000000000',
|
'opening_balance' => 'numeric|nullable|max:1000000000',
|
||||||
'opening_balance_date' => 'date|required_with:opening_balance|nullable',
|
'opening_balance_date' => 'date|required_with:opening_balance|nullable',
|
||||||
'iban' => ['iban', 'nullable', new UniqueIban(null, $this->string('objectType'))],
|
'iban' => ['iban', 'nullable', new UniqueIban(null, $this->convertString('objectType'))],
|
||||||
'BIC' => 'bic|nullable',
|
'BIC' => 'bic|nullable',
|
||||||
'virtual_balance' => 'numeric|nullable|max:1000000000',
|
'virtual_balance' => 'numeric|nullable|max:1000000000',
|
||||||
'currency_id' => 'exists:transaction_currencies,id',
|
'currency_id' => 'exists:transaction_currencies,id',
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class AttachmentFormRequest extends FormRequest
|
|||||||
public function getAttachmentData(): array
|
public function getAttachmentData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'notes' => $this->string('notes'),
|
'notes' => $this->convertString('notes'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,19 +41,19 @@ class BillStoreRequest extends FormRequest
|
|||||||
public function getBillData(): array
|
public function getBillData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'amount_min' => $this->string('amount_min'),
|
'amount_min' => $this->convertString('amount_min'),
|
||||||
'currency_id' => $this->integer('transaction_currency_id'),
|
'currency_id' => $this->convertInteger('transaction_currency_id'),
|
||||||
'currency_code' => '',
|
'currency_code' => '',
|
||||||
'amount_max' => $this->string('amount_max'),
|
'amount_max' => $this->convertString('amount_max'),
|
||||||
'date' => $this->getCarbonDate('date'),
|
'date' => $this->getCarbonDate('date'),
|
||||||
'end_date' => $this->getCarbonDate('bill_end_date'),
|
'end_date' => $this->getCarbonDate('bill_end_date'),
|
||||||
'extension_date' => $this->getCarbonDate('extension_date'),
|
'extension_date' => $this->getCarbonDate('extension_date'),
|
||||||
'repeat_freq' => $this->string('repeat_freq'),
|
'repeat_freq' => $this->convertString('repeat_freq'),
|
||||||
'skip' => $this->integer('skip'),
|
'skip' => $this->convertInteger('skip'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'object_group_title' => $this->string('object_group'),
|
'object_group_title' => $this->convertString('object_group'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,19 +42,19 @@ class BillUpdateRequest extends FormRequest
|
|||||||
public function getBillData(): array
|
public function getBillData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'amount_min' => $this->string('amount_min'),
|
'amount_min' => $this->convertString('amount_min'),
|
||||||
'currency_id' => $this->integer('transaction_currency_id'),
|
'currency_id' => $this->convertInteger('transaction_currency_id'),
|
||||||
'currency_code' => '',
|
'currency_code' => '',
|
||||||
'amount_max' => $this->string('amount_max'),
|
'amount_max' => $this->convertString('amount_max'),
|
||||||
'date' => $this->getCarbonDate('date'),
|
'date' => $this->getCarbonDate('date'),
|
||||||
'end_date' => $this->getCarbonDate('bill_end_date'),
|
'end_date' => $this->getCarbonDate('bill_end_date'),
|
||||||
'extension_date' => $this->getCarbonDate('extension_date'),
|
'extension_date' => $this->getCarbonDate('extension_date'),
|
||||||
'repeat_freq' => $this->string('repeat_freq'),
|
'repeat_freq' => $this->convertString('repeat_freq'),
|
||||||
'skip' => $this->integer('skip'),
|
'skip' => $this->convertInteger('skip'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'object_group_title' => $this->string('object_group'),
|
'object_group_title' => $this->convertString('object_group'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ class BudgetFormStoreRequest extends FormRequest
|
|||||||
public function getBudgetData(): array
|
public function getBudgetData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'auto_budget_type' => $this->integer('auto_budget_type'),
|
'auto_budget_type' => $this->convertInteger('auto_budget_type'),
|
||||||
'currency_id' => $this->integer('auto_budget_currency_id'),
|
'currency_id' => $this->convertInteger('auto_budget_currency_id'),
|
||||||
'auto_budget_amount' => $this->string('auto_budget_amount'),
|
'auto_budget_amount' => $this->convertString('auto_budget_amount'),
|
||||||
'auto_budget_period' => $this->string('auto_budget_period'),
|
'auto_budget_period' => $this->convertString('auto_budget_period'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ class BudgetFormUpdateRequest extends FormRequest
|
|||||||
public function getBudgetData(): array
|
public function getBudgetData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'auto_budget_type' => $this->integer('auto_budget_type'),
|
'auto_budget_type' => $this->convertInteger('auto_budget_type'),
|
||||||
'currency_id' => $this->integer('auto_budget_currency_id'),
|
'currency_id' => $this->convertInteger('auto_budget_currency_id'),
|
||||||
'auto_budget_amount' => $this->string('auto_budget_amount'),
|
'auto_budget_amount' => $this->convertString('auto_budget_amount'),
|
||||||
'auto_budget_period' => $this->string('auto_budget_period'),
|
'auto_budget_period' => $this->convertString('auto_budget_period'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class CategoryFormRequest extends FormRequest
|
|||||||
public function getCategoryData(): array
|
public function getCategoryData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ class CurrencyFormRequest extends FormRequest
|
|||||||
public function getCurrencyData(): array
|
public function getCurrencyData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'code' => $this->string('code'),
|
'code' => $this->convertString('code'),
|
||||||
'symbol' => $this->string('symbol'),
|
'symbol' => $this->convertString('symbol'),
|
||||||
'decimal_places' => $this->integer('decimal_places'),
|
'decimal_places' => $this->convertInteger('decimal_places'),
|
||||||
'enabled' => $this->boolean('enabled'),
|
'enabled' => $this->boolean('enabled'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ class JournalLinkRequest extends FormRequest
|
|||||||
$linkType = $this->get('link_type');
|
$linkType = $this->get('link_type');
|
||||||
$parts = explode('_', $linkType);
|
$parts = explode('_', $linkType);
|
||||||
$return['link_type_id'] = (int) $parts[0];
|
$return['link_type_id'] = (int) $parts[0];
|
||||||
$return['transaction_journal_id'] = $this->integer('opposing');
|
$return['transaction_journal_id'] = $this->convertInteger('opposing');
|
||||||
$return['notes'] = $this->string('notes');
|
$return['notes'] = $this->convertString('notes');
|
||||||
$return['direction'] = $parts[1];
|
$return['direction'] = $parts[1];
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ObjectGroupFormRequest extends FormRequest
|
|||||||
public function getObjectGroupData(): array
|
public function getObjectGroupData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ class PiggyBankStoreRequest extends FormRequest
|
|||||||
public function getPiggyBankData(): array
|
public function getPiggyBankData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'startdate' => $this->getCarbonDate('startdate'),
|
'startdate' => $this->getCarbonDate('startdate'),
|
||||||
'account_id' => $this->integer('account_id'),
|
'account_id' => $this->convertInteger('account_id'),
|
||||||
'targetamount' => $this->string('targetamount'),
|
'targetamount' => $this->convertString('targetamount'),
|
||||||
'targetdate' => $this->getCarbonDate('targetdate'),
|
'targetdate' => $this->getCarbonDate('targetdate'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'object_group_title' => $this->string('object_group'),
|
'object_group_title' => $this->convertString('object_group'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ class PiggyBankUpdateRequest extends FormRequest
|
|||||||
public function getPiggyBankData(): array
|
public function getPiggyBankData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->convertString('name'),
|
||||||
'startdate' => $this->getCarbonDate('startdate'),
|
'startdate' => $this->getCarbonDate('startdate'),
|
||||||
'account_id' => $this->integer('account_id'),
|
'account_id' => $this->convertInteger('account_id'),
|
||||||
'targetamount' => $this->string('targetamount'),
|
'targetamount' => $this->convertString('targetamount'),
|
||||||
'targetdate' => $this->getCarbonDate('targetdate'),
|
'targetdate' => $this->getCarbonDate('targetdate'),
|
||||||
'notes' => $this->stringWithNewlines('notes'),
|
'notes' => $this->stringWithNewlines('notes'),
|
||||||
'object_group_title' => $this->string('object_group'),
|
'object_group_title' => $this->convertString('object_group'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ class ReconciliationStoreRequest extends FormRequest
|
|||||||
$data = [
|
$data = [
|
||||||
'start' => $this->getCarbonDate('start'),
|
'start' => $this->getCarbonDate('start'),
|
||||||
'end' => $this->getCarbonDate('end'),
|
'end' => $this->getCarbonDate('end'),
|
||||||
'start_balance' => $this->string('startBalance'),
|
'start_balance' => $this->convertString('startBalance'),
|
||||||
'end_balance' => $this->string('endBalance'),
|
'end_balance' => $this->convertString('endBalance'),
|
||||||
'difference' => $this->string('difference'),
|
'difference' => $this->convertString('difference'),
|
||||||
'journals' => $transactions,
|
'journals' => $transactions,
|
||||||
'reconcile' => $this->string('reconcile'),
|
'reconcile' => $this->convertString('reconcile'),
|
||||||
];
|
];
|
||||||
Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.');
|
Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.');
|
||||||
|
|
||||||
|
|||||||
@@ -56,34 +56,34 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
$repetitionData = $this->parseRepetitionData();
|
$repetitionData = $this->parseRepetitionData();
|
||||||
$return = [
|
$return = [
|
||||||
'recurrence' => [
|
'recurrence' => [
|
||||||
'type' => $this->string('transaction_type'),
|
'type' => $this->convertString('transaction_type'),
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'description' => $this->string('recurring_description'),
|
'description' => $this->convertString('recurring_description'),
|
||||||
'first_date' => $this->getCarbonDate('first_date'),
|
'first_date' => $this->getCarbonDate('first_date'),
|
||||||
'repeat_until' => $this->getCarbonDate('repeat_until'),
|
'repeat_until' => $this->getCarbonDate('repeat_until'),
|
||||||
'nr_of_repetitions' => $this->integer('repetitions'),
|
'nr_of_repetitions' => $this->convertInteger('repetitions'),
|
||||||
'apply_rules' => $this->boolean('apply_rules'),
|
'apply_rules' => $this->boolean('apply_rules'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'repetition_end' => $this->string('repetition_end'),
|
'repetition_end' => $this->convertString('repetition_end'),
|
||||||
],
|
],
|
||||||
'transactions' => [
|
'transactions' => [
|
||||||
[
|
[
|
||||||
'currency_id' => $this->integer('transaction_currency_id'),
|
'currency_id' => $this->convertInteger('transaction_currency_id'),
|
||||||
'currency_code' => null,
|
'currency_code' => null,
|
||||||
'type' => $this->string('transaction_type'),
|
'type' => $this->convertString('transaction_type'),
|
||||||
'description' => $this->string('transaction_description'),
|
'description' => $this->convertString('transaction_description'),
|
||||||
'amount' => $this->string('amount'),
|
'amount' => $this->convertString('amount'),
|
||||||
'foreign_amount' => null,
|
'foreign_amount' => null,
|
||||||
'foreign_currency_id' => null,
|
'foreign_currency_id' => null,
|
||||||
'foreign_currency_code' => null,
|
'foreign_currency_code' => null,
|
||||||
'budget_id' => $this->integer('budget_id'),
|
'budget_id' => $this->convertInteger('budget_id'),
|
||||||
'budget_name' => null,
|
'budget_name' => null,
|
||||||
'bill_id' => $this->integer('bill_id'),
|
'bill_id' => $this->convertInteger('bill_id'),
|
||||||
'bill_name' => null,
|
'bill_name' => null,
|
||||||
'category_id' => null,
|
'category_id' => null,
|
||||||
'category_name' => $this->string('category'),
|
'category_name' => $this->convertString('category'),
|
||||||
'tags' => '' !== $this->string('tags') ? explode(',', $this->string('tags')) : [],
|
'tags' => '' !== $this->convertString('tags') ? explode(',', $this->convertString('tags')) : [],
|
||||||
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
'piggy_bank_id' => $this->convertInteger('piggy_bank_id'),
|
||||||
'piggy_bank_name' => null,
|
'piggy_bank_name' => null,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -91,17 +91,17 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
[
|
[
|
||||||
'type' => $repetitionData['type'],
|
'type' => $repetitionData['type'],
|
||||||
'moment' => $repetitionData['moment'],
|
'moment' => $repetitionData['moment'],
|
||||||
'skip' => $this->integer('skip'),
|
'skip' => $this->convertInteger('skip'),
|
||||||
'weekend' => $this->integer('weekend'),
|
'weekend' => $this->convertInteger('weekend'),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// fill in foreign currency data
|
// fill in foreign currency data
|
||||||
if (null !== $this->float('foreign_amount')) {
|
if (null !== $this->convertFloat('foreign_amount')) {
|
||||||
$return['transactions'][0]['foreign_amount'] = $this->string('foreign_amount');
|
$return['transactions'][0]['foreign_amount'] = $this->convertString('foreign_amount');
|
||||||
$return['transactions'][0]['foreign_currency_id'] = $this->integer('foreign_currency_id');
|
$return['transactions'][0]['foreign_currency_id'] = $this->convertInteger('foreign_currency_id');
|
||||||
}
|
}
|
||||||
// default values:
|
// default values:
|
||||||
$return['transactions'][0]['source_id'] = null;
|
$return['transactions'][0]['source_id'] = null;
|
||||||
@@ -109,20 +109,20 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
$return['transactions'][0]['destination_id'] = null;
|
$return['transactions'][0]['destination_id'] = null;
|
||||||
$return['transactions'][0]['destination_name'] = null;
|
$return['transactions'][0]['destination_name'] = null;
|
||||||
// fill in source and destination account data
|
// fill in source and destination account data
|
||||||
switch ($this->string('transaction_type')) {
|
switch ($this->convertString('transaction_type')) {
|
||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
|
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
|
||||||
case 'withdrawal':
|
case 'withdrawal':
|
||||||
$return['transactions'][0]['source_id'] = $this->integer('source_id');
|
$return['transactions'][0]['source_id'] = $this->convertInteger('source_id');
|
||||||
$return['transactions'][0]['destination_id'] = $this->integer('withdrawal_destination_id');
|
$return['transactions'][0]['destination_id'] = $this->convertInteger('withdrawal_destination_id');
|
||||||
break;
|
break;
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
$return['transactions'][0]['source_id'] = $this->integer('deposit_source_id');
|
$return['transactions'][0]['source_id'] = $this->convertInteger('deposit_source_id');
|
||||||
$return['transactions'][0]['destination_id'] = $this->integer('destination_id');
|
$return['transactions'][0]['destination_id'] = $this->convertInteger('destination_id');
|
||||||
break;
|
break;
|
||||||
case 'transfer':
|
case 'transfer':
|
||||||
$return['transactions'][0]['source_id'] = $this->integer('source_id');
|
$return['transactions'][0]['source_id'] = $this->convertInteger('source_id');
|
||||||
$return['transactions'][0]['destination_id'] = $this->integer('destination_id');
|
$return['transactions'][0]['destination_id'] = $this->convertInteger('destination_id');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
private function parseRepetitionData(): array
|
private function parseRepetitionData(): array
|
||||||
{
|
{
|
||||||
$value = $this->string('repetition_type');
|
$value = $this->convertString('repetition_type');
|
||||||
$return = [
|
$return = [
|
||||||
'type' => '',
|
'type' => '',
|
||||||
'moment' => '',
|
'moment' => '',
|
||||||
@@ -219,26 +219,26 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
'category' => 'between:1,255|nullable',
|
'category' => 'between:1,255|nullable',
|
||||||
'tags' => 'between:1,255|nullable',
|
'tags' => 'between:1,255|nullable',
|
||||||
];
|
];
|
||||||
if ($this->integer('foreign_currency_id') > 0) {
|
if ($this->convertInteger('foreign_currency_id') > 0) {
|
||||||
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id';
|
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ends after X repetitions, set another rule
|
// if ends after X repetitions, set another rule
|
||||||
if ('times' === $this->string('repetition_end')) {
|
if ('times' === $this->convertString('repetition_end')) {
|
||||||
$rules['repetitions'] = 'required|numeric|between:0,254';
|
$rules['repetitions'] = 'required|numeric|between:0,254';
|
||||||
}
|
}
|
||||||
// if foreign amount, currency must be different.
|
// if foreign amount, currency must be different.
|
||||||
if (null !== $this->float('foreign_amount')) {
|
if (null !== $this->convertFloat('foreign_amount')) {
|
||||||
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id';
|
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ends at date X, set another rule.
|
// if ends at date X, set another rule.
|
||||||
if ('until_date' === $this->string('repetition_end')) {
|
if ('until_date' === $this->convertString('repetition_end')) {
|
||||||
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
|
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
// switchc on type to expand rules for source and destination accounts:
|
// switch on type to expand rules for source and destination accounts:
|
||||||
switch ($this->string('transaction_type')) {
|
switch ($this->convertString('transaction_type')) {
|
||||||
case strtolower(TransactionType::WITHDRAWAL):
|
case strtolower(TransactionType::WITHDRAWAL):
|
||||||
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
|
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
|
||||||
$rules['destination_name'] = 'between:1,255|nullable';
|
$rules['destination_name'] = 'between:1,255|nullable';
|
||||||
@@ -254,7 +254,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->string('transaction_type')));
|
throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->convertString('transaction_type')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update some rules in case the user is editing a post:
|
// update some rules in case the user is editing a post:
|
||||||
@@ -309,9 +309,9 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
|
|
||||||
// See reference nr. 45
|
// See reference nr. 45
|
||||||
|
|
||||||
switch ($this->string('transaction_type')) {
|
switch ($this->convertString('transaction_type')) {
|
||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
|
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
|
||||||
case 'withdrawal':
|
case 'withdrawal':
|
||||||
$sourceId = (int) $data['source_id'];
|
$sourceId = (int) $data['source_id'];
|
||||||
$destinationId = (int) $data['withdrawal_destination_id'];
|
$destinationId = (int) $data['withdrawal_destination_id'];
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ class RuleFormRequest extends FormRequest
|
|||||||
public function getRuleData(): array
|
public function getRuleData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'rule_group_id' => $this->integer('rule_group_id'),
|
'rule_group_id' => $this->convertInteger('rule_group_id'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'trigger' => $this->string('trigger'),
|
'trigger' => $this->convertString('trigger'),
|
||||||
'description' => $this->stringWithNewlines('description'),
|
'description' => $this->stringWithNewlines('description'),
|
||||||
'stop_processing' => $this->boolean('stop_processing'),
|
'stop_processing' => $this->boolean('stop_processing'),
|
||||||
'strict' => $this->boolean('strict'),
|
'strict' => $this->boolean('strict'),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class RuleGroupFormRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->convertString('title'),
|
||||||
'description' => $this->stringWithNewlines('description'),
|
'description' => $this->stringWithNewlines('description'),
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ class TagFormRequest extends FormRequest
|
|||||||
public function collectTagData(): array
|
public function collectTagData(): array
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'tag' => $this->string('tag'),
|
'tag' => $this->convertString('tag'),
|
||||||
'date' => $this->getCarbonDate('date'),
|
'date' => $this->getCarbonDate('date'),
|
||||||
'description' => $this->string('description'),
|
'description' => $this->convertString('description'),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->appendLocationData($data, 'location');
|
return $this->appendLocationData($data, 'location');
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ class UserFormRequest extends FormRequest
|
|||||||
public function getUserData(): array
|
public function getUserData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'email' => $this->string('email'),
|
'email' => $this->convertString('email'),
|
||||||
'blocked' => 1 === $this->integer('blocked'),
|
'blocked' => 1 === $this->convertInteger('blocked'),
|
||||||
'blocked_code' => $this->string('blocked_code'),
|
'blocked_code' => $this->convertString('blocked_code'),
|
||||||
'password' => $this->string('password'),
|
'password' => $this->convertString('password'),
|
||||||
'is_owner' => 1 === $this->integer('is_owner'),
|
'is_owner' => 1 === $this->convertInteger('is_owner'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
|
|||||||
|
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@@ -223,4 +224,28 @@ class Bill extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the max amount
|
||||||
|
*
|
||||||
|
* @return Attribute
|
||||||
|
*/
|
||||||
|
protected function amountMax(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => (string) $value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the min amount
|
||||||
|
*
|
||||||
|
* @return Attribute
|
||||||
|
*/
|
||||||
|
protected function amountMin(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => (string) $value,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
|
|||||||
|
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@@ -119,4 +120,16 @@ class BudgetLimit extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(TransactionCurrency::class);
|
return $this->belongsTo(TransactionCurrency::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount
|
||||||
|
*
|
||||||
|
* @return Attribute
|
||||||
|
*/
|
||||||
|
protected function amount(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => (string) $value,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user