mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 20:55:31 +00:00
Compare commits
1498 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b47614c965 | ||
|
|
9af458df49 | ||
|
|
a67e2b597d | ||
|
|
3c36eed461 | ||
|
|
5a7c3bd716 | ||
|
|
43476167d8 | ||
|
|
d357eaeb51 | ||
|
|
2e118c5f22 | ||
|
|
8e95530ca8 | ||
|
|
a04a6845f7 | ||
|
|
185e9b66d6 | ||
|
|
93a7c51dd1 | ||
|
|
f9ac40a811 | ||
|
|
b0027acf34 | ||
|
|
f5e5854479 | ||
|
|
95d72d065b | ||
|
|
56b2fa69bc | ||
|
|
e614427925 | ||
|
|
34dc1f9f53 | ||
|
|
94d9b78a33 | ||
|
|
b9d949d259 | ||
|
|
3376e1e663 | ||
|
|
ea98c2631f | ||
|
|
50b9fe649d | ||
|
|
56054531a3 | ||
|
|
1912e46113 | ||
|
|
075f951cfe | ||
|
|
26aad765ae | ||
|
|
73ba78d46d | ||
|
|
0d5dd40134 | ||
|
|
f0d84ad142 | ||
|
|
0b4ebf644d | ||
|
|
5b60db120f | ||
|
|
f2073a4494 | ||
|
|
3e12d26afd | ||
|
|
e458208966 | ||
|
|
e28a77dc87 | ||
|
|
a709596ccb | ||
|
|
849c7dfe02 | ||
|
|
e580093a34 | ||
|
|
4fa7a5c1bc | ||
|
|
d668007fee | ||
|
|
6cbccf3be6 | ||
|
|
9cd75dda1a | ||
|
|
56dff7ea67 | ||
|
|
6160f99e92 | ||
|
|
115639a004 | ||
|
|
a0c98c7d9f | ||
|
|
7842700bf1 | ||
|
|
4ecda4d4e0 | ||
|
|
c76d140d0b | ||
|
|
4f42eb1796 | ||
|
|
c67b10e38d | ||
|
|
614ceabd45 | ||
|
|
a94b2e8806 | ||
|
|
732616984b | ||
|
|
eddf0c1200 | ||
|
|
49013264d5 | ||
|
|
f12744ad8c | ||
|
|
4ddcb0c965 | ||
|
|
0846d4898f | ||
|
|
cb746200fa | ||
|
|
fe06a1f7a0 | ||
|
|
9c1cee738d | ||
|
|
7cc778673a | ||
|
|
38d0f0427f | ||
|
|
8572280b7b | ||
|
|
69b1769f22 | ||
|
|
5ceef2e9c3 | ||
|
|
d32446b171 | ||
|
|
d8ca39ffea | ||
|
|
d47bddde62 | ||
|
|
e4802ec958 | ||
|
|
6d855e119d | ||
|
|
7ab81e493a | ||
|
|
fa0397e431 | ||
|
|
aba3b361be | ||
|
|
1cf188ee08 | ||
|
|
f5983f08fd | ||
|
|
b812c2e09f | ||
|
|
d7466efbe1 | ||
|
|
dff30af9f2 | ||
|
|
25dcb73e27 | ||
|
|
63ed3d09d5 | ||
|
|
caf1e6010b | ||
|
|
2d97408c1f | ||
|
|
01c0d76c5a | ||
|
|
7c7032d951 | ||
|
|
6e722f5833 | ||
|
|
d3502c56d3 | ||
|
|
1b8eb3cd68 | ||
|
|
bc7bd84221 | ||
|
|
85b22341a4 | ||
|
|
f8c725e5b2 | ||
|
|
e6344e4f51 | ||
|
|
8eac10bf89 | ||
|
|
c1da0eeced | ||
|
|
0a6d5b1766 | ||
|
|
4035ac09ce | ||
|
|
f81a7cfac0 | ||
|
|
2b086879cc | ||
|
|
a3091f7509 | ||
|
|
70a6ac0038 | ||
|
|
468a53d587 | ||
|
|
51f3b17ad2 | ||
|
|
a864d3bd56 | ||
|
|
a4d5aa0d10 | ||
|
|
aff5ac2c0a | ||
|
|
effe92a05c | ||
|
|
a4ca6dfd38 | ||
|
|
e6012e1ca2 | ||
|
|
472497cafd | ||
|
|
34f4b16a63 | ||
|
|
7f55a870d9 | ||
|
|
6a37ad7c15 | ||
|
|
788981d170 | ||
|
|
f377c92d8a | ||
|
|
0dc3068f7f | ||
|
|
1ad8ec6dd1 | ||
|
|
18a80f3519 | ||
|
|
82f8b091c1 | ||
|
|
71785bae57 | ||
|
|
6d979a68f2 | ||
|
|
ef852ef963 | ||
|
|
00b0ce6c6e | ||
|
|
5750087d37 | ||
|
|
a2ae977550 | ||
|
|
b893651223 | ||
|
|
e221d37d2b | ||
|
|
f0acab21a3 | ||
|
|
93dc5fae09 | ||
|
|
40746db53e | ||
|
|
4404db650c | ||
|
|
ab968a56e6 | ||
|
|
246a3d000a | ||
|
|
cbcf251bb3 | ||
|
|
0756054690 | ||
|
|
b6109ca93e | ||
|
|
823ee2cea0 | ||
|
|
18f6052681 | ||
|
|
4f2ab72567 | ||
|
|
bc6a2c2cca | ||
|
|
7a6a911f7f | ||
|
|
abeff39829 | ||
|
|
4d18c1bf83 | ||
|
|
8a818059f2 | ||
|
|
3768262224 | ||
|
|
b790a0731e | ||
|
|
c38b9eeb08 | ||
|
|
22b376da71 | ||
|
|
fde53abb1a | ||
|
|
c32e09a2b3 | ||
|
|
a243f3d7c2 | ||
|
|
3586c76b95 | ||
|
|
c9d9840235 | ||
|
|
10390953fe | ||
|
|
d6c6bc05ad | ||
|
|
a17601e2a8 | ||
|
|
93d481b515 | ||
|
|
13b8ba3746 | ||
|
|
e6fbd9259d | ||
|
|
b5eeacc128 | ||
|
|
2c575f3ca5 | ||
|
|
5abbb8a807 | ||
|
|
6401b5c9eb | ||
|
|
7edc1a2571 | ||
|
|
f489add855 | ||
|
|
adfdcdb9c6 | ||
|
|
922050a79b | ||
|
|
436bef01da | ||
|
|
b7ba6f81da | ||
|
|
381b09d68b | ||
|
|
fbed65d464 | ||
|
|
bcd612d42f | ||
|
|
eac2293778 | ||
|
|
72deff81f9 | ||
|
|
a8e9ba3041 | ||
|
|
3e73641378 | ||
|
|
7cf44a604a | ||
|
|
9003db6eba | ||
|
|
d1c87e1c21 | ||
|
|
ccaadd1f52 | ||
|
|
e64653eaff | ||
|
|
abb0f3d2be | ||
|
|
7f48a1b6ee | ||
|
|
4affed8f68 | ||
|
|
1088a43866 | ||
|
|
e0d0f49bfd | ||
|
|
ee5b4d6a03 | ||
|
|
7062294419 | ||
|
|
97a687e40a | ||
|
|
206845575c | ||
|
|
da1751940e | ||
|
|
9502544abf | ||
|
|
b975ed87a0 | ||
|
|
cbf3118b8a | ||
|
|
657726e667 | ||
|
|
eb90dac89d | ||
|
|
4c2f758f69 | ||
|
|
e577db4635 | ||
|
|
b1023cdfda | ||
|
|
f15da8e4b3 | ||
|
|
5df6135a0e | ||
|
|
186cbed777 | ||
|
|
bc5aa4b4cd | ||
|
|
836f0ecf3f | ||
|
|
e32f14578c | ||
|
|
03d3ede036 | ||
|
|
b4d44fdd2b | ||
|
|
a93da2a912 | ||
|
|
df86c89acc | ||
|
|
690edb8fcc | ||
|
|
a43bd745d1 | ||
|
|
d5ee87ddee | ||
|
|
a0b46d9d8a | ||
|
|
1783f0beb1 | ||
|
|
8d84dfb3aa | ||
|
|
b9bf5c9856 | ||
|
|
83be7c1886 | ||
|
|
81404d934c | ||
|
|
1a73b6d20d | ||
|
|
1817160d48 | ||
|
|
5eb1f93851 | ||
|
|
beece4dcbb | ||
|
|
288052905e | ||
|
|
40a463d62a | ||
|
|
d82fe2ab4c | ||
|
|
fc4d4a455b | ||
|
|
e113225b37 | ||
|
|
07f62b0d5c | ||
|
|
25bc0b0b78 | ||
|
|
1f50f65bb7 | ||
|
|
2a4486a8dc | ||
|
|
fdcd6befb6 | ||
|
|
c9f7f877c0 | ||
|
|
5ab156c7ad | ||
|
|
bdb298740a | ||
|
|
bd040c80b2 | ||
|
|
7118abe28d | ||
|
|
668b169a5e | ||
|
|
a03e000af1 | ||
|
|
81f5224b11 | ||
|
|
a05d006fa7 | ||
|
|
748d61fb8f | ||
|
|
97561ab9c9 | ||
|
|
aec70cf6a0 | ||
|
|
b0c9745982 | ||
|
|
ab5df484e8 | ||
|
|
cecef98d7d | ||
|
|
625e31d053 | ||
|
|
75c8ec7c0a | ||
|
|
31df959935 | ||
|
|
238a582d8a | ||
|
|
5f4b025be5 | ||
|
|
e0c3c91bf2 | ||
|
|
2a975c302f | ||
|
|
9369d908c8 | ||
|
|
83f38eb8c8 | ||
|
|
4d34160ede | ||
|
|
ddaec93550 | ||
|
|
66e0cea18d | ||
|
|
e3161a8b9c | ||
|
|
91394553c3 | ||
|
|
414c99489c | ||
|
|
ba163f82d1 | ||
|
|
c4882231d1 | ||
|
|
d6dd6795fe | ||
|
|
f2e5e7d182 | ||
|
|
7606757d78 | ||
|
|
ea07b831f2 | ||
|
|
9cc20bbea7 | ||
|
|
9632f69b15 | ||
|
|
b11e3145c5 | ||
|
|
fa5d33caf5 | ||
|
|
93a31337fc | ||
|
|
a8a1eca89e | ||
|
|
4ba713e553 | ||
|
|
cfa9e8b318 | ||
|
|
2437759368 | ||
|
|
b43ea5c108 | ||
|
|
84263b9ee8 | ||
|
|
2b2d10d1f1 | ||
|
|
1c041b9543 | ||
|
|
c53f8b6dfc | ||
|
|
1c661a86b6 | ||
|
|
0afebb26e0 | ||
|
|
0cb0a628e3 | ||
|
|
30d653faee | ||
|
|
b0d4ebbf4b | ||
|
|
711999f589 | ||
|
|
fcf578784f | ||
|
|
4f76ea560d | ||
|
|
df9c9ce044 | ||
|
|
1f12d81008 | ||
|
|
736f7963d1 | ||
|
|
b38e2a994d | ||
|
|
b8bd232622 | ||
|
|
27bc33add3 | ||
|
|
0703343748 | ||
|
|
584963f360 | ||
|
|
054e563c59 | ||
|
|
fd1dc9ca04 | ||
|
|
e5669fcfab | ||
|
|
a7f57e10eb | ||
|
|
c9dea3f531 | ||
|
|
ef74016a13 | ||
|
|
ff6a0d2cb5 | ||
|
|
4af923ac78 | ||
|
|
34f1e8a56b | ||
|
|
968ff30058 | ||
|
|
aaf0c5d276 | ||
|
|
4b2392c966 | ||
|
|
9bcf56157d | ||
|
|
43e8779e3b | ||
|
|
2287339781 | ||
|
|
4d9aafbeaf | ||
|
|
5944cda03a | ||
|
|
9aa743b31b | ||
|
|
6bd6b1eb95 | ||
|
|
fc0202eb74 | ||
|
|
fd0dc3d289 | ||
|
|
aa4695bbbf | ||
|
|
09d751076e | ||
|
|
419c1a75dd | ||
|
|
fb821ea63e | ||
|
|
f1be63e8bf | ||
|
|
7725b2a723 | ||
|
|
f5a83fa84f | ||
|
|
c1d090db67 | ||
|
|
7aaec92ae6 | ||
|
|
afe6f07e61 | ||
|
|
b151ec0c85 | ||
|
|
978c56b16b | ||
|
|
fbbf002451 | ||
|
|
13cd9312f8 | ||
|
|
a534c142c1 | ||
|
|
89ece0ce78 | ||
|
|
9b65f468a0 | ||
|
|
e1826cdfb2 | ||
|
|
97d12cd77a | ||
|
|
5b5c988aa3 | ||
|
|
6d9acd1dc2 | ||
|
|
860fc507b7 | ||
|
|
5f1d4292ad | ||
|
|
7e2cda7f41 | ||
|
|
ef394e1024 | ||
|
|
f2f0d82f89 | ||
|
|
2032ef6662 | ||
|
|
7b5c41d541 | ||
|
|
f844197954 | ||
|
|
0353e4aa95 | ||
|
|
3ee93de280 | ||
|
|
1175c1d676 | ||
|
|
6d51d0cc79 | ||
|
|
12e19c0a70 | ||
|
|
00f25836c0 | ||
|
|
c4669ade29 | ||
|
|
2b06279f05 | ||
|
|
252ea7277b | ||
|
|
20c45aa0e0 | ||
|
|
c34a5ed3e4 | ||
|
|
5ff7884596 | ||
|
|
e04245de96 | ||
|
|
25e4d78119 | ||
|
|
d5d0e6b4ba | ||
|
|
2f14753405 | ||
|
|
5e7c57744c | ||
|
|
0ac0dbc774 | ||
|
|
0b368edd97 | ||
|
|
d0e7fe37bb | ||
|
|
c2d9dcf696 | ||
|
|
4efc0ffc6e | ||
|
|
e64b5dcf3a | ||
|
|
cb4b6f7023 | ||
|
|
784b24fe3c | ||
|
|
fba23c927b | ||
|
|
5771b8c3c6 | ||
|
|
5c7ba4e065 | ||
|
|
e51f593a2d | ||
|
|
bfd925fbfe | ||
|
|
993fe3ae0a | ||
|
|
70aaa67cfc | ||
|
|
45f918963e | ||
|
|
1ecc454f70 | ||
|
|
95966cdcd4 | ||
|
|
b1f2780fb6 | ||
|
|
416f8e2855 | ||
|
|
1558da60aa | ||
|
|
18a9d90d46 | ||
|
|
934ae994cc | ||
|
|
ee4b38c279 | ||
|
|
2171ed7912 | ||
|
|
4e274e6a09 | ||
|
|
1be0cf99b9 | ||
|
|
60a41887cb | ||
|
|
f9582cd4fe | ||
|
|
edcd5d56c9 | ||
|
|
14fa91d17f | ||
|
|
e411e629ce | ||
|
|
5626b11b66 | ||
|
|
eee42a0f99 | ||
|
|
03787e3d74 | ||
|
|
b9e7d99a87 | ||
|
|
b0ac0ea0cf | ||
|
|
8e42f25a1e | ||
|
|
d69843d4bc | ||
|
|
fdba28fad7 | ||
|
|
3b2dd93316 | ||
|
|
2ad7336605 | ||
|
|
84ad8529df | ||
|
|
e441df367d | ||
|
|
08fcff2a98 | ||
|
|
957e34a57a | ||
|
|
71239dbf5b | ||
|
|
c5d27f0148 | ||
|
|
b8340ddb59 | ||
|
|
f16b7c4286 | ||
|
|
b126177546 | ||
|
|
1121377d2d | ||
|
|
f9220b8999 | ||
|
|
be05513ecd | ||
|
|
ffe18c63a5 | ||
|
|
fd8a59924d | ||
|
|
fdd9d81701 | ||
|
|
2dd2d0ef58 | ||
|
|
329c3b14d5 | ||
|
|
27815d0311 | ||
|
|
21da959203 | ||
|
|
d60c5a26de | ||
|
|
d4c9f53b10 | ||
|
|
02cd0600ea | ||
|
|
7ffc621638 | ||
|
|
3ed4d28c4a | ||
|
|
3a5abc3047 | ||
|
|
ed06ec9a58 | ||
|
|
fdb74a3dcd | ||
|
|
fcea35ffa9 | ||
|
|
3c494a64f5 | ||
|
|
e75d9ccd0e | ||
|
|
ccaf9d31a6 | ||
|
|
cb6862b364 | ||
|
|
e83416d84d | ||
|
|
2f8113db6b | ||
|
|
cbed5ce67b | ||
|
|
c9fa1588df | ||
|
|
22beea1a76 | ||
|
|
b46e17667c | ||
|
|
e3f174621c | ||
|
|
2ffb98aba8 | ||
|
|
d1e462e66d | ||
|
|
29b5513b03 | ||
|
|
8918c3ed12 | ||
|
|
036e50c0b6 | ||
|
|
47d9f5e470 | ||
|
|
8efc1df385 | ||
|
|
fbc6d4a002 | ||
|
|
fa2c2ff7ba | ||
|
|
787f27102e | ||
|
|
80a4a26eae | ||
|
|
48f89a7448 | ||
|
|
32081fb07c | ||
|
|
b13d617863 | ||
|
|
936ead8668 | ||
|
|
c01f1aa788 | ||
|
|
2b9c1e65aa | ||
|
|
4cd7c528f2 | ||
|
|
74db23a972 | ||
|
|
aa009d22fc | ||
|
|
79c00548df | ||
|
|
c86791950d | ||
|
|
eb5d17d695 | ||
|
|
ab31cade09 | ||
|
|
99f8ed7760 | ||
|
|
b4f929b325 | ||
|
|
ca1dcc8038 | ||
|
|
a545f1ef88 | ||
|
|
4a64fea352 | ||
|
|
e4800851b0 | ||
|
|
95681519a8 | ||
|
|
f1037c3616 | ||
|
|
cfe83c7e00 | ||
|
|
157f0fc7b6 | ||
|
|
261ab7251c | ||
|
|
61e673ea7b | ||
|
|
3fb3fc698a | ||
|
|
f3aabf6ab8 | ||
|
|
d752c38d3d | ||
|
|
48bfae99f4 | ||
|
|
116c772b1c | ||
|
|
e784dd2399 | ||
|
|
19aec7e6d6 | ||
|
|
0fdce6191b | ||
|
|
ee3ad3e498 | ||
|
|
7b4b6a2356 | ||
|
|
b4f47e793b | ||
|
|
aff7651697 | ||
|
|
27003f15e7 | ||
|
|
b501cd4555 | ||
|
|
b40581919c | ||
|
|
b2fce4d487 | ||
|
|
24b7543f72 | ||
|
|
b040db7976 | ||
|
|
405c487518 | ||
|
|
84b0e344fe | ||
|
|
48cae87ed0 | ||
|
|
cd5ce36b5d | ||
|
|
3d71c924fd | ||
|
|
e6a44706a3 | ||
|
|
1353f684b5 | ||
|
|
dd5119f49a | ||
|
|
83c036e33e | ||
|
|
3e1c16d9a9 | ||
|
|
42adbfa9f4 | ||
|
|
b3068b7a66 | ||
|
|
d24a046570 | ||
|
|
ff2640276c | ||
|
|
459d57befa | ||
|
|
5dddb5e0df | ||
|
|
e848c7372c | ||
|
|
1884746233 | ||
|
|
321bb33255 | ||
|
|
e6fd8324e2 | ||
|
|
fc4f35d6ba | ||
|
|
ef42d89d55 | ||
|
|
2a0af839f9 | ||
|
|
a19e116a15 | ||
|
|
9325b628fd | ||
|
|
02237d9efe | ||
|
|
f2e6f03f8c | ||
|
|
e2330d9bfe | ||
|
|
bbc131b52c | ||
|
|
7812613d54 | ||
|
|
f9ce8b0bd9 | ||
|
|
b4da9096d5 | ||
|
|
85880a1974 | ||
|
|
6b9b7fdeb3 | ||
|
|
7c1cb9ac5d | ||
|
|
24070c3cb9 | ||
|
|
6c18c7fb9f | ||
|
|
9d05d26aa4 | ||
|
|
b34f16535c | ||
|
|
232cc39325 | ||
|
|
6be1f5819f | ||
|
|
1a8fd25ec3 | ||
|
|
7530effcaa | ||
|
|
e9cab814d3 | ||
|
|
40f2c9bd27 | ||
|
|
cb243e6295 | ||
|
|
b263120c8f | ||
|
|
c7cf55b831 | ||
|
|
235ef06386 | ||
|
|
925fd3bd3c | ||
|
|
4559d3e4c5 | ||
|
|
670bf26510 | ||
|
|
f3c9ee5a54 | ||
|
|
ee237bfc3f | ||
|
|
fe66bb1984 | ||
|
|
9971d95605 | ||
|
|
4ebfc33b39 | ||
|
|
bb86ef5683 | ||
|
|
69edc66509 | ||
|
|
d3f4a06d89 | ||
|
|
dac961a732 | ||
|
|
21619544f5 | ||
|
|
4a8183e5cc | ||
|
|
da198fb073 | ||
|
|
b1ed1f878b | ||
|
|
2a3a89a6ed | ||
|
|
013ebbf039 | ||
|
|
07fa1b301f | ||
|
|
c9893d0fda | ||
|
|
78c936cd1e | ||
|
|
c0ae7b6987 | ||
|
|
83e4bc774a | ||
|
|
9d8fe1d917 | ||
|
|
b78913ee0f | ||
|
|
ac0d173cfd | ||
|
|
bd7c5423e6 | ||
|
|
839c077e8f | ||
|
|
325d74ff6b | ||
|
|
cf2390a02e | ||
|
|
abbd04b487 | ||
|
|
9f8fbd67e7 | ||
|
|
1d287c5d0d | ||
|
|
b2d42d590c | ||
|
|
2a4d10c7c7 | ||
|
|
65329b84b9 | ||
|
|
8a58215f45 | ||
|
|
a9a41f31e3 | ||
|
|
dcabaf380f | ||
|
|
29e3eedef5 | ||
|
|
c9322cf69f | ||
|
|
cb7b2cd53c | ||
|
|
61ac8f6ab8 | ||
|
|
61ff1330df | ||
|
|
008b9c1191 | ||
|
|
be33f6c987 | ||
|
|
ee6bd0a0fa | ||
|
|
f41145fe56 | ||
|
|
21dc8df0bf | ||
|
|
858f8c63e6 | ||
|
|
80f9e0e396 | ||
|
|
81a3e23b4e | ||
|
|
58f97a163f | ||
|
|
9576806765 | ||
|
|
deb829dfdb | ||
|
|
4a7e185c44 | ||
|
|
ce5cabd903 | ||
|
|
172d2297f1 | ||
|
|
48d1d5c90b | ||
|
|
7ee9b51b3f | ||
|
|
888f5896ff | ||
|
|
a539cfe4f2 | ||
|
|
eb80578e30 | ||
|
|
35c9367819 | ||
|
|
cbe046ba07 | ||
|
|
e27e0a97a7 | ||
|
|
822432712b | ||
|
|
1f5ac4d9cc | ||
|
|
d66b03166f | ||
|
|
c563340532 | ||
|
|
dd85b8d46a | ||
|
|
182cd6c100 | ||
|
|
59962005db | ||
|
|
6ecbc5e013 | ||
|
|
f42bd19c1c | ||
|
|
c68d7c5aad | ||
|
|
0e5e2fcef7 | ||
|
|
d8344d8d45 | ||
|
|
1ad5f5c759 | ||
|
|
b38e7cbb1a | ||
|
|
a5b6bf5797 | ||
|
|
29d1c950ec | ||
|
|
b16d23460e | ||
|
|
1b27f6143c | ||
|
|
11e6410d7c | ||
|
|
a78d7b9fec | ||
|
|
68bbadb99a | ||
|
|
7211ea5b9b | ||
|
|
825be42c4e | ||
|
|
e12c4197f6 | ||
|
|
6c14742ce0 | ||
|
|
16018109c8 | ||
|
|
9a658b60fb | ||
|
|
a13dc20e51 | ||
|
|
9f1fb62d21 | ||
|
|
a41dc220ca | ||
|
|
6388bdc946 | ||
|
|
5ea5622ead | ||
|
|
bcfbb232c0 | ||
|
|
b7f73cdc0e | ||
|
|
4c84a14ee2 | ||
|
|
e5201d6127 | ||
|
|
ce7bc723ac | ||
|
|
4a54f484aa | ||
|
|
e1c242326a | ||
|
|
2eee4cfcf8 | ||
|
|
729a6130be | ||
|
|
b8c73aa0d9 | ||
|
|
c659d67172 | ||
|
|
3dbc74b040 | ||
|
|
5e703c6e7f | ||
|
|
30817cba9f | ||
|
|
38170ba614 | ||
|
|
369e92f0ad | ||
|
|
f8f407aac5 | ||
|
|
f9ce04744b | ||
|
|
6ba421e867 | ||
|
|
7cfc615af8 | ||
|
|
cfc5dfb62f | ||
|
|
3a8bfaba27 | ||
|
|
fedc16503a | ||
|
|
8f0d36e724 | ||
|
|
20850a604f | ||
|
|
259fadc433 | ||
|
|
eb616f36ea | ||
|
|
20e7948d99 | ||
|
|
1e4c3f0e19 | ||
|
|
c749e69abc | ||
|
|
f266c14f9c | ||
|
|
b8fffe5d6d | ||
|
|
9082a7d9b9 | ||
|
|
f7490176ec | ||
|
|
5fce6af00a | ||
|
|
cd67d8fe21 | ||
|
|
ce51bb8be6 | ||
|
|
60339c9d1b | ||
|
|
d90f457a36 | ||
|
|
8f42c6e4eb | ||
|
|
5e87d7b570 | ||
|
|
80718baa16 | ||
|
|
ae9a9c1647 | ||
|
|
68ff7fd568 | ||
|
|
30ff2f0f11 | ||
|
|
ab70fd8bc5 | ||
|
|
479f9e8f0c | ||
|
|
f584f159f0 | ||
|
|
9352d38c1c | ||
|
|
6b79f1abdb | ||
|
|
52ce873aac | ||
|
|
006da9ebbc | ||
|
|
0f32761ae8 | ||
|
|
ec44d0dc8e | ||
|
|
d268931187 | ||
|
|
7efb77e000 | ||
|
|
e16bbf1072 | ||
|
|
6560510dd8 | ||
|
|
293d61b343 | ||
|
|
f582a11feb | ||
|
|
896fbbc146 | ||
|
|
bcb734a459 | ||
|
|
8e9e0f71bf | ||
|
|
647c9c5eb0 | ||
|
|
4fa92ed5f7 | ||
|
|
febcbac1de | ||
|
|
c9763c3d05 | ||
|
|
fab6d5df8d | ||
|
|
5d872bead7 | ||
|
|
60a3cc1f72 | ||
|
|
413df5a005 | ||
|
|
5b35612be0 | ||
|
|
54441df562 | ||
|
|
87f4b59cfe | ||
|
|
4d0839cf9c | ||
|
|
56388e46f2 | ||
|
|
6b20b7ecdb | ||
|
|
ee82547eed | ||
|
|
ebd9b30f55 | ||
|
|
5b70f70aa7 | ||
|
|
80ef6fcb04 | ||
|
|
700db14de2 | ||
|
|
433397cb3d | ||
|
|
40b952c4e8 | ||
|
|
b46b01e03d | ||
|
|
70b8a10e94 | ||
|
|
b40eaf7585 | ||
|
|
aeca645a37 | ||
|
|
713dbf47fb | ||
|
|
d6c7ccf62d | ||
|
|
52385ae980 | ||
|
|
53da61429a | ||
|
|
c8a87833c6 | ||
|
|
55c8b9012c | ||
|
|
0104d46206 | ||
|
|
b9963ce0bf | ||
|
|
09247cc30b | ||
|
|
b03b0c630b | ||
|
|
ebd076e0ed | ||
|
|
a0f34666a3 | ||
|
|
1ed71ea742 | ||
|
|
b75c221626 | ||
|
|
3cf340e44c | ||
|
|
e6c0bbf082 | ||
|
|
86ca234625 | ||
|
|
7bd86fe2b6 | ||
|
|
23356b3884 | ||
|
|
ca3d836c83 | ||
|
|
3aa835a985 | ||
|
|
7b9f2b6ce5 | ||
|
|
31a9b03c1a | ||
|
|
141436aebb | ||
|
|
8d84bffc2d | ||
|
|
0fb81a6112 | ||
|
|
6563a79483 | ||
|
|
372c6ac667 | ||
|
|
e4923a3c69 | ||
|
|
54f3e60ae4 | ||
|
|
df6f65e0aa | ||
|
|
e83fdc58ff | ||
|
|
7720482930 | ||
|
|
c07fae19f9 | ||
|
|
aa3e467a3e | ||
|
|
c837692d72 | ||
|
|
61c8b79e30 | ||
|
|
d0a8e6eb5b | ||
|
|
e61236836b | ||
|
|
a235b60bef | ||
|
|
a7d15ef287 | ||
|
|
045cec4421 | ||
|
|
465e49476a | ||
|
|
ed6a331faa | ||
|
|
f578e2c9e7 | ||
|
|
e0526508cb | ||
|
|
9151f44022 | ||
|
|
276de8a470 | ||
|
|
f6ce49b586 | ||
|
|
cf3d9d26fa | ||
|
|
265385c833 | ||
|
|
ca3e4e978d | ||
|
|
0dbfeed639 | ||
|
|
ca235e2287 | ||
|
|
9d826519e3 | ||
|
|
3979e12043 | ||
|
|
b3f1737495 | ||
|
|
179a710c5b | ||
|
|
08f347cd57 | ||
|
|
c910cbe5da | ||
|
|
34a2ab31df | ||
|
|
229a3b4284 | ||
|
|
dbc878950c | ||
|
|
ab4bcd3703 | ||
|
|
048e5eeb31 | ||
|
|
a526559a0e | ||
|
|
8dbd785ab8 | ||
|
|
0845e1cb7d | ||
|
|
20598d877d | ||
|
|
cf540bf173 | ||
|
|
a8fcde1459 | ||
|
|
bcdc562bf7 | ||
|
|
171f8c5848 | ||
|
|
58bb5eaeae | ||
|
|
fd629d6574 | ||
|
|
9bafd067f6 | ||
|
|
bc06afe17e | ||
|
|
250aa989c4 | ||
|
|
2e3317b95f | ||
|
|
c8be714d16 | ||
|
|
2f885d65cc | ||
|
|
f07c1f7164 | ||
|
|
ed86c26a18 | ||
|
|
ec787de5e0 | ||
|
|
0d5c09af84 | ||
|
|
ff32f96295 | ||
|
|
590591f6bd | ||
|
|
30f708ba7a | ||
|
|
2e3af087e8 | ||
|
|
6ce922e983 | ||
|
|
f63cff91bf | ||
|
|
b422ba6547 | ||
|
|
114d53befd | ||
|
|
076010c058 | ||
|
|
56a7793bf1 | ||
|
|
00c610045d | ||
|
|
4b0b2f46ef | ||
|
|
5a53cea90b | ||
|
|
07a3ff01b0 | ||
|
|
03875d7e41 | ||
|
|
0e340288e6 | ||
|
|
1183c40114 | ||
|
|
06ab9df6fc | ||
|
|
b871dab5fe | ||
|
|
054eecf541 | ||
|
|
348452ec7d | ||
|
|
1f5934d6e2 | ||
|
|
60fa6c775b | ||
|
|
ed98c01ba0 | ||
|
|
198c79c048 | ||
|
|
3cd331062d | ||
|
|
22f1e4db31 | ||
|
|
68693f20bb | ||
|
|
54a4c25152 | ||
|
|
21c615818c | ||
|
|
204d7e57bd | ||
|
|
cd151da240 | ||
|
|
687a62fe26 | ||
|
|
0bf0b762b8 | ||
|
|
53a6af7779 | ||
|
|
4c10f2b960 | ||
|
|
2630732b8a | ||
|
|
b8774a7af3 | ||
|
|
7a89df749d | ||
|
|
937c11e83c | ||
|
|
a79f7e3b59 | ||
|
|
c1b52524b1 | ||
|
|
04d451be8d | ||
|
|
e5109d6a0f | ||
|
|
c404354890 | ||
|
|
01fbe89295 | ||
|
|
388da769bb | ||
|
|
0d4f203fae | ||
|
|
96dbd633bf | ||
|
|
4b1f4ae319 | ||
|
|
13e15d0476 | ||
|
|
7c962c617a | ||
|
|
4e51f0abc4 | ||
|
|
3bd5ac21c9 | ||
|
|
d7b872eeaa | ||
|
|
c868a6374d | ||
|
|
e61720754a | ||
|
|
f9f0eaefbe | ||
|
|
5712739df1 | ||
|
|
6e7152a200 | ||
|
|
f2b8aab1d2 | ||
|
|
59f2e9cf72 | ||
|
|
3a0793b26a | ||
|
|
659df750d8 | ||
|
|
b5983f7e99 | ||
|
|
86d0d18b00 | ||
|
|
28f71963f1 | ||
|
|
27f91365b4 | ||
|
|
8d11fecfeb | ||
|
|
c10a955928 | ||
|
|
d5a12d56a6 | ||
|
|
f869ebbb30 | ||
|
|
3471c964d0 | ||
|
|
94b1934877 | ||
|
|
adfd3ab3ac | ||
|
|
a42008dd7b | ||
|
|
acfc976f6d | ||
|
|
76cfdef27d | ||
|
|
d75f33558d | ||
|
|
7345a558ce | ||
|
|
5ba93dda9f | ||
|
|
a94195ae45 | ||
|
|
0b8415e82b | ||
|
|
a5c37f1e4a | ||
|
|
7bd0b09711 | ||
|
|
64370229d8 | ||
|
|
6671c6d45c | ||
|
|
a2eedb3742 | ||
|
|
3bae5e236b | ||
|
|
9f4e950a70 | ||
|
|
4d2d9d4d6e | ||
|
|
61ffc8ada6 | ||
|
|
b8e36b0398 | ||
|
|
d89e4ec143 | ||
|
|
712b8d6e0c | ||
|
|
50cfb54a3d | ||
|
|
dcb1866e81 | ||
|
|
f2550a7861 | ||
|
|
5ed3d52e9a | ||
|
|
aadcb2cc5b | ||
|
|
96028e91be | ||
|
|
f92780d3da | ||
|
|
8c7e3b3731 | ||
|
|
8eb6b5a364 | ||
|
|
d03ca0ec36 | ||
|
|
c25f5598f1 | ||
|
|
d32611b2d5 | ||
|
|
9ab034c1ad | ||
|
|
b3edbecde2 | ||
|
|
3ce949f0aa | ||
|
|
df8c6abd5c | ||
|
|
b94561223e | ||
|
|
f633769f7b | ||
|
|
8767bad61e | ||
|
|
c01345468d | ||
|
|
8046d14d2d | ||
|
|
f957d8aeb5 | ||
|
|
564a387505 | ||
|
|
116fc0c70f | ||
|
|
f82e35a8a8 | ||
|
|
ea76647b29 | ||
|
|
26dc70c8fd | ||
|
|
85113d50be | ||
|
|
9e41cc27af | ||
|
|
89d8c11b52 | ||
|
|
70d16c31ad | ||
|
|
e07f243344 | ||
|
|
ba4a43b4aa | ||
|
|
860bf22503 | ||
|
|
4a1f009458 | ||
|
|
4830b3b2c1 | ||
|
|
e2bf13b5ca | ||
|
|
c36a4f64d4 | ||
|
|
39abea0290 | ||
|
|
abec47f6c3 | ||
|
|
4f0100b7a9 | ||
|
|
8c576953ad | ||
|
|
e8f9d2b608 | ||
|
|
2347267518 | ||
|
|
602f5b6646 | ||
|
|
b1b2e0ff09 | ||
|
|
ab38bfe4d2 | ||
|
|
dcb3f23078 | ||
|
|
c0f363cf86 | ||
|
|
46ebf3c07c | ||
|
|
ed7977a105 | ||
|
|
f093dbb30b | ||
|
|
620b69f234 | ||
|
|
a346b6ee29 | ||
|
|
ccb511936e | ||
|
|
9f98289952 | ||
|
|
e549b74c97 | ||
|
|
f73af50eb0 | ||
|
|
5f5346ed71 | ||
|
|
fc157b2944 | ||
|
|
cc1a537ecb | ||
|
|
1e5df66c62 | ||
|
|
e5ea82663e | ||
|
|
2d6e6f3ec9 | ||
|
|
a822c9f833 | ||
|
|
0b8b9cb280 | ||
|
|
29b8cf936e | ||
|
|
b288d6b0eb | ||
|
|
8a2d5b12c3 | ||
|
|
a7dc9e201f | ||
|
|
c686f16a93 | ||
|
|
58245d85b3 | ||
|
|
f564ef5195 | ||
|
|
18c24a7251 | ||
|
|
d97fd73ce5 | ||
|
|
1624abd9ed | ||
|
|
14f22009ed | ||
|
|
86cd3c0c38 | ||
|
|
855fe1235a | ||
|
|
198a0f7011 | ||
|
|
2b16d73e65 | ||
|
|
03f68426e5 | ||
|
|
229479b7ed | ||
|
|
0f742aa040 | ||
|
|
e5ac6a3a1d | ||
|
|
d05fb4472c | ||
|
|
5161971373 | ||
|
|
2a5841c631 | ||
|
|
766abd3336 | ||
|
|
b58cde5431 | ||
|
|
9964cf11a4 | ||
|
|
7f9c8fa133 | ||
|
|
10057f05a5 | ||
|
|
fc61b20f6d | ||
|
|
40e7f019dd | ||
|
|
2f32ddce6b | ||
|
|
459015c01e | ||
|
|
b669f96036 | ||
|
|
4524d1cfe3 | ||
|
|
651029e284 | ||
|
|
cbeb2675fd | ||
|
|
7a80caf26b | ||
|
|
f3eaf1dd4c | ||
|
|
af88e91a48 | ||
|
|
706cb47065 | ||
|
|
0d72aa9673 | ||
|
|
039e654ef1 | ||
|
|
1c3fe93d59 | ||
|
|
5ef45fd4a3 | ||
|
|
db700d6b80 | ||
|
|
7032bdc169 | ||
|
|
1dde09c738 | ||
|
|
a54ca0141a | ||
|
|
a553bfd142 | ||
|
|
ed01551ad4 | ||
|
|
91473332b4 | ||
|
|
890de05394 | ||
|
|
29445e4ffb | ||
|
|
098eac8bab | ||
|
|
e2ad5c60c6 | ||
|
|
34e2595a3d | ||
|
|
284222c2ee | ||
|
|
0b308cb5f2 | ||
|
|
22dc03f32c | ||
|
|
c2ff26b515 | ||
|
|
402351a6b7 | ||
|
|
562be457ec | ||
|
|
600e98cf47 | ||
|
|
bded065d42 | ||
|
|
a526007957 | ||
|
|
c0af49f336 | ||
|
|
ff6c0c26e0 | ||
|
|
a7af8d2195 | ||
|
|
f5871898bd | ||
|
|
df8f23cba3 | ||
|
|
d9bc23725b | ||
|
|
a68ab28f00 | ||
|
|
676c282f11 | ||
|
|
f99731e90b | ||
|
|
302ece8ffc | ||
|
|
47100a8e51 | ||
|
|
7e59d8cb75 | ||
|
|
7eaa00a5ad | ||
|
|
0713cc55b6 | ||
|
|
8329d68b22 | ||
|
|
3e05cf7306 | ||
|
|
8c116e1bc5 | ||
|
|
7d61986025 | ||
|
|
abff2a0a8f | ||
|
|
65499bb9ff | ||
|
|
6f219d1932 | ||
|
|
9d35048fb9 | ||
|
|
af58c30249 | ||
|
|
366744ed69 | ||
|
|
d809b77154 | ||
|
|
03cec69af3 | ||
|
|
9ae41b1645 | ||
|
|
b0f18a0419 | ||
|
|
5648a9197d | ||
|
|
f0fe8bf5c7 | ||
|
|
8a690afc46 | ||
|
|
2bb6c48278 | ||
|
|
6eb661df19 | ||
|
|
8e578e1058 | ||
|
|
4f7683b1fd | ||
|
|
656456b9d9 | ||
|
|
8c1daa9eed | ||
|
|
f146205208 | ||
|
|
dce3c333da | ||
|
|
b0d67f1637 | ||
|
|
bc913d0e9c | ||
|
|
415ef57458 | ||
|
|
278ddf27bd | ||
|
|
3566305c27 | ||
|
|
b41b03e8f0 | ||
|
|
e5642b59d7 | ||
|
|
e159de9a6a | ||
|
|
2a02e8a790 | ||
|
|
798c73394d | ||
|
|
7f48043505 | ||
|
|
82b49a9e51 | ||
|
|
56ea680e46 | ||
|
|
70f3d13626 | ||
|
|
093f34b7a8 | ||
|
|
63794cab07 | ||
|
|
ed17600f79 | ||
|
|
778af9f4e2 | ||
|
|
8c97754b64 | ||
|
|
2393344978 | ||
|
|
4c81a46af6 | ||
|
|
7df084dd3c | ||
|
|
08aa61a2bf | ||
|
|
a16ac479d5 | ||
|
|
483e7256f7 | ||
|
|
412b169e3a | ||
|
|
bfcd743efa | ||
|
|
f123c28540 | ||
|
|
56f9ce333c | ||
|
|
cd156d6991 | ||
|
|
c985683ee3 | ||
|
|
59ab0c9f0d | ||
|
|
a24b6711d1 | ||
|
|
7f7d7be646 | ||
|
|
2f2a02834b | ||
|
|
e2a3aa12a8 | ||
|
|
a4f70794a2 | ||
|
|
0ee3941b43 | ||
|
|
4e05ce4c35 | ||
|
|
c5fa48ca46 | ||
|
|
20e39b2e12 | ||
|
|
d28394c5d9 | ||
|
|
86fff1b61c | ||
|
|
71ef5abea5 | ||
|
|
6b83313ce8 | ||
|
|
2fe93656ee | ||
|
|
ec8003245f | ||
|
|
8f632cb57b | ||
|
|
d7b9129c33 | ||
|
|
82efe530ea | ||
|
|
b3805585a7 | ||
|
|
04b84fd0dc | ||
|
|
2ac405b2d0 | ||
|
|
eb8571a508 | ||
|
|
f7e75e9b8a | ||
|
|
0fd7dabbc1 | ||
|
|
9123454545 | ||
|
|
3141ec0406 | ||
|
|
4bf86500bd | ||
|
|
bee54146bf | ||
|
|
28698cc769 | ||
|
|
41f2339c8c | ||
|
|
ce34e097a2 | ||
|
|
fecc9f7659 | ||
|
|
139b3ffab4 | ||
|
|
febe60b3d1 | ||
|
|
fc519c41bc | ||
|
|
6e074d9b8b | ||
|
|
d89a4d8a54 | ||
|
|
a504617425 | ||
|
|
0c0fef6e84 | ||
|
|
1dfda62125 | ||
|
|
5e0c0e25f2 | ||
|
|
07220eb167 | ||
|
|
216a0a186c | ||
|
|
14df37712c | ||
|
|
ab5a146277 | ||
|
|
24a373abf4 | ||
|
|
ffca935ced | ||
|
|
d69934ca8f | ||
|
|
3081911eae | ||
|
|
67806cacdb | ||
|
|
8ee2f12217 | ||
|
|
c63721a15f | ||
|
|
9f80d729a2 | ||
|
|
d78d2f25eb | ||
|
|
229d4bfe6b | ||
|
|
8e638d1cff | ||
|
|
1b17d53d65 | ||
|
|
77d3410b4e | ||
|
|
6b279398b3 | ||
|
|
c34a00b3f3 | ||
|
|
ce3c1cccc3 | ||
|
|
00683ff1bc | ||
|
|
c2852e30bf | ||
|
|
44680a38b0 | ||
|
|
80a674baab | ||
|
|
ff85654cb9 | ||
|
|
56a122705d | ||
|
|
a48df9ac83 | ||
|
|
d4029775ec | ||
|
|
3dc1050929 | ||
|
|
c9a444b079 | ||
|
|
831267b2ab | ||
|
|
d8b807df50 | ||
|
|
879e24e7b1 | ||
|
|
a1e454d693 | ||
|
|
39f8f14aa1 | ||
|
|
d7fd1e333e | ||
|
|
76cd77cc73 | ||
|
|
ee3ef4b8cc | ||
|
|
5f9ba78d94 | ||
|
|
93628f4d36 | ||
|
|
ac2824dfdd | ||
|
|
9dd6a4430e | ||
|
|
f840de0b93 | ||
|
|
6b5e4d34d5 | ||
|
|
94f0b9f331 | ||
|
|
67b5a6c096 | ||
|
|
644796e466 | ||
|
|
d244ab1af9 | ||
|
|
f2683ae011 | ||
|
|
8844583807 | ||
|
|
c7bf6fc866 | ||
|
|
55c4465e5d | ||
|
|
f63054823b | ||
|
|
83f441340c | ||
|
|
e81865fce3 | ||
|
|
bceffbc874 | ||
|
|
c6e8a63f7c | ||
|
|
10c9118f49 | ||
|
|
cdf42e2a37 | ||
|
|
d4c26820fc | ||
|
|
87c134322d | ||
|
|
6d627be679 | ||
|
|
1191ec00db | ||
|
|
027c212546 | ||
|
|
be0f2f0b9f | ||
|
|
73c1452aa9 | ||
|
|
7a7f1e7d97 | ||
|
|
f60bacba85 | ||
|
|
d078764ae4 | ||
|
|
1558a41397 | ||
|
|
9fca946821 | ||
|
|
4f35b9f327 | ||
|
|
74d7183a10 | ||
|
|
3990f4b7af | ||
|
|
99342d615e | ||
|
|
0ad9380226 | ||
|
|
0453493a9e | ||
|
|
eb256fced6 | ||
|
|
ed0f04d644 | ||
|
|
1a17d5be39 | ||
|
|
0f33e9d48f | ||
|
|
5be8c8e2a7 | ||
|
|
66c1b881ef | ||
|
|
520206ad52 | ||
|
|
db00e22063 | ||
|
|
342626684b | ||
|
|
8df6356abf | ||
|
|
dfa60ec703 | ||
|
|
1e3fb073e0 | ||
|
|
cbf44a9069 | ||
|
|
54e6b5aa83 | ||
|
|
bd20500d39 | ||
|
|
d26331bd36 | ||
|
|
9d6d15635f | ||
|
|
3e372bb1d9 | ||
|
|
8f22b97905 | ||
|
|
6ecbaf554b | ||
|
|
74b9b0db10 | ||
|
|
4623ff9955 | ||
|
|
2a3651013c | ||
|
|
3fa5694bb8 | ||
|
|
839ba9d109 | ||
|
|
8dd315d7d6 | ||
|
|
9a4a2708c0 | ||
|
|
e93521f3ac | ||
|
|
71ce9eb004 | ||
|
|
1338dab5e7 | ||
|
|
7208f8ae35 | ||
|
|
490740721e | ||
|
|
9d9d1325bd | ||
|
|
a22e757502 | ||
|
|
6db2b3d434 | ||
|
|
e74bce197f | ||
|
|
bb6f4843b9 | ||
|
|
61dc1b6f33 | ||
|
|
700579e06a | ||
|
|
bff6c81ed2 | ||
|
|
c741d56b32 | ||
|
|
0219069766 | ||
|
|
d0a01d73c4 | ||
|
|
e7e21348eb | ||
|
|
e29b2066c2 | ||
|
|
fb0d31226a | ||
|
|
30d7d5d90e | ||
|
|
386c067e93 | ||
|
|
384854b353 | ||
|
|
5d63f54fe2 | ||
|
|
9db79c3142 | ||
|
|
f4b6a63514 | ||
|
|
1947d81c58 | ||
|
|
1169c5c5e2 | ||
|
|
ae7cd76d87 | ||
|
|
7b7076116e | ||
|
|
1b8ebe498a | ||
|
|
dc53bedff7 | ||
|
|
b9b8c1168f | ||
|
|
35d30fea9c | ||
|
|
f3b116cfce | ||
|
|
3bf6891e1c | ||
|
|
723d1cffe2 | ||
|
|
977c78412f | ||
|
|
a6a83286b9 | ||
|
|
43fc4c5f52 | ||
|
|
c26de3bdd2 | ||
|
|
65f54ed8f3 | ||
|
|
c2fc759b68 | ||
|
|
c41d766604 | ||
|
|
f76fd06055 | ||
|
|
3d5230228e | ||
|
|
07b93037b3 | ||
|
|
8cebd03298 | ||
|
|
a502594545 | ||
|
|
57cb325639 | ||
|
|
e0b71c316b | ||
|
|
ad76afe4f6 | ||
|
|
895762ff18 | ||
|
|
214dcc7e4c | ||
|
|
49b855f7fd | ||
|
|
62494e7943 | ||
|
|
d2fd858d18 | ||
|
|
749236bc8d | ||
|
|
d3daf8d61e | ||
|
|
d3051cb229 | ||
|
|
bb89c59b51 | ||
|
|
fbd46c683e | ||
|
|
d45a5e6c93 | ||
|
|
fbb8a0e543 | ||
|
|
4d5a50c026 | ||
|
|
b25d046528 | ||
|
|
142b7b9c0e | ||
|
|
e46958c23e | ||
|
|
c3d8d70b34 | ||
|
|
b302775c37 | ||
|
|
4b96558433 | ||
|
|
c3110a43da | ||
|
|
22b1bfd189 | ||
|
|
c0b7ef878a | ||
|
|
9234636422 | ||
|
|
886e9459a5 | ||
|
|
9d6979e3dd | ||
|
|
cea3f860f2 | ||
|
|
bc27ce8c56 | ||
|
|
c78c1bea7d | ||
|
|
7dcc76f217 | ||
|
|
4c38c7c67b | ||
|
|
fcf6863aaf | ||
|
|
e57251abf4 | ||
|
|
6e6dd60b46 | ||
|
|
8a91618f8d | ||
|
|
cd19e86141 | ||
|
|
1e2829ed8e | ||
|
|
981960fcb4 | ||
|
|
77658d19dd | ||
|
|
0264184442 | ||
|
|
eabda85b1e | ||
|
|
93856a3c57 | ||
|
|
7351d98590 | ||
|
|
7ad1458ad7 | ||
|
|
2cb61ea501 | ||
|
|
7c2ae7a91e | ||
|
|
5ae786516a | ||
|
|
a590cfd881 | ||
|
|
3b03fb7e8b | ||
|
|
d6564f7b7b | ||
|
|
fcdeaf3510 | ||
|
|
b3761c7088 | ||
|
|
2486faebe9 | ||
|
|
0c7a38a1ad | ||
|
|
bdfce234b0 | ||
|
|
c5e0ced4bd | ||
|
|
2aed0651b5 | ||
|
|
15089217f0 | ||
|
|
9dff2cca2b | ||
|
|
6eb401247e | ||
|
|
dc66163edd | ||
|
|
8d7972ed07 | ||
|
|
a40bbb34b3 | ||
|
|
ab2602b5d6 | ||
|
|
9123222830 | ||
|
|
b8994a7755 | ||
|
|
089bb9e076 | ||
|
|
5b3bb0fa80 | ||
|
|
fafee5f527 | ||
|
|
21d7eadee2 | ||
|
|
fe7a30c238 | ||
|
|
e769a10a95 | ||
|
|
24b5a3787e | ||
|
|
f227f19d9f | ||
|
|
8f95e4c55d | ||
|
|
da309a3d03 | ||
|
|
c2650df224 | ||
|
|
8bbbaab9bb | ||
|
|
67482858b9 | ||
|
|
a29487abcd | ||
|
|
b910a249cb | ||
|
|
20498efd2e | ||
|
|
4feddb61c5 | ||
|
|
012420c47d | ||
|
|
ff9d8865d1 | ||
|
|
3cda3b27e2 | ||
|
|
8363efd1f9 | ||
|
|
36b0167eac | ||
|
|
66b5523310 | ||
|
|
8f568d41ca | ||
|
|
1c07feb446 | ||
|
|
261156588f | ||
|
|
294cda7f33 | ||
|
|
995c43d832 | ||
|
|
d49743031f | ||
|
|
7017d33b87 | ||
|
|
fade9ae6f9 | ||
|
|
c5489a7c55 | ||
|
|
9c14bc24e2 | ||
|
|
fe66be673a | ||
|
|
fdea25051c | ||
|
|
c86673f3ec | ||
|
|
94c31ad747 | ||
|
|
633bc043da | ||
|
|
453709a117 | ||
|
|
83467ef2f2 | ||
|
|
9d409a7412 | ||
|
|
4b16d7c53d | ||
|
|
5e1306282a | ||
|
|
02ad8273eb | ||
|
|
74247c292f | ||
|
|
1286694efd | ||
|
|
69d63bc3ba | ||
|
|
bc4b841baa | ||
|
|
ba488b71eb | ||
|
|
117affb1d4 | ||
|
|
50ee1a11f6 | ||
|
|
74eddfa1fa | ||
|
|
758e1ff2ad | ||
|
|
e1f4cd7565 | ||
|
|
93a0338678 | ||
|
|
3d6bf713ee | ||
|
|
b63e8d60bb | ||
|
|
162e791dfd | ||
|
|
0f840ad082 | ||
|
|
6a158a173d | ||
|
|
f777abdeb1 | ||
|
|
bb841e66c7 | ||
|
|
74ed80aaef | ||
|
|
723696b971 | ||
|
|
858158d886 | ||
|
|
62fd701808 | ||
|
|
b207100074 | ||
|
|
5ad7439241 | ||
|
|
debbe89187 | ||
|
|
a654158bd4 | ||
|
|
0bb59f5505 | ||
|
|
6881d4479e | ||
|
|
7f3168cc55 | ||
|
|
14dd185717 | ||
|
|
edf6ece7cb | ||
|
|
3619427f60 | ||
|
|
bd779c8156 | ||
|
|
cf977a2bfa | ||
|
|
8a4999406b | ||
|
|
fd6f1fbbf0 | ||
|
|
9cf99314d1 | ||
|
|
fc7d8bb810 | ||
|
|
c1f0dedd09 | ||
|
|
3653469dda | ||
|
|
1e313f80a4 | ||
|
|
73f1f8aea0 | ||
|
|
78107b1212 | ||
|
|
3b56f4271e | ||
|
|
f3a55e6cee | ||
|
|
2f70ea074e | ||
|
|
88172dbc7c | ||
|
|
34eda509c2 | ||
|
|
c7eab7873e | ||
|
|
58c1880219 | ||
|
|
d73195ec36 | ||
|
|
427bcaa522 | ||
|
|
d55cc03edf | ||
|
|
1282009257 | ||
|
|
106f097b45 | ||
|
|
fafb7f5e49 | ||
|
|
e54c08e2d3 | ||
|
|
03a63d0119 | ||
|
|
e2b698f166 | ||
|
|
f14ac5928f | ||
|
|
cd65d4d4c5 | ||
|
|
7aa3cd5ba4 | ||
|
|
0fe17d5458 | ||
|
|
aaa3cc3d19 | ||
|
|
c80d1d3402 | ||
|
|
254b004587 | ||
|
|
d813d0b7c2 | ||
|
|
53909fdd8a | ||
|
|
0ba03be9a3 | ||
|
|
7aac446cf2 | ||
|
|
f2dcb108e8 | ||
|
|
c0e5d6dd68 | ||
|
|
0b966ed541 | ||
|
|
8219b51e47 | ||
|
|
9b102d1cf4 |
326
.ci/.env.ci
Normal file
326
.ci/.env.ci
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
# You can leave this on "local". If you change it to production most console commands will ask for extra confirmation.
|
||||||
|
# Never set it to "testing".
|
||||||
|
APP_ENV=local
|
||||||
|
|
||||||
|
# Set to true if you want to see debug information in error screens.
|
||||||
|
APP_DEBUG=false
|
||||||
|
|
||||||
|
# This should be your email address.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by using SITE_OWNER_FILE
|
||||||
|
SITE_OWNER=mail@example.com
|
||||||
|
|
||||||
|
# The encryption key for your sessions. Keep this very secure.
|
||||||
|
# If you generate a new one all existing attachments must be considered LOST.
|
||||||
|
# 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
|
||||||
|
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III will launch using this language (for new users and unauthenticated visitors)
|
||||||
|
# For a list of available languages: https://github.com/firefly-iii/firefly-iii/tree/main/resources/lang
|
||||||
|
#
|
||||||
|
# If text is still in English, remember that not everything may have been translated.
|
||||||
|
DEFAULT_LANGUAGE=en_US
|
||||||
|
|
||||||
|
# The locale defines how numbers are formatted.
|
||||||
|
# by default this value is the same as whatever the language is.
|
||||||
|
DEFAULT_LOCALE=equal
|
||||||
|
|
||||||
|
# Change this value to your preferred time zone.
|
||||||
|
# Example: Europe/Amsterdam
|
||||||
|
# For a list of supported time zones, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||||
|
TZ=Europe/Amsterdam
|
||||||
|
|
||||||
|
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
|
||||||
|
# Set it to ** and reverse proxies work just fine.
|
||||||
|
TRUSTED_PROXIES=
|
||||||
|
|
||||||
|
# The log channel defines where your log entries go to.
|
||||||
|
# Several other options exist. You can use 'single' for one big fat error log (not recommended).
|
||||||
|
# Also available are 'syslog', 'errorlog' and 'stdout' which will log to the system itself.
|
||||||
|
# A rotating log option is 'daily', creates 5 files that (surprise) rotate.
|
||||||
|
# Default setting 'stack' will log to 'daily' and to 'stdout' at the same time.
|
||||||
|
|
||||||
|
# - Docker + versions <= 4.8.1.8 and before: use "stdout"
|
||||||
|
# - Docker + versions > 4.8.1.8 : use "docker_out"
|
||||||
|
# - Docker + versions >= 5.1.1 : use "stack"
|
||||||
|
# - For everything else (als not Docker) : use 'stack'
|
||||||
|
|
||||||
|
LOG_CHANNEL=single
|
||||||
|
|
||||||
|
# Log level. You can set this from least severe to most severe:
|
||||||
|
# debug, info, notice, warning, error, critical, alert, emergency
|
||||||
|
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
|
||||||
|
# nothing will get logged, ever.
|
||||||
|
APP_LOG_LEVEL=info
|
||||||
|
|
||||||
|
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
||||||
|
# For other database types, please see the FAQ: https://docs.firefly-iii.org/support/faq
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
# Use "pgsql" for PostgreSQL
|
||||||
|
# Use "mysql" for MySQL and MariaDB.
|
||||||
|
# Use "sqlite" for SQLite.
|
||||||
|
DB_CONNECTION=sqlite_test
|
||||||
|
|
||||||
|
# MySQL supports SSL. You can configure it here.
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
MYSQL_USE_SSL=false
|
||||||
|
MYSQL_SSL_VERIFY_SERVER_CERT=true
|
||||||
|
# You need to set at least of these options
|
||||||
|
MYSQL_SSL_CAPATH=/etc/ssl/certs/
|
||||||
|
MYSQL_SSL_CA=
|
||||||
|
MYSQL_SSL_CERT=
|
||||||
|
MYSQL_SSL_KEY=
|
||||||
|
MYSQL_SSL_CIPHER=
|
||||||
|
|
||||||
|
# PostgreSQL supports SSL. You can configure it here.
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
PGSQL_SSL_MODE=prefer
|
||||||
|
PGSQL_SSL_ROOT_CERT=null
|
||||||
|
PGSQL_SSL_CERT=null
|
||||||
|
PGSQL_SSL_KEY=null
|
||||||
|
PGSQL_SSL_CRL_FILE=null
|
||||||
|
|
||||||
|
# If you're looking for performance improvements, you could install memcached.
|
||||||
|
CACHE_DRIVER=array
|
||||||
|
SESSION_DRIVER=array
|
||||||
|
|
||||||
|
# If you set either of these to 'redis', you might want to update these settings too
|
||||||
|
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
|
||||||
|
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
|
||||||
|
|
||||||
|
# can be tcp, unix or http
|
||||||
|
REDIS_SCHEME=tcp
|
||||||
|
|
||||||
|
# use only when using 'unix' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
|
REDIS_PATH=
|
||||||
|
|
||||||
|
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
|
||||||
|
REDIS_DB="0"
|
||||||
|
REDIS_CACHE_DB="1"
|
||||||
|
|
||||||
|
# Cookie settings. Should not be necessary to change these.
|
||||||
|
# If you use Docker or similar, you can set COOKIE_DOMAIN_FILE to set
|
||||||
|
# the value from a file instead of from an environment variable
|
||||||
|
COOKIE_PATH="/"
|
||||||
|
COOKIE_DOMAIN=
|
||||||
|
COOKIE_SECURE=false
|
||||||
|
|
||||||
|
# If you want Firefly III to mail you, update these settings
|
||||||
|
# For instructions, see: https://docs.firefly-iii.org/advanced-installation/email
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_HOST=null
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_FROM=changeme@example.com
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
|
||||||
|
# Other mail drivers:
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
MAILGUN_DOMAIN=
|
||||||
|
MAILGUN_SECRET=
|
||||||
|
|
||||||
|
|
||||||
|
# If you are on EU region in mailgun, use api.eu.mailgun.net, otherwise use api.mailgun.net
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
MAILGUN_ENDPOINT=api.mailgun.net
|
||||||
|
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
MANDRILL_SECRET=
|
||||||
|
SPARKPOST_SECRET=
|
||||||
|
|
||||||
|
|
||||||
|
# Firefly III can send you the following messages
|
||||||
|
SEND_REGISTRATION_MAIL=true
|
||||||
|
SEND_ERROR_MESSAGE=true
|
||||||
|
|
||||||
|
# These messages contain (sensitive) transaction information:
|
||||||
|
SEND_REPORT_JOURNALS=true
|
||||||
|
|
||||||
|
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
MAPBOX_API_KEY=
|
||||||
|
|
||||||
|
# The map will default to this location:
|
||||||
|
MAP_DEFAULT_LAT=51.983333
|
||||||
|
MAP_DEFAULT_LONG=5.916667
|
||||||
|
MAP_DEFAULT_ZOOM=6
|
||||||
|
|
||||||
|
# Firefly III currently supports two provider for live Currency Exchange Rates:
|
||||||
|
# "fixer", and "ratesapi".
|
||||||
|
# RatesApi.IO (see https://ratesapi.io) is a FREE and OPEN SOURCE live currency exchange rates,
|
||||||
|
# built compatible with Fixer.IO, based on data published by European Central Bank, and doesn't require API key.
|
||||||
|
CER_PROVIDER=ratesapi
|
||||||
|
|
||||||
|
# If you have select "fixer" as default currency exchange rates,
|
||||||
|
# set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
|
||||||
|
# Please note that this WILL ONLY WORK FOR PAID fixer.io accounts because they severely limited
|
||||||
|
# the free API up to the point where you might as well offer nothing.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
FIXER_API_KEY=
|
||||||
|
|
||||||
|
# Firefly III has two options for user authentication. "eloquent" is the default,
|
||||||
|
# and "ldap" for LDAP servers.
|
||||||
|
# For full instructions on these settings please visit:
|
||||||
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
LOGIN_PROVIDER=eloquent
|
||||||
|
|
||||||
|
#
|
||||||
|
# It's also possible to change the way users are authenticated. You could use Authelia for example.
|
||||||
|
# Authentication via the REMOTE_USER header is supported. Change the value below to "remote_user_guard".
|
||||||
|
#
|
||||||
|
# If you do this please read the documentation for instructions and warnings:
|
||||||
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
|
#
|
||||||
|
# This function is available in Firefly III v5.3.0 and higher.
|
||||||
|
AUTHENTICATION_GUARD=web
|
||||||
|
|
||||||
|
#
|
||||||
|
# Likewise, it's impossible to log out users who's authentication is handled by an external system.
|
||||||
|
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
|
||||||
|
# Setting this variable only works when AUTHENTICATION_GUARD != web
|
||||||
|
#
|
||||||
|
CUSTOM_LOGOUT_URI=
|
||||||
|
|
||||||
|
# LDAP connection configuration
|
||||||
|
# OpenLDAP, FreeIPA or ActiveDirectory
|
||||||
|
# # If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
ADLDAP_CONNECTION_SCHEME=OpenLDAP
|
||||||
|
ADLDAP_AUTO_CONNECT=true
|
||||||
|
|
||||||
|
# LDAP connection settings
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
# ADLDAP_CONTROLLERS, ADLDAP_PORT, ADLDAP_BASEDN
|
||||||
|
ADLDAP_CONTROLLERS=
|
||||||
|
ADLDAP_PORT=389
|
||||||
|
ADLDAP_TIMEOUT=5
|
||||||
|
ADLDAP_BASEDN=""
|
||||||
|
ADLDAP_FOLLOW_REFFERALS=false
|
||||||
|
|
||||||
|
# SSL/TLS settings
|
||||||
|
ADLDAP_USE_SSL=false
|
||||||
|
ADLDAP_USE_TLS=false
|
||||||
|
ADLDAP_SSL_CACERTDIR=
|
||||||
|
ADLDAP_SSL_CACERTFILE=
|
||||||
|
ADLDAP_SSL_CERTFILE=
|
||||||
|
ADLDAP_SSL_KEYFILE=
|
||||||
|
ADLDAP_SSL_CIPHER_SUITE=
|
||||||
|
ADLDAP_SSL_REQUIRE_CERT=
|
||||||
|
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
ADLDAP_ADMIN_USERNAME=
|
||||||
|
ADLDAP_ADMIN_PASSWORD=
|
||||||
|
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
ADLDAP_ACCOUNT_PREFIX=
|
||||||
|
ADLDAP_ACCOUNT_SUFFIX=
|
||||||
|
|
||||||
|
|
||||||
|
# LDAP authentication settings.
|
||||||
|
ADLDAP_PASSWORD_SYNC=false
|
||||||
|
ADLDAP_LOGIN_FALLBACK=false
|
||||||
|
|
||||||
|
ADLDAP_DISCOVER_FIELD=distinguishedname
|
||||||
|
ADLDAP_AUTH_FIELD=distinguishedname
|
||||||
|
|
||||||
|
# Will allow SSO if your server provides an AUTH_USER field.
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
WINDOWS_SSO_ENABLED=false
|
||||||
|
WINDOWS_SSO_DISCOVER=samaccountname
|
||||||
|
WINDOWS_SSO_KEY=AUTH_USER
|
||||||
|
|
||||||
|
# field to sync as local username.
|
||||||
|
# You can set the following variable from a file by appending it with _FILE:
|
||||||
|
ADLDAP_SYNC_FIELD=userprincipalname
|
||||||
|
|
||||||
|
# You can disable the X-Frame-Options header if it interferes with tools like
|
||||||
|
# Organizr. This is at your own risk. Applications running in frames run the risk
|
||||||
|
# of leaking information to their parent frame.
|
||||||
|
DISABLE_FRAME_HEADER=false
|
||||||
|
|
||||||
|
# You can disable the Content Security Policy header when you're using an ancient browser
|
||||||
|
# or any version of Microsoft Edge / Internet Explorer (which amounts to the same thing really)
|
||||||
|
# This leaves you with the risk of not being able to stop XSS bugs should they ever surface.
|
||||||
|
# This is at your own risk.
|
||||||
|
DISABLE_CSP_HEADER=false
|
||||||
|
|
||||||
|
# If you wish to track your own behavior over Firefly III, set valid analytics tracker information here.
|
||||||
|
# Nobody uses this except for me on the demo site. But hey, feel free to use this if you want to.
|
||||||
|
# Do not prepend the TRACKER_URL with http:// or https://
|
||||||
|
# The only tracker supported is Matomo.
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
TRACKER_SITE_ID=
|
||||||
|
TRACKER_URL=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
|
||||||
|
# In order to allow this, change the following variable to true.
|
||||||
|
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
|
||||||
|
SEND_TELEMETRY=false
|
||||||
|
|
||||||
|
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||||
|
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
|
||||||
|
# However if you know what you're doing you can significantly speed up container start times.
|
||||||
|
# Set each value to true to enable, or false to disable.
|
||||||
|
|
||||||
|
# Check if the SQLite database exists. Can be skipped if you're not using SQLite.
|
||||||
|
# Won't significantly speed up things.
|
||||||
|
DKR_CHECK_SQLITE=true
|
||||||
|
|
||||||
|
# Run database creation and migration commands. Disable this only if you're 100% sure the DB exists
|
||||||
|
# and is up to date.
|
||||||
|
DKR_RUN_MIGRATION=true
|
||||||
|
|
||||||
|
# Run database upgrade commands. Disable this only when you're 100% sure your DB is up-to-date
|
||||||
|
# with the latest fixes (outside of migrations!)
|
||||||
|
DKR_RUN_UPGRADE=true
|
||||||
|
|
||||||
|
# Verify database integrity. Includes all data checks and verifications.
|
||||||
|
# Disabling this makes Firefly III assume your DB is intact.
|
||||||
|
DKR_RUN_VERIFY=true
|
||||||
|
|
||||||
|
# Run database reporting commands. When disabled, Firefly III won't go over your data to report current state.
|
||||||
|
# Disabling this should have no impact on data integrity or safety but it won't warn you of possible issues.
|
||||||
|
DKR_RUN_REPORT=true
|
||||||
|
|
||||||
|
# Generate OAuth2 keys.
|
||||||
|
# When disabled, Firefly III won't attempt to generate OAuth2 Passport keys. This won't be an issue, IFF (if and only if)
|
||||||
|
# you had previously generated keys already and they're stored in your database for restoration.
|
||||||
|
DKR_RUN_PASSPORT_INSTALL=true
|
||||||
|
|
||||||
|
# Leave the following configuration vars as is.
|
||||||
|
# Unless you like to tinker and know what you're doing.
|
||||||
|
APP_NAME=FireflyIII
|
||||||
|
ADLDAP_CONNECTION=default
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
QUEUE_DRIVER=sync
|
||||||
|
CACHE_PREFIX=firefly
|
||||||
|
SEARCH_RESULT_LIMIT=50
|
||||||
|
PUSHER_KEY=
|
||||||
|
PUSHER_SECRET=
|
||||||
|
PUSHER_ID=
|
||||||
|
DEMO_USERNAME=
|
||||||
|
DEMO_PASSWORD=
|
||||||
|
USE_ENCRYPTION=false
|
||||||
|
IS_HEROKU=false
|
||||||
|
FIREFLY_III_LAYOUT=v1
|
||||||
|
|
||||||
|
#
|
||||||
|
# If you have trouble configuring your Firefly III installation, DON'T BOTHER setting this variable.
|
||||||
|
# It won't work. It doesn't do ANYTHING. Don't believe the lies you read online. I'm not joking.
|
||||||
|
# This configuration value WILL NOT HELP.
|
||||||
|
#
|
||||||
|
# This variable is ONLY used in some of the emails Firefly III sends around. Nowhere else.
|
||||||
|
# So when configuring anything WEB related this variable doesn't do anything. Nothing
|
||||||
|
#
|
||||||
|
# If you're stuck I understand you get desperate but look SOMEWHERE ELSE.
|
||||||
|
#
|
||||||
|
APP_URL=http://localhost
|
||||||
250
.ci/firefly-iii-standard.yml
Normal file
250
.ci/firefly-iii-standard.yml
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
parameters:
|
||||||
|
indentation: spaces
|
||||||
|
|
||||||
|
file_extensions:
|
||||||
|
- php
|
||||||
|
|
||||||
|
exclude_files:
|
||||||
|
- fixtures/*
|
||||||
|
- fixtures*/*
|
||||||
|
- temp/*
|
||||||
|
- tmp/*
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Checkers bellow aim on 1:1 copy of https://nette.org/en/coding-standard
|
||||||
|
|
||||||
|
# General rules - https://nette.org/en/coding-standard#toc-general-rules
|
||||||
|
|
||||||
|
# use tabs over spaces
|
||||||
|
# PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowSpaceIndentSniff: ~
|
||||||
|
# PHP code must use only UTF-8 without BOM
|
||||||
|
PhpCsFixer\Fixer\Basic\EncodingFixer: ~
|
||||||
|
# <?php opening tag
|
||||||
|
PhpCsFixer\Fixer\PhpTag\FullOpeningTagFixer: ~
|
||||||
|
# Ensure there is no code on the same line as the PHP open tag.
|
||||||
|
PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer: ~
|
||||||
|
# The closing ?> tag must be omitted from files containing only PHP.
|
||||||
|
PhpCsFixer\Fixer\PhpTag\NoClosingTagFixer: ~
|
||||||
|
# There must not be trailing whitespace at the end of lines.
|
||||||
|
PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer: ~
|
||||||
|
# ...and at the end of blank lines.
|
||||||
|
PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer: ~
|
||||||
|
# All files must end with a single blank line.
|
||||||
|
PhpCsFixer\Fixer\Whitespace\SingleBlankLineAtEofFixer: ~
|
||||||
|
# File name should match class name if possible.
|
||||||
|
PhpCsFixer\Fixer\Basic\Psr4Fixer: ~
|
||||||
|
# Enforces using shorthand scalar typehint variants in phpDocs: `int` instead of `integer` and `bool` instead of `boolean`
|
||||||
|
SlevomatCodingStandard\Sniffs\TypeHints\LongTypeHintsSniff: ~
|
||||||
|
|
||||||
|
# File Header - https://nette.org/en/coding-standard#toc-file-header
|
||||||
|
|
||||||
|
# empty line before namespace
|
||||||
|
PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer: ~
|
||||||
|
# 1 Use statement per line
|
||||||
|
PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer: ~
|
||||||
|
# Use statements are alphabetically ordered
|
||||||
|
PhpCsFixer\Fixer\Import\OrderedImportsFixer: ~
|
||||||
|
# disallow group use declarations use FooLibrary\Bar\Baz\{ ClassA, ClassB, ClassC, ClassD as Fizbo }
|
||||||
|
SlevomatCodingStandard\Sniffs\Namespaces\DisallowGroupUseSniff: ~
|
||||||
|
# Disallows leading backslash in use statement: use \Foo\Bar;
|
||||||
|
SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff: ~
|
||||||
|
# Looks for unused imports from other namespaces.
|
||||||
|
Nette\CodingStandard\Sniffs\Namespaces\UnusedUsesSniff:
|
||||||
|
searchAnnotations: yes
|
||||||
|
ignoredAnnotationNames: ['@testCase']
|
||||||
|
ignoredAnnotations: ['@internal']
|
||||||
|
|
||||||
|
# Language Construct (should be placed before some other fixers)
|
||||||
|
|
||||||
|
# Functions should be used with `$strict` param set to `true`
|
||||||
|
PhpCsFixer\Fixer\Strict\StrictParamFixer: ~
|
||||||
|
# replaces is_null(parameter) expression with `null === parameter`.
|
||||||
|
PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer:
|
||||||
|
use_yoda_style: true
|
||||||
|
# Calling `unset` on multiple items should be done in one call.
|
||||||
|
PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer: ~
|
||||||
|
# Replace all `<>` with `!=`.
|
||||||
|
PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer: ~
|
||||||
|
# Include/Require and file path should be divided with a single space. File path should not be placed under brackets.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\IncludeFixer: ~
|
||||||
|
# Requires short ternary operator ?: when possible
|
||||||
|
SlevomatCodingStandard\Sniffs\ControlStructures\RequireShortTernaryOperatorSniff: ~
|
||||||
|
|
||||||
|
# Arrays - https://nette.org/en/coding-standard#toc-arrays
|
||||||
|
|
||||||
|
# use short array fixes
|
||||||
|
PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer:
|
||||||
|
syntax: short
|
||||||
|
# use trailing command in last array element
|
||||||
|
PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer: ~
|
||||||
|
# PHP single-line arrays should not have trailing comma.
|
||||||
|
# PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer: ~
|
||||||
|
# In array declaration, there MUST NOT be a whitespace before each comma.
|
||||||
|
PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer: ~
|
||||||
|
# Arrays should be formatted like function/method arguments, without leading or trailing single line space.
|
||||||
|
PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer: ~
|
||||||
|
# In array declaration, there MUST be a whitespace after each comma.
|
||||||
|
PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer: ~
|
||||||
|
|
||||||
|
# Strings
|
||||||
|
|
||||||
|
# Convert `heredoc` to `nowdoc` where possible.
|
||||||
|
PhpCsFixer\Fixer\StringNotation\HeredocToNowdocFixer: ~
|
||||||
|
# Convert double quotes to single quotes for simple strings.
|
||||||
|
PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer: ~
|
||||||
|
|
||||||
|
# Keywords and True/False/Null - https://nette.org/en/coding-standard#toc-keywords-and-true-false-null
|
||||||
|
|
||||||
|
# PHP keywords must be in lower case
|
||||||
|
PhpCsFixer\Fixer\Casing\LowercaseKeywordsFixer: ~
|
||||||
|
# The PHP constants `true`, `false`, and `null` MUST be in lower case
|
||||||
|
PhpCsFixer\Fixer\Casing\LowercaseConstantsFixer: ~
|
||||||
|
|
||||||
|
# Method and Functions Calls - https://nette.org/en/coding-standard#toc-method-and-function-calls
|
||||||
|
|
||||||
|
# Function defined by PHP should be called using the correct casing
|
||||||
|
PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer: ~
|
||||||
|
# In the argument list, there must be one space after each comma, and there must no be a space before each comma
|
||||||
|
PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer: ~
|
||||||
|
# This sniff checks that there are two blank lines between functions declarations and single between signatures.
|
||||||
|
#Nette\CodingStandard\Sniffs\WhiteSpace\FunctionSpacingSniff: ~
|
||||||
|
|
||||||
|
# Classes - https://nette.org/en/coding-standard#toc-classes
|
||||||
|
|
||||||
|
# Inside a classy element "self" should be preferred to the class name itself.
|
||||||
|
PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer: ~
|
||||||
|
# class element order: constants, properties, from public to private
|
||||||
|
PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer:
|
||||||
|
order:
|
||||||
|
- use_trait
|
||||||
|
- constant
|
||||||
|
- constant_public
|
||||||
|
- constant_protected
|
||||||
|
- constant_private
|
||||||
|
- property_public
|
||||||
|
- property_protected
|
||||||
|
- property_private
|
||||||
|
|
||||||
|
# Constants - https://nette.org/en/coding-standard#toc-constants
|
||||||
|
|
||||||
|
# constant names are CAPITALIZED (manuall fixing only :()
|
||||||
|
PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff: ~
|
||||||
|
|
||||||
|
# Class Properties - https://nette.org/en/coding-standard#toc-class-properties
|
||||||
|
|
||||||
|
# There MUST NOT be more than one property declared per statement.
|
||||||
|
PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer:
|
||||||
|
elements: ['property']
|
||||||
|
|
||||||
|
# Methods - https://nette.org/en/coding-standard#toc-methods
|
||||||
|
|
||||||
|
# They must be declared in camelCase.
|
||||||
|
PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff: ~
|
||||||
|
# Checks that there's a single space between a typehint and a parameter name and no whitespace between a nullability symbol and a typehint
|
||||||
|
SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff: ~
|
||||||
|
# Spaces should be properly placed in a function declaration.
|
||||||
|
PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer: ~
|
||||||
|
# In function arguments there must not be arguments with default values before non-default ones.
|
||||||
|
PhpCsFixer\Fixer\FunctionNotation\NoUnreachableDefaultArgumentValueFixer: ~
|
||||||
|
|
||||||
|
# Constans, Class Properties, Methods
|
||||||
|
|
||||||
|
# Constants and Properties should be separated by 1 blank line
|
||||||
|
#PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer:
|
||||||
|
# elements: [const, property]
|
||||||
|
|
||||||
|
# Last property and 1st method should be separated by 2 spaces
|
||||||
|
Nette\CodingStandard\Fixer\ClassNotation\LastPropertyAndFirstMethodSeparationFixer:
|
||||||
|
space_count: 2
|
||||||
|
|
||||||
|
# Control Statements - https://nette.org/en/coding-standard#toc-control-statements
|
||||||
|
|
||||||
|
# The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\ElseifFixer: ~
|
||||||
|
# Remove useless semicolon statements.
|
||||||
|
PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer: ~
|
||||||
|
# Remove trailing commas in list() calls.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer: ~
|
||||||
|
# Removes unneeded parentheses around control statements.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer: ~
|
||||||
|
# A case should be followed by a colon and not a semicolon.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer: ~
|
||||||
|
# The structure body must be indented once.
|
||||||
|
# The closing brace must be on the next line after the body.
|
||||||
|
# There should not be more than one statement per line.
|
||||||
|
#Nette\CodingStandard\Fixer\Basic\BracesFixer:
|
||||||
|
# allow_single_line_closure: true
|
||||||
|
# changes if (1 === $cond) to if ($cond === 1)
|
||||||
|
#SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff: ~
|
||||||
|
# finds unreachable catch blocks:
|
||||||
|
SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff: ~
|
||||||
|
|
||||||
|
# Casting
|
||||||
|
|
||||||
|
# A single space or none should be between cast and variable (int) $val
|
||||||
|
PhpCsFixer\Fixer\CastNotation\CastSpacesFixer: ~
|
||||||
|
# Cast should be written in lower case.
|
||||||
|
PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer: ~
|
||||||
|
# Replaces `intval`, `floatval`, `doubleval`, `strval` and `boolval` function calls with according type casting operator
|
||||||
|
PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer: ~
|
||||||
|
# Short cast `bool` using double exclamation mark should not be used
|
||||||
|
PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer: ~
|
||||||
|
# Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`
|
||||||
|
PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer: ~
|
||||||
|
|
||||||
|
# Language Whitespace
|
||||||
|
|
||||||
|
# Binary operators should be surrounded by at least one space. DO NOT USE
|
||||||
|
#PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer: ~
|
||||||
|
# Unary operators should be placed adjacent to their operands.
|
||||||
|
PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: ~
|
||||||
|
# No space after the opening parenthesis and before the closing parenthesis
|
||||||
|
PhpCsFixer\Fixer\Whitespace\NoSpacesInsideParenthesisFixer: ~
|
||||||
|
# There MUST NOT be spaces around offset braces $a[0]
|
||||||
|
PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer: ~
|
||||||
|
# There should not be space before or after object `T_OBJECT_OPERATOR` `->`.
|
||||||
|
PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer: ~
|
||||||
|
# Standardize spaces around ternary operator.
|
||||||
|
PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer: ~
|
||||||
|
# Concatenation $a . $b should be spaced according configuration
|
||||||
|
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
|
||||||
|
spacing: one
|
||||||
|
# Removes extra spaces between colon and case value.
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\SwitchCaseSpaceFixer: ~
|
||||||
|
|
||||||
|
# Comments
|
||||||
|
|
||||||
|
# Docblocks should have the same indentation as the documented subject.
|
||||||
|
PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer: ~
|
||||||
|
# There should not be any empty comments.
|
||||||
|
PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer: ~
|
||||||
|
# There should not be empty PHPDoc blocks.
|
||||||
|
#PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer: ~
|
||||||
|
# Phpdocs should start and end with content, excluding the very first and last line of the docblocks.
|
||||||
|
PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer: ~
|
||||||
|
# Single-line comments comments with only one line of actual content should use the `//` syntax.
|
||||||
|
PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer:
|
||||||
|
comment_types: ['hash']
|
||||||
|
# Require comments with single-line content to be written as one-liners
|
||||||
|
SlevomatCodingStandard\Sniffs\Commenting\RequireOneLinePropertyDocCommentSniff: ~
|
||||||
|
|
||||||
|
|
||||||
|
# Properties MUST not be explicitly initialized with `null`.
|
||||||
|
#PhpCsFixer\Fixer\ClassNotation\NoNullPropertyInitializationFixer: ~
|
||||||
|
|
||||||
|
PhpCsFixer\Fixer\ControlStructure\NoBreakCommentFixer:
|
||||||
|
comment_text: 'break omitted'
|
||||||
|
|
||||||
|
# declare(strict_types=1);
|
||||||
|
PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer: ~
|
||||||
|
# Enforces consistent formatting of return typehints: function foo(): ?int
|
||||||
|
SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff: ~
|
||||||
|
# Use `null` coalescing operator `??` where possible.
|
||||||
|
PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer: ~
|
||||||
|
|
||||||
|
Nette\CodingStandard\Fixer\ClassNotation\ClassAndTraitVisibilityRequiredFixer:
|
||||||
|
elements: ['const', 'property', 'method']
|
||||||
|
|
||||||
|
# short list() syntax []
|
||||||
|
PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer:
|
||||||
|
syntax: short
|
||||||
33
.ci/phpstan.neon
Normal file
33
.ci/phpstan.neon
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
includes:
|
||||||
|
- ../vendor/nunomaduro/larastan/extension.neon
|
||||||
|
- ../vendor/ergebnis/phpstan-rules/rules.neon
|
||||||
|
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
|
||||||
|
- ../vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
- '#is not allowed to extend#'
|
||||||
|
- '#is neither abstract nor final#'
|
||||||
|
- '#Control structures using switch should not be used\.#'
|
||||||
|
- '#has a nullable return type declaration#'
|
||||||
|
- '#with a nullable type declaration#'
|
||||||
|
- '#with null as default value#'
|
||||||
|
- '#Constructor in [a-zA-Z0-9\\_]+ has parameter \$[a-zA-Z0-9\\_]+ with default value#'
|
||||||
|
-
|
||||||
|
message: '#Function compact\(\) should not be used.#'
|
||||||
|
paths:
|
||||||
|
- ../app/Http/Controllers
|
||||||
|
- ../app/Support/Http/Controllers/RenderPartialViews.php
|
||||||
|
- ../app/Support/Form/FormSupport.php
|
||||||
|
- ../app/Support/Form/CurrencyForm.php
|
||||||
|
- ../app/Support/Form/AccountForm.php
|
||||||
|
- ../app/Support/ExpandedForm.php
|
||||||
|
- ../app/Generator/Report
|
||||||
|
paths:
|
||||||
|
- ../app
|
||||||
|
- ../database
|
||||||
|
- ../routes
|
||||||
|
- ../bootstrap/app.php
|
||||||
|
|
||||||
|
# The level 8 is the highest level. original was 5
|
||||||
|
level: 2
|
||||||
33
.ci/phpstan.sh
Executable file
33
.ci/phpstan.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# phpstan.sh
|
||||||
|
# Copyright (c) 2021 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Install composer packages
|
||||||
|
#composer install --no-scripts --no-ansi
|
||||||
|
|
||||||
|
# enable test .env file.
|
||||||
|
cp .ci/.env.ci .env
|
||||||
|
|
||||||
|
# Do static code analysis.
|
||||||
|
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress
|
||||||
|
./vendor/bin/phpstan analyse -c .ci/phpstan.neon
|
||||||
|
|
||||||
|
exit 0
|
||||||
33
.ci/phpunit.sh
Executable file
33
.ci/phpunit.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# phpunit.sh
|
||||||
|
# Copyright (c) 2021 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# enable test .env file.
|
||||||
|
cp .ci/.env.ci ../.env
|
||||||
|
|
||||||
|
# download test database
|
||||||
|
# TODO no longer exists
|
||||||
|
wget --quiet https://raw.githubusercontent.com/firefly-iii/test-data/main/test_db.sqlite -o storage/database/test_db.sqlite
|
||||||
|
|
||||||
|
# run phpunit
|
||||||
|
./vendor/bin/phpunit --configuration phpunit.coverage.xml
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -5,77 +5,118 @@ APP_ENV=heroku
|
|||||||
# Set to true if you want to see debug information in error screens.
|
# Set to true if you want to see debug information in error screens.
|
||||||
APP_DEBUG=false
|
APP_DEBUG=false
|
||||||
|
|
||||||
# This should be your email address
|
# This should be your email address.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by using SITE_OWNER_FILE
|
||||||
SITE_OWNER=heroku@example.com
|
SITE_OWNER=heroku@example.com
|
||||||
|
|
||||||
# The encryption key for your database and sessions. Keep this very secure.
|
# The encryption key for your sessions. Keep this very secure.
|
||||||
# If you generate a new one all existing data must be considered LOST.
|
# If you generate a new one all existing attachments must be considered LOST.
|
||||||
# Change it to a string of exactly 32 chars or use command `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
|
||||||
APP_KEY=7ahyYVPVsmxjdhsweWCauGeJfwc92NP2
|
APP_KEY=7ahyYVPVsmxjdhsweWCauGeJfwc92NP2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III will launch using this language (for new users and unauthenticated visitors)
|
||||||
|
# For a list of available languages: https://github.com/firefly-iii/firefly-iii/tree/main/resources/lang
|
||||||
|
#
|
||||||
|
# If text is still in English, remember that not everything may have been translated.
|
||||||
|
DEFAULT_LANGUAGE=en_US
|
||||||
|
|
||||||
|
# The locale defines how numbers are formatted.
|
||||||
|
# by default this value is the same as whatever the language is.
|
||||||
|
DEFAULT_LOCALE=equal
|
||||||
|
|
||||||
# Change this value to your preferred time zone.
|
# Change this value to your preferred time zone.
|
||||||
# Example: Europe/Amsterdam
|
# Example: Europe/Amsterdam
|
||||||
|
# For a list of supported time zones, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||||
TZ=UTC
|
TZ=UTC
|
||||||
|
|
||||||
# This variable must match your installation's external address but keep in mind that
|
|
||||||
# it's only used on the command line as a fallback value.
|
|
||||||
APP_URL=http://localhost
|
|
||||||
|
|
||||||
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
|
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
|
||||||
|
# Set it to ** and reverse proxies work just fine.
|
||||||
TRUSTED_PROXIES=**
|
TRUSTED_PROXIES=**
|
||||||
|
|
||||||
# The log channel defines where your log entries go to.
|
# The log channel defines where your log entries go to.
|
||||||
# 'daily' is the default logging mode giving you 5 daily rotated log files in /storage/logs/.
|
|
||||||
# Several other options exist. You can use 'single' for one big fat error log (not recommended).
|
# Several other options exist. You can use 'single' for one big fat error log (not recommended).
|
||||||
# Also available are 'syslog', 'errorlog' and 'stdout' which will log to the system itself.
|
# Also available are 'syslog', 'errorlog' and 'stdout' which will log to the system itself.
|
||||||
|
# A rotating log option is 'daily', creates 5 files that (surprise) rotate.
|
||||||
|
# Default setting 'stack' will log to 'daily' and to 'stdout' at the same time.
|
||||||
|
|
||||||
|
# - Docker + versions <= 4.8.1.8 and before: use "stdout"
|
||||||
|
# - Docker + versions > 4.8.1.8 : use "docker_out"
|
||||||
|
# - Docker + versions >= 5.1.1 : use "stack"
|
||||||
|
# - For everything else (als not Docker) : use 'stack'
|
||||||
|
|
||||||
LOG_CHANNEL=stdout
|
LOG_CHANNEL=stdout
|
||||||
|
|
||||||
# Log level. You can set this from least severe to most severe:
|
# Log level. You can set this from least severe to most severe:
|
||||||
# debug, info, notice, warning, error, critical, alert, emergency
|
# debug, info, notice, warning, error, critical, alert, emergency
|
||||||
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
|
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
|
||||||
# nothing will get logged, ever.
|
# nothing will get logged, ever.
|
||||||
APP_LOG_LEVEL=debug
|
APP_LOG_LEVEL=notice
|
||||||
|
|
||||||
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
||||||
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
|
# For other database types, please see the FAQ: https://docs.firefly-iii.org/support/faq
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
# Use "pgsql" for PostgreSQL
|
||||||
|
# Use "mysql" for MySQL and MariaDB.
|
||||||
|
# Use "sqlite" for SQLite.
|
||||||
DB_CONNECTION=pgsql
|
DB_CONNECTION=pgsql
|
||||||
|
|
||||||
|
|
||||||
|
# MySQL supports SSL. You can configure it here.
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
|
MYSQL_USE_SSL=false
|
||||||
|
MYSQL_SSL_VERIFY_SERVER_CERT=true
|
||||||
|
# You need to set at least of these options
|
||||||
|
MYSQL_SSL_CAPATH=/etc/ssl/certs/
|
||||||
|
MYSQL_SSL_CA=
|
||||||
|
MYSQL_SSL_CERT=
|
||||||
|
MYSQL_SSL_KEY=
|
||||||
|
MYSQL_SSL_CIPHER=
|
||||||
|
|
||||||
# PostgreSQL supports SSL. You can configure it here.
|
# PostgreSQL supports SSL. You can configure it here.
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
PGSQL_SSL_MODE=prefer
|
PGSQL_SSL_MODE=prefer
|
||||||
PGSQL_SSL_ROOT_CERT=null
|
PGSQL_SSL_ROOT_CERT=null
|
||||||
PGSQL_SSL_CERT=null
|
PGSQL_SSL_CERT=null
|
||||||
PGSQL_SSL_KEY=null
|
PGSQL_SSL_KEY=null
|
||||||
PGSQL_SSL_CRL_FILE=null
|
PGSQL_SSL_CRL_FILE=null
|
||||||
|
|
||||||
|
|
||||||
# If you're looking for performance improvements, you could install memcached.
|
# If you're looking for performance improvements, you could install memcached.
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
|
|
||||||
# You can configure another file storage backend if you cannot use the local storage option.
|
# If you set either of these to 'redis', you might want to update these settings too
|
||||||
# To set this up, fill in the following variables. The upload path is used to store uploaded
|
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
|
||||||
# files and the export path is to store exported data (before download).
|
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
|
||||||
SFTP_HOST=
|
|
||||||
SFTP_PORT=
|
|
||||||
SFTP_UPLOAD_PATH=
|
|
||||||
SFTP_EXPORT_PATH=
|
|
||||||
|
|
||||||
# SFTP uses either the username/password combination or the private key to authenticate.
|
# can be tcp, unix or http
|
||||||
SFTP_USERNAME=
|
REDIS_SCHEME=tcp
|
||||||
SFTP_PASSWORD=
|
|
||||||
SFTP_PRIV_KEY=
|
# use only when using 'unix' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
|
REDIS_PATH=
|
||||||
|
|
||||||
|
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
|
||||||
|
REDIS_DB="0"
|
||||||
|
REDIS_CACHE_DB="1"
|
||||||
|
|
||||||
# Cookie settings. Should not be necessary to change these.
|
# Cookie settings. Should not be necessary to change these.
|
||||||
|
# If you use Docker or similar, you can set COOKIE_DOMAIN_FILE to set
|
||||||
|
# the value from a file instead of from an environment variable
|
||||||
COOKIE_PATH="/"
|
COOKIE_PATH="/"
|
||||||
COOKIE_DOMAIN=
|
COOKIE_DOMAIN=
|
||||||
COOKIE_SECURE=false
|
COOKIE_SECURE=false
|
||||||
|
|
||||||
# If you want Firefly III to mail you, update these settings
|
# If you want Firefly III to mail you, update these settings
|
||||||
# For instructions, see: https://firefly-iii.readthedocs.io/en/latest/installation/mail.html
|
# For instructions, see: https://docs.firefly-iii.org/advanced-installation/email
|
||||||
MAIL_DRIVER=log
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
MAIL_HOST=smtp.mailtrap.io
|
MAIL_MAILER=log
|
||||||
|
MAIL_HOST=null
|
||||||
MAIL_PORT=2525
|
MAIL_PORT=2525
|
||||||
MAIL_FROM=changeme@example.com
|
MAIL_FROM=changeme@example.com
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
@@ -83,11 +124,20 @@ MAIL_PASSWORD=null
|
|||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
|
|
||||||
# Other mail drivers:
|
# Other mail drivers:
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
MAILGUN_DOMAIN=
|
MAILGUN_DOMAIN=
|
||||||
MAILGUN_SECRET=
|
MAILGUN_SECRET=
|
||||||
|
|
||||||
|
|
||||||
|
# If you are on EU region in mailgun, use api.eu.mailgun.net, otherwise use api.mailgun.net
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
MAILGUN_ENDPOINT=api.mailgun.net
|
||||||
|
|
||||||
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
MANDRILL_SECRET=
|
MANDRILL_SECRET=
|
||||||
SPARKPOST_SECRET=
|
SPARKPOST_SECRET=
|
||||||
|
|
||||||
|
|
||||||
# Firefly III can send you the following messages
|
# Firefly III can send you the following messages
|
||||||
SEND_REGISTRATION_MAIL=true
|
SEND_REGISTRATION_MAIL=true
|
||||||
SEND_ERROR_MESSAGE=true
|
SEND_ERROR_MESSAGE=true
|
||||||
@@ -96,53 +146,85 @@ SEND_ERROR_MESSAGE=true
|
|||||||
SEND_REPORT_JOURNALS=true
|
SEND_REPORT_JOURNALS=true
|
||||||
|
|
||||||
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
|
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
MAPBOX_API_KEY=
|
MAPBOX_API_KEY=
|
||||||
|
|
||||||
|
# The map will default to this location:
|
||||||
|
MAP_DEFAULT_LAT=51.983333
|
||||||
|
MAP_DEFAULT_LONG=5.916667
|
||||||
|
MAP_DEFAULT_ZOOM=6
|
||||||
|
|
||||||
# Firefly III currently supports two provider for live Currency Exchange Rates:
|
# Firefly III currently supports two provider for live Currency Exchange Rates:
|
||||||
# "fixer" is the default (for backward compatibility), and "ratesapi" is the new one.
|
# "fixer", and "ratesapi".
|
||||||
# RatesApi.IO (see https://ratesapi.io) is a FREE and OPEN SOURCE live currency exchange rates,
|
# RatesApi.IO (see https://ratesapi.io) is a FREE and OPEN SOURCE live currency exchange rates,
|
||||||
# built compatible with Fixer.IO, based on data published by European Central Bank, and don't require API key.
|
# built compatible with Fixer.IO, based on data published by European Central Bank, and doesn't require API key.
|
||||||
CER_PROVIDER=fixer
|
CER_PROVIDER=ratesapi
|
||||||
|
|
||||||
# If you have select "fixer" as default currency exchange rates,
|
# If you have select "fixer" as default currency exchange rates,
|
||||||
# set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
|
# set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
|
||||||
# Please note that this WILL ONLY WORK FOR PAID fixer.io accounts because they severely limited
|
# Please note that this WILL ONLY WORK FOR PAID fixer.io accounts because they severely limited
|
||||||
# the free API up to the point where you might as well offer nothing.
|
# the free API up to the point where you might as well offer nothing.
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
FIXER_API_KEY=
|
FIXER_API_KEY=
|
||||||
|
|
||||||
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
|
|
||||||
TRACKER_SITE_ID=
|
|
||||||
TRACKER_URL=
|
|
||||||
|
|
||||||
# Most parts of the database are encrypted by default, but you can turn this off if you want to.
|
|
||||||
# This makes it easier to migrate your database. Not that some fields will never be decrypted.
|
|
||||||
USE_ENCRYPTION=true
|
|
||||||
|
|
||||||
# Firefly III has two options for user authentication. "eloquent" is the default,
|
# Firefly III has two options for user authentication. "eloquent" is the default,
|
||||||
# and "ldap" for LDAP servers.
|
# and "ldap" for LDAP servers.
|
||||||
# For full instructions on these settings please visit:
|
# For full instructions on these settings please visit:
|
||||||
# https://firefly-iii.readthedocs.io/en/latest/installation/authentication.html
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
LOGIN_PROVIDER=eloquent
|
LOGIN_PROVIDER=eloquent
|
||||||
|
|
||||||
|
#
|
||||||
|
# It's also possible to change the way users are authenticated. You could use Authelia for example.
|
||||||
|
# Authentication via the REMOTE_USER header is supported. Change the value below to "remote_user_guard".
|
||||||
|
#
|
||||||
|
# If you do this please read the documentation for instructions and warnings:
|
||||||
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
|
#
|
||||||
|
# This function is available in Firefly III v5.3.0 and higher.
|
||||||
|
AUTHENTICATION_GUARD=web
|
||||||
|
|
||||||
|
#
|
||||||
|
# Likewise, it's impossible to log out users who's authentication is handled by an external system.
|
||||||
|
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
|
||||||
|
# Setting this variable only works when AUTHENTICATION_GUARD != web
|
||||||
|
#
|
||||||
|
CUSTOM_LOGOUT_URI=
|
||||||
|
|
||||||
# LDAP connection configuration
|
# LDAP connection configuration
|
||||||
# OpenLDAP, FreeIPA or ActiveDirectory
|
# OpenLDAP, FreeIPA or ActiveDirectory
|
||||||
|
# # If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
ADLDAP_CONNECTION_SCHEME=OpenLDAP
|
ADLDAP_CONNECTION_SCHEME=OpenLDAP
|
||||||
ADLDAP_AUTO_CONNECT=true
|
ADLDAP_AUTO_CONNECT=true
|
||||||
|
|
||||||
# LDAP connection settings
|
# LDAP connection settings
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
# ADLDAP_CONTROLLERS, ADLDAP_PORT, ADLDAP_BASEDN
|
||||||
ADLDAP_CONTROLLERS=
|
ADLDAP_CONTROLLERS=
|
||||||
ADLDAP_PORT=389
|
ADLDAP_PORT=389
|
||||||
ADLDAP_TIMEOUT=5
|
ADLDAP_TIMEOUT=5
|
||||||
ADLDAP_BASEDN=""
|
ADLDAP_BASEDN=""
|
||||||
ADLDAP_FOLLOW_REFFERALS=false
|
ADLDAP_FOLLOW_REFFERALS=false
|
||||||
|
|
||||||
|
# SSL/TLS settings
|
||||||
ADLDAP_USE_SSL=false
|
ADLDAP_USE_SSL=false
|
||||||
ADLDAP_USE_TLS=false
|
ADLDAP_USE_TLS=false
|
||||||
|
ADLDAP_SSL_CACERTDIR=
|
||||||
|
ADLDAP_SSL_CACERTFILE=
|
||||||
|
ADLDAP_SSL_CERTFILE=
|
||||||
|
ADLDAP_SSL_KEYFILE=
|
||||||
|
ADLDAP_SSL_CIPHER_SUITE=
|
||||||
|
ADLDAP_SSL_REQUIRE_CERT=
|
||||||
|
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
ADLDAP_ADMIN_USERNAME=
|
ADLDAP_ADMIN_USERNAME=
|
||||||
ADLDAP_ADMIN_PASSWORD=
|
ADLDAP_ADMIN_PASSWORD=
|
||||||
|
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
ADLDAP_ACCOUNT_PREFIX=
|
ADLDAP_ACCOUNT_PREFIX=
|
||||||
ADLDAP_ACCOUNT_SUFFIX=
|
ADLDAP_ACCOUNT_SUFFIX=
|
||||||
|
|
||||||
|
|
||||||
# LDAP authentication settings.
|
# LDAP authentication settings.
|
||||||
ADLDAP_PASSWORD_SYNC=false
|
ADLDAP_PASSWORD_SYNC=false
|
||||||
ADLDAP_LOGIN_FALLBACK=false
|
ADLDAP_LOGIN_FALLBACK=false
|
||||||
@@ -151,25 +233,76 @@ ADLDAP_DISCOVER_FIELD=distinguishedname
|
|||||||
ADLDAP_AUTH_FIELD=distinguishedname
|
ADLDAP_AUTH_FIELD=distinguishedname
|
||||||
|
|
||||||
# Will allow SSO if your server provides an AUTH_USER field.
|
# Will allow SSO if your server provides an AUTH_USER field.
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
WINDOWS_SSO_ENABLED=false
|
||||||
WINDOWS_SSO_DISCOVER=samaccountname
|
WINDOWS_SSO_DISCOVER=samaccountname
|
||||||
WINDOWS_SSO_KEY=AUTH_USER
|
WINDOWS_SSO_KEY=AUTH_USER
|
||||||
|
|
||||||
# field to sync as local username.
|
# field to sync as local username.
|
||||||
|
# You can set the following variable from a file by appending it with _FILE:
|
||||||
ADLDAP_SYNC_FIELD=userprincipalname
|
ADLDAP_SYNC_FIELD=userprincipalname
|
||||||
|
|
||||||
# You can disable the X-Frame-Options header if it interfears with tools like
|
# You can disable the X-Frame-Options header if it interferes with tools like
|
||||||
# Organizr. This is at your own risk.
|
# Organizr. This is at your own risk. Applications running in frames run the risk
|
||||||
|
# of leaking information to their parent frame.
|
||||||
DISABLE_FRAME_HEADER=false
|
DISABLE_FRAME_HEADER=false
|
||||||
|
|
||||||
|
# You can disable the Content Security Policy header when you're using an ancient browser
|
||||||
|
# or any version of Microsoft Edge / Internet Explorer (which amounts to the same thing really)
|
||||||
|
# This leaves you with the risk of not being able to stop XSS bugs should they ever surface.
|
||||||
|
# This is at your own risk.
|
||||||
|
DISABLE_CSP_HEADER=false
|
||||||
|
|
||||||
|
# If you wish to track your own behavior over Firefly III, set valid analytics tracker information here.
|
||||||
|
# Nobody uses this except for me on the demo site. But hey, feel free to use this if you want to.
|
||||||
|
# Do not prepend the TRACKER_URL with http:// or https://
|
||||||
|
# The only tracker supported is Matomo.
|
||||||
|
# You can set the following variables from a file by appending them with _FILE:
|
||||||
|
TRACKER_SITE_ID=
|
||||||
|
TRACKER_URL=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
|
||||||
|
# In order to allow this, change the following variable to true.
|
||||||
|
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
|
||||||
|
SEND_TELEMETRY=false
|
||||||
|
|
||||||
|
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||||
|
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
|
||||||
|
# However if you know what you're doing you can significantly speed up container start times.
|
||||||
|
# Set each value to true to enable, or false to disable.
|
||||||
|
|
||||||
|
# Check if the SQLite database exists. Can be skipped if you're not using SQLite.
|
||||||
|
# Won't significantly speed up things.
|
||||||
|
DKR_CHECK_SQLITE=true
|
||||||
|
|
||||||
|
# Run database creation and migration commands. Disable this only if you're 100% sure the DB exists
|
||||||
|
# and is up to date.
|
||||||
|
DKR_RUN_MIGRATION=true
|
||||||
|
|
||||||
|
# Run database upgrade commands. Disable this only when you're 100% sure your DB is up-to-date
|
||||||
|
# with the latest fixes (outside of migrations!)
|
||||||
|
DKR_RUN_UPGRADE=true
|
||||||
|
|
||||||
|
# Verify database integrity. Includes all data checks and verifications.
|
||||||
|
# Disabling this makes Firefly III assume your DB is intact.
|
||||||
|
DKR_RUN_VERIFY=true
|
||||||
|
|
||||||
|
# Run database reporting commands. When disabled, Firefly III won't go over your data to report current state.
|
||||||
|
# Disabling this should have no impact on data integrity or safety but it won't warn you of possible issues.
|
||||||
|
DKR_RUN_REPORT=true
|
||||||
|
|
||||||
|
# Generate OAuth2 keys.
|
||||||
|
# When disabled, Firefly III won't attempt to generate OAuth2 Passport keys. This won't be an issue, IFF (if and only if)
|
||||||
|
# you had previously generated keys already and they're stored in your database for restoration.
|
||||||
|
DKR_RUN_PASSPORT_INSTALL=true
|
||||||
|
|
||||||
# Leave the following configuration vars as is.
|
# Leave the following configuration vars as is.
|
||||||
# Unless you like to tinker and know what you're doing.
|
# Unless you like to tinker and know what you're doing.
|
||||||
APP_NAME=FireflyIII
|
APP_NAME=FireflyIII
|
||||||
ADLDAP_CONNECTION=default
|
ADLDAP_CONNECTION=default
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
REDIS_HOST=127.0.0.1
|
|
||||||
REDIS_PASSWORD=null
|
|
||||||
REDIS_PORT=6379
|
|
||||||
CACHE_PREFIX=firefly
|
CACHE_PREFIX=firefly
|
||||||
SEARCH_RESULT_LIMIT=50
|
SEARCH_RESULT_LIMIT=50
|
||||||
PUSHER_KEY=
|
PUSHER_KEY=
|
||||||
@@ -177,7 +310,18 @@ PUSHER_SECRET=
|
|||||||
PUSHER_ID=
|
PUSHER_ID=
|
||||||
DEMO_USERNAME=
|
DEMO_USERNAME=
|
||||||
DEMO_PASSWORD=
|
DEMO_PASSWORD=
|
||||||
IS_SANDSTORM=false
|
USE_ENCRYPTION=false
|
||||||
IS_HEROKU=true
|
IS_HEROKU=false
|
||||||
BUNQ_USE_SANDBOX=false
|
FIREFLY_III_LAYOUT=v1
|
||||||
FFIII_LAYOUT=v1
|
|
||||||
|
#
|
||||||
|
# If you have trouble configuring your Firefly III installation, DON'T BOTHER setting this variable.
|
||||||
|
# It won't work. It doesn't do ANYTHING. Don't believe the lies you read online. I'm not joking.
|
||||||
|
# This configuration value WILL NOT HELP.
|
||||||
|
#
|
||||||
|
# This variable is ONLY used in some of the emails Firefly III sends around. Nowhere else.
|
||||||
|
# So when configuring anything WEB related this variable doesn't do anything. Nothing
|
||||||
|
#
|
||||||
|
# If you're stuck I understand you get desperate but look SOMEWHERE ELSE.
|
||||||
|
#
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
en_US
|
bg_BG
|
||||||
cs_CZ
|
cs_CZ
|
||||||
es_ES
|
|
||||||
de_DE
|
de_DE
|
||||||
|
el_GR
|
||||||
|
en_GB
|
||||||
|
en_US
|
||||||
|
es_ES
|
||||||
|
fi_FI
|
||||||
fr_FR
|
fr_FR
|
||||||
|
hu_HU
|
||||||
it_IT
|
it_IT
|
||||||
nb_NO
|
nb_NO
|
||||||
nl_NL
|
nl_NL
|
||||||
pl_PL
|
pl_PL
|
||||||
pt_BR
|
pt_BR
|
||||||
|
pt_PT
|
||||||
ro_RO
|
ro_RO
|
||||||
ru_RU
|
ru_RU
|
||||||
hu_HU
|
sk_SK
|
||||||
el_GR
|
|
||||||
sv_SE
|
sv_SE
|
||||||
|
vi_VN
|
||||||
zh-hans_CN
|
zh-hans_CN
|
||||||
zh-hant_CN
|
zh-hant_CN
|
||||||
fi_FI
|
|
||||||
vi_VN
|
|
||||||
|
|||||||
85
.env.example
85
.env.example
@@ -10,12 +10,10 @@ APP_DEBUG=false
|
|||||||
SITE_OWNER=mail@example.com
|
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.
|
||||||
# If you generate a new one all existing attachments must be considered LOST.
|
|
||||||
# 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
|
||||||
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)
|
||||||
# For a list of available languages: https://github.com/firefly-iii/firefly-iii/tree/main/resources/lang
|
# For a list of available languages: https://github.com/firefly-iii/firefly-iii/tree/main/resources/lang
|
||||||
#
|
#
|
||||||
@@ -54,6 +52,11 @@ LOG_CHANNEL=stack
|
|||||||
# nothing will get logged, ever.
|
# nothing will get logged, ever.
|
||||||
APP_LOG_LEVEL=notice
|
APP_LOG_LEVEL=notice
|
||||||
|
|
||||||
|
# Audit log level.
|
||||||
|
# set to "emergency" if you dont want to store audit logs.
|
||||||
|
# leave on info otherwise.
|
||||||
|
AUDIT_LOG_LEVEL=info
|
||||||
|
|
||||||
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
||||||
# For other database types, please see the FAQ: https://docs.firefly-iii.org/support/faq
|
# For other database types, please see the FAQ: https://docs.firefly-iii.org/support/faq
|
||||||
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||||
@@ -93,9 +96,18 @@ SESSION_DRIVER=file
|
|||||||
# If you set either of these to 'redis', you might want to update these settings too
|
# If you set either of these to 'redis', you might want to update these settings too
|
||||||
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
|
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
|
||||||
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
|
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
|
||||||
|
|
||||||
|
# can be tcp, unix or http
|
||||||
|
REDIS_SCHEME=tcp
|
||||||
|
|
||||||
|
# use only when using 'unix' for REDIS_SCHEME. Leave empty otherwise.
|
||||||
|
REDIS_PATH=
|
||||||
|
|
||||||
|
# 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_PASSWORD=null
|
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
REDIS_PASSWORD=null
|
||||||
# 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"
|
||||||
REDIS_CACHE_DB="1"
|
REDIS_CACHE_DB="1"
|
||||||
@@ -106,6 +118,7 @@ REDIS_CACHE_DB="1"
|
|||||||
COOKIE_PATH="/"
|
COOKIE_PATH="/"
|
||||||
COOKIE_DOMAIN=
|
COOKIE_DOMAIN=
|
||||||
COOKIE_SECURE=false
|
COOKIE_SECURE=false
|
||||||
|
COOKIE_SAMESITE=lax
|
||||||
|
|
||||||
# If you want Firefly III to mail you, update these settings
|
# If you want Firefly III to mail you, update these settings
|
||||||
# For instructions, see: https://docs.firefly-iii.org/advanced-installation/email
|
# For instructions, see: https://docs.firefly-iii.org/advanced-installation/email
|
||||||
@@ -132,36 +145,31 @@ MAILGUN_ENDPOINT=api.mailgun.net
|
|||||||
MANDRILL_SECRET=
|
MANDRILL_SECRET=
|
||||||
SPARKPOST_SECRET=
|
SPARKPOST_SECRET=
|
||||||
|
|
||||||
|
|
||||||
# Firefly III can send you the following messages
|
# Firefly III can send you the following messages
|
||||||
SEND_REGISTRATION_MAIL=true
|
SEND_REGISTRATION_MAIL=true
|
||||||
SEND_ERROR_MESSAGE=true
|
SEND_ERROR_MESSAGE=true
|
||||||
|
SEND_LOGIN_NEW_IP_WARNING=true
|
||||||
|
|
||||||
# These messages contain (sensitive) transaction information:
|
# These messages contain (sensitive) transaction information:
|
||||||
SEND_REPORT_JOURNALS=true
|
SEND_REPORT_JOURNALS=true
|
||||||
|
|
||||||
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
|
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
|
||||||
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
|
# Take note: it is no longer necessary to set this value, and it will be removed in future versions.
|
||||||
MAPBOX_API_KEY=
|
MAPBOX_API_KEY=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Instead of the mapbox API key, just set this value to true if you want to set the location
|
||||||
|
# of certain things, like transactions. Since this involves an external service, it's optional
|
||||||
|
# and disabled by default.
|
||||||
|
#
|
||||||
|
ENABLE_EXTERNAL_MAP=false
|
||||||
|
|
||||||
# The map will default to this location:
|
# The map will default to this location:
|
||||||
MAP_DEFAULT_LAT=51.983333
|
MAP_DEFAULT_LAT=51.983333
|
||||||
MAP_DEFAULT_LONG=5.916667
|
MAP_DEFAULT_LONG=5.916667
|
||||||
MAP_DEFAULT_ZOOM=6
|
MAP_DEFAULT_ZOOM=6
|
||||||
|
|
||||||
# Firefly III currently supports two provider for live Currency Exchange Rates:
|
|
||||||
# "fixer", and "ratesapi".
|
|
||||||
# RatesApi.IO (see https://ratesapi.io) is a FREE and OPEN SOURCE live currency exchange rates,
|
|
||||||
# built compatible with Fixer.IO, based on data published by European Central Bank, and doesn't require API key.
|
|
||||||
CER_PROVIDER=ratesapi
|
|
||||||
|
|
||||||
# If you have select "fixer" as default currency exchange rates,
|
|
||||||
# set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
|
|
||||||
# Please note that this WILL ONLY WORK FOR PAID fixer.io accounts because they severely limited
|
|
||||||
# the free API up to the point where you might as well offer nothing.
|
|
||||||
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
|
||||||
FIXER_API_KEY=
|
|
||||||
|
|
||||||
# Firefly III has two options for user authentication. "eloquent" is the default,
|
# Firefly III has two options for user authentication. "eloquent" is the default,
|
||||||
# and "ldap" for LDAP servers.
|
# and "ldap" for LDAP servers.
|
||||||
# For full instructions on these settings please visit:
|
# For full instructions on these settings please visit:
|
||||||
@@ -169,18 +177,41 @@ FIXER_API_KEY=
|
|||||||
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
|
||||||
LOGIN_PROVIDER=eloquent
|
LOGIN_PROVIDER=eloquent
|
||||||
|
|
||||||
#
|
|
||||||
# It's also possible to change the way users are authenticated. You could use Authelia for example.
|
# It's also possible to change the way users are authenticated. You could use Authelia for example.
|
||||||
# Authentication via the REMOTE_USER header is supported. Change the value below to "remote_user_guard".
|
# Authentication via the REMOTE_USER header is supported. Change the value below to "remote_user_guard".
|
||||||
#
|
#
|
||||||
|
# This will also allow Windows SSO.
|
||||||
|
#
|
||||||
# If you do this please read the documentation for instructions and warnings:
|
# If you do this please read the documentation for instructions and warnings:
|
||||||
# https://docs.firefly-iii.org/advanced-installation/authentication
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
#
|
#
|
||||||
# This function is available in Firefly III v5.3.0 and higher.
|
# This function is available in Firefly III v5.3.0 and higher.
|
||||||
AUTHENTICATION_GUARD=web
|
AUTHENTICATION_GUARD=web
|
||||||
|
|
||||||
|
# If the guard is changed, Firefly III uses the 'REMOTE_USER' header as per RFC 3875.
|
||||||
|
# You can also use another header, like AUTH_USER when using Windows SSO.
|
||||||
|
# Some systems use X-Auth headers. In that case, use HTTP_X_AUTH_USERNAME or HTTP_X_AUTH_EMAIL
|
||||||
|
# Depending on your system, REMOTE_USER may need to be changed to HTTP_REMOTE_USER
|
||||||
#
|
#
|
||||||
# Likewise, it's impossible to log out users who's authentication is handled by an external system.
|
# If this header is 'unexpectedly empty', check out the documentation.
|
||||||
|
# https://docs.firefly-iii.org/advanced-installation/authentication
|
||||||
|
#
|
||||||
|
AUTHENTICATION_GUARD_HEADER=REMOTE_USER
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III uses email addresses as user identifiers. When you're using an external authentication guard
|
||||||
|
# that doesn't do this, Firefly III is incapable of emailing you. Messages sent to "Bill Gates" always fail.
|
||||||
|
#
|
||||||
|
# However, if you set this value, Firefly III will store the value from this header as the user's backup
|
||||||
|
# email address and use it to communicate. So user "Bill Gates" could still have
|
||||||
|
# the email address "bill@microsoft.com".
|
||||||
|
#
|
||||||
|
# Example value: AUTHENTICATION_GUARD_EMAIL=HTTP_X_AUTH_EMAIL
|
||||||
|
#
|
||||||
|
AUTHENTICATION_GUARD_EMAIL=
|
||||||
|
|
||||||
|
|
||||||
|
# It's impossible to log out users who's authentication is handled by an external system.
|
||||||
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
|
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
|
||||||
# Setting this variable only works when AUTHENTICATION_GUARD != web
|
# Setting this variable only works when AUTHENTICATION_GUARD != web
|
||||||
#
|
#
|
||||||
@@ -219,7 +250,6 @@ ADLDAP_ADMIN_PASSWORD=
|
|||||||
ADLDAP_ACCOUNT_PREFIX=
|
ADLDAP_ACCOUNT_PREFIX=
|
||||||
ADLDAP_ACCOUNT_SUFFIX=
|
ADLDAP_ACCOUNT_SUFFIX=
|
||||||
|
|
||||||
|
|
||||||
# LDAP authentication settings.
|
# LDAP authentication settings.
|
||||||
ADLDAP_PASSWORD_SYNC=false
|
ADLDAP_PASSWORD_SYNC=false
|
||||||
ADLDAP_LOGIN_FALLBACK=false
|
ADLDAP_LOGIN_FALLBACK=false
|
||||||
@@ -227,12 +257,6 @@ ADLDAP_LOGIN_FALLBACK=false
|
|||||||
ADLDAP_DISCOVER_FIELD=distinguishedname
|
ADLDAP_DISCOVER_FIELD=distinguishedname
|
||||||
ADLDAP_AUTH_FIELD=distinguishedname
|
ADLDAP_AUTH_FIELD=distinguishedname
|
||||||
|
|
||||||
# Will allow SSO if your server provides an AUTH_USER field.
|
|
||||||
# You can set the following variables from a file by appending them with _FILE:
|
|
||||||
WINDOWS_SSO_ENABLED=false
|
|
||||||
WINDOWS_SSO_DISCOVER=samaccountname
|
|
||||||
WINDOWS_SSO_KEY=AUTH_USER
|
|
||||||
|
|
||||||
# field to sync as local username.
|
# field to sync as local username.
|
||||||
# You can set the following variable from a file by appending it with _FILE:
|
# You can set the following variable from a file by appending it with _FILE:
|
||||||
ADLDAP_SYNC_FIELD=userprincipalname
|
ADLDAP_SYNC_FIELD=userprincipalname
|
||||||
@@ -256,12 +280,16 @@ DISABLE_CSP_HEADER=false
|
|||||||
TRACKER_SITE_ID=
|
TRACKER_SITE_ID=
|
||||||
TRACKER_URL=
|
TRACKER_URL=
|
||||||
|
|
||||||
#
|
|
||||||
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
|
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
|
||||||
# In order to allow this, change the following variable to true.
|
# In order to allow this, change the following variable to true.
|
||||||
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
|
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
|
||||||
SEND_TELEMETRY=false
|
SEND_TELEMETRY=false
|
||||||
|
|
||||||
|
#
|
||||||
|
# Firefly III supports webhooks. These are security sensitive and must be enabled manually first.
|
||||||
|
#
|
||||||
|
ALLOW_WEBHOOKS=false
|
||||||
|
|
||||||
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||||
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
|
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
|
||||||
# However if you know what you're doing you can significantly speed up container start times.
|
# However if you know what you're doing you can significantly speed up container start times.
|
||||||
@@ -299,13 +327,12 @@ ADLDAP_CONNECTION=default
|
|||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
CACHE_PREFIX=firefly
|
CACHE_PREFIX=firefly
|
||||||
SEARCH_RESULT_LIMIT=50
|
|
||||||
PUSHER_KEY=
|
PUSHER_KEY=
|
||||||
|
IPINFO_TOKEN=
|
||||||
PUSHER_SECRET=
|
PUSHER_SECRET=
|
||||||
PUSHER_ID=
|
PUSHER_ID=
|
||||||
DEMO_USERNAME=
|
DEMO_USERNAME=
|
||||||
DEMO_PASSWORD=
|
DEMO_PASSWORD=
|
||||||
USE_ENCRYPTION=false
|
|
||||||
IS_HEROKU=false
|
IS_HEROKU=false
|
||||||
FIREFLY_III_LAYOUT=v1
|
FIREFLY_III_LAYOUT=v1
|
||||||
|
|
||||||
|
|||||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -3,3 +3,6 @@
|
|||||||
*.scss linguist-vendored
|
*.scss linguist-vendored
|
||||||
*.js linguist-vendored
|
*.js linguist-vendored
|
||||||
CHANGELOG.md export-ignore
|
CHANGELOG.md export-ignore
|
||||||
|
/tests export-ignore
|
||||||
|
/phpunit.xml export-ignore
|
||||||
|
/.ci export-ignore
|
||||||
|
|||||||
7
.github/.mergify.yml
vendored
Normal file
7
.github/.mergify.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
pull_request_rules:
|
||||||
|
- name: PR on main is never approved.
|
||||||
|
conditions:
|
||||||
|
- base=main
|
||||||
|
actions:
|
||||||
|
close:
|
||||||
|
message: Please reopen this PR on the `develop` branch. Thank you.
|
||||||
10
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
10
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@@ -1,6 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Create a report to help Firefly III improve
|
about: Create a report to help Firefly III improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -13,7 +16,12 @@ I am running Firefly III version x.x.x, and my problem is:
|
|||||||
<!-- What do you need to do to trigger this bug? -->
|
<!-- What do you need to do to trigger this bug? -->
|
||||||
|
|
||||||
**Extra info**
|
**Extra info**
|
||||||
<!-- Please add extra info here, such as OS, browser, and the output from the /debug page of your Firefly III installation (click the version at the bottom). -->
|
<!-- Please add extra info here, such as OS, browser, and the output from the /debug page of your Firefly III installation (click the version at the bottom).
|
||||||
|
|
||||||
|
DO NOT PUT ```BACKTICKS``` AROUND THE OUTPUT OF THE /debug PAGE
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
**Bonus points**
|
**Bonus points**
|
||||||
<!-- Before you submit, verify the following please: -->
|
<!-- Before you submit, verify the following please: -->
|
||||||
|
|||||||
6
.github/ISSUE_TEMPLATE/Custom.md
vendored
6
.github/ISSUE_TEMPLATE/Custom.md
vendored
@@ -10,7 +10,11 @@ I am running Firefly III version x.x.x.
|
|||||||
<!-- (if relevant of course) -->
|
<!-- (if relevant of course) -->
|
||||||
|
|
||||||
**Extra info**
|
**Extra info**
|
||||||
<!-- Please add extra info here, such as OS, browser, and the output from the `/debug`-page of your Firefly III installation (click the version at the bottom). -->
|
<!-- Please add extra info here, such as OS, browser, and the output from the `/debug`-page of your Firefly III installation (click the version at the bottom).
|
||||||
|
|
||||||
|
DO NOT PUT ```BACKTICKS``` AROUND THE OUTPUT OF THE /debug PAGE
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
**Bonus points**
|
**Bonus points**
|
||||||
|
|
||||||
|
|||||||
5
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
5
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
@@ -1,6 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: Feature request
|
name: Feature request
|
||||||
about: Suggest an idea or feature for Firefly III
|
about: Suggest an idea or feature for Firefly III
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -28,4 +31,4 @@ Please describe your feature request:
|
|||||||
|
|
||||||
- Make a drawing
|
- Make a drawing
|
||||||
- Donate money (just kidding ;)
|
- Donate money (just kidding ;)
|
||||||
-->
|
-->
|
||||||
|
|||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Ask a question
|
||||||
|
url: https://github.com/firefly-iii/firefly-iii/discussions
|
||||||
|
about: Please ask and answer questions here.
|
||||||
16
.github/contributing.md
vendored
16
.github/contributing.md
vendored
@@ -1,15 +1,3 @@
|
|||||||
# Welcome to Firefly III on Github!
|
# [Contributing guidelines](https://docs.firefly-iii.org/other-pages/contributing)
|
||||||
|
|
||||||
:+1::tada: Thank you for taking the time to contribute something to Firefly III!
|
[Contributing guidelines](https://docs.firefly-iii.org/other-pages/contributing)
|
||||||
|
|
||||||
## Feature requests
|
|
||||||
|
|
||||||
I am always interested in expanding Firefly III's many features. Just open a ticket or [drop me a line](mailto:james@firefly-iii.org).
|
|
||||||
|
|
||||||
## Pull requests
|
|
||||||
|
|
||||||
When contributing to Firefly III, please first discuss the change you wish to make via issue, email, or any other method. I can only accept pull requests against the `develop` branch, never the `main` branch.
|
|
||||||
|
|
||||||
## Translations :us: :fr: :de:
|
|
||||||
|
|
||||||
If you see a spelling error, grammatical error or a weird translation in your language, please join [our CrowdIn](https://crowdin.com/project/firefly-iii) project. There, you can submit your translations and fixes. The GitHub repository will download these automatically and they will be included in the next release.
|
|
||||||
26
.github/dependabot.yml
vendored
Normal file
26
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
|
||||||
|
# composer updates
|
||||||
|
- package-ecosystem: "composer"
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
target-branch: develop
|
||||||
|
labels: ["bug"]
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
|
||||||
|
# yarn / JS updates
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: develop
|
||||||
|
labels: ["bug"]
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
|
||||||
|
# yarn / JS updates for new frontend
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/frontend"
|
||||||
|
target-branch: develop
|
||||||
|
labels: ["bug"]
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
1
.github/funding.yml
vendored
1
.github/funding.yml
vendored
@@ -2,4 +2,3 @@
|
|||||||
|
|
||||||
github: jc5
|
github: jc5
|
||||||
patreon: JC5
|
patreon: JC5
|
||||||
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=44UKUT455HUFA
|
|
||||||
|
|||||||
146
.github/workflows/laravel.yml
vendored
Normal file
146
.github/workflows/laravel.yml
vendored
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
name: Firefly III
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Copy .env
|
||||||
|
run: test -f .env || cp .ci/.env.ci .env
|
||||||
|
- name: Prepare dependencies
|
||||||
|
run: |
|
||||||
|
set -euxo pipefail
|
||||||
|
export PATH=$PATH:$HOME/.composer/vendor/bin/
|
||||||
|
composer global require hirak/prestissimo --no-plugins --no-scripts
|
||||||
|
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-suggest
|
||||||
|
|
||||||
|
touch ./storage/database/database.sqlite
|
||||||
|
- name: Prepare Firefly III
|
||||||
|
run: |
|
||||||
|
chmod -R 777 storage bootstrap/cache
|
||||||
|
php artisan migrate --seed
|
||||||
|
php artisan firefly-iii:upgrade-database
|
||||||
|
- name: Upload database
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: database
|
||||||
|
path: storage/database/database.sqlite
|
||||||
|
- name: Upload cache
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: cache
|
||||||
|
path: bootstrap/cache/
|
||||||
|
- name: Upload composer cache
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: composer
|
||||||
|
path: ~/.composer
|
||||||
|
|
||||||
|
laravel-tests:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Copy .env
|
||||||
|
run: test -f .env || cp .ci/.env.ci .env
|
||||||
|
- name: Download database
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: database
|
||||||
|
path: storage/database/database.sqlite
|
||||||
|
- name: Download cache
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: cache
|
||||||
|
path: bootstrap/cache/
|
||||||
|
- name: Download vendor
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: composer
|
||||||
|
path: ~/.composer
|
||||||
|
- name: Install composer
|
||||||
|
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-suggest
|
||||||
|
|
||||||
|
- name: PHPUnit tests
|
||||||
|
uses: php-actions/phpunit@v1
|
||||||
|
with:
|
||||||
|
config: phpunit.xml
|
||||||
|
memory: 512M
|
||||||
|
|
||||||
|
coding-standards:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Copy .env
|
||||||
|
run: test -f .env || cp .ci/.env.ci .env
|
||||||
|
- name: Download database
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: database
|
||||||
|
path: storage/database/database.sqlite
|
||||||
|
- name: Download cache
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: cache
|
||||||
|
path: bootstrap/cache/
|
||||||
|
- name: Download vendor
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: composer
|
||||||
|
path: ~/.composer
|
||||||
|
- name: install depenencies
|
||||||
|
run: |
|
||||||
|
composer global require nette/coding-standard
|
||||||
|
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-suggest
|
||||||
|
|
||||||
|
- name: Execute code standard
|
||||||
|
run: /home/runner/.composer/vendor/bin/ecs check app tests --config ./.ci/firefly-iii-standard.yml
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Copy .env
|
||||||
|
run: test -f .env || cp .ci/.env.ci .env
|
||||||
|
- name: Download database
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: database
|
||||||
|
path: storage/database/database.sqlite
|
||||||
|
- name: Download cache
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: cache
|
||||||
|
path: bootstrap/cache/
|
||||||
|
- name: Download vendor
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: composer
|
||||||
|
path: ~/.composer
|
||||||
|
- name: Install depenencies
|
||||||
|
run: |
|
||||||
|
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-suggest
|
||||||
|
|
||||||
|
- name: Execute PHPStan
|
||||||
|
run: vendor/bin/phpstan analyse -c .ci/phpstan.neon
|
||||||
23
.github/workflows/stale.yml
vendored
Normal file
23
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: "Close stale issues"
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "30 1 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v3
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
stale-issue-message: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
stale-pr-message: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
days-before-stale: 14
|
||||||
|
days-before-close: 7
|
||||||
|
exempt-issue-labels: 'enhancement,feature,bug,announcement'
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/frontend/node_modules
|
/frontend/node_modules
|
||||||
/frontend/fonts
|
/frontend/fonts
|
||||||
|
/frontend/images
|
||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
|
|||||||
20
.travis.yml
Normal file
20
.travis.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
language: php
|
||||||
|
php:
|
||||||
|
- '7.4'
|
||||||
|
dist: xenial
|
||||||
|
os: linux
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- "/home/travis/.config"
|
||||||
|
- "/home/travis/build/firefly-iii/firefly-iii/vendor"
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- phpenv config-rm xdebug.ini || return 0
|
||||||
|
|
||||||
|
script:
|
||||||
|
- "./.ci/phpstan.sh"
|
||||||
|
- "./.ci/phpunit.sh"
|
||||||
116
app/Api/V1/Controllers/Autocomplete/AccountController.php
Normal file
116
app/Api/V1/Controllers/Autocomplete/AccountController.php
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountController
|
||||||
|
*/
|
||||||
|
class AccountController extends Controller
|
||||||
|
{
|
||||||
|
use AccountFilter;
|
||||||
|
|
||||||
|
private array $balanceTypes;
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function accounts(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$types = $data['types'];
|
||||||
|
$query = $data['query'];
|
||||||
|
$date = $data['date'] ?? today(config('app.timezone'));
|
||||||
|
|
||||||
|
$return = [];
|
||||||
|
$result = $this->repository->searchAccount((string)$query, $types, $data['limit']);
|
||||||
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
|
|
||||||
|
/** @var Account $account */
|
||||||
|
foreach ($result as $account) {
|
||||||
|
$nameWithBalance = $account->name;
|
||||||
|
$currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||||
|
|
||||||
|
if (in_array($account->accountType->type, $this->balanceTypes, true)) {
|
||||||
|
$balance = app('steam')->balance($account, $date);
|
||||||
|
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
$return[] = [
|
||||||
|
'id' => (string)$account->id,
|
||||||
|
'name' => $account->name,
|
||||||
|
'name_with_balance' => $nameWithBalance,
|
||||||
|
'type' => $account->accountType->type,
|
||||||
|
'currency_id' => $currency->id,
|
||||||
|
'currency_name' => $currency->name,
|
||||||
|
'currency_code' => $currency->code,
|
||||||
|
'currency_symbol' => $currency->symbol,
|
||||||
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// custom order.
|
||||||
|
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
|
||||||
|
usort(
|
||||||
|
$return, function ($a, $b) use ($order) {
|
||||||
|
$pos_a = array_search($a['type'], $order);
|
||||||
|
$pos_b = array_search($b['type'], $order);
|
||||||
|
|
||||||
|
return $pos_a - $pos_b;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($return);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
app/Api/V1/Controllers/Autocomplete/BillController.php
Normal file
79
app/Api/V1/Controllers/Autocomplete/BillController.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* BillController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BillController
|
||||||
|
*/
|
||||||
|
class BillController extends Controller
|
||||||
|
{
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function bills(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$result = $this->repository->searchBill($data['query'], $data['limit']);
|
||||||
|
$filtered = $result->map(
|
||||||
|
static function (Bill $item) {
|
||||||
|
return [
|
||||||
|
'id' => (string)$item->id,
|
||||||
|
'name' => $item->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($filtered->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
app/Api/V1/Controllers/Autocomplete/BudgetController.php
Normal file
78
app/Api/V1/Controllers/Autocomplete/BudgetController.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* BudgetController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BudgetController
|
||||||
|
*/
|
||||||
|
class BudgetController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function budgets(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$result = $this->repository->searchBudget($data['query'], $data['limit']);
|
||||||
|
$filtered = $result->map(
|
||||||
|
static function (Budget $item) {
|
||||||
|
return [
|
||||||
|
'id' => (string)$item->id,
|
||||||
|
'name' => $item->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($filtered);
|
||||||
|
}
|
||||||
|
}
|
||||||
78
app/Api/V1/Controllers/Autocomplete/CategoryController.php
Normal file
78
app/Api/V1/Controllers/Autocomplete/CategoryController.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CategoryController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CategoryController
|
||||||
|
*/
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function categories(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$result = $this->repository->searchCategory($data['query'], $data['limit']);
|
||||||
|
$filtered = $result->map(
|
||||||
|
static function (Category $item) {
|
||||||
|
return [
|
||||||
|
'id' => (string)$item->id,
|
||||||
|
'name' => $item->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($filtered);
|
||||||
|
}
|
||||||
|
}
|
||||||
107
app/Api/V1/Controllers/Autocomplete/CurrencyController.php
Normal file
107
app/Api/V1/Controllers/Autocomplete/CurrencyController.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CurrencyController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CurrencyController
|
||||||
|
*/
|
||||||
|
class CurrencyController extends Controller
|
||||||
|
{
|
||||||
|
private CurrencyRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CurrencyController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(CurrencyRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function currencies(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$collection = $this->repository->searchCurrency($data['query'], $data['limit']);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
/** @var TransactionCurrency $currency */
|
||||||
|
foreach ($collection as $currency) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$currency->id,
|
||||||
|
'name' => $currency->name,
|
||||||
|
'code' => $currency->code,
|
||||||
|
'symbol' => $currency->symbol,
|
||||||
|
'decimal_places' => $currency->decimal_places,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function currenciesWithCode(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$collection = $this->repository->searchCurrency($data['query'], $data['limit']);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
/** @var TransactionCurrency $currency */
|
||||||
|
foreach ($collection as $currency) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$currency->id,
|
||||||
|
'name' => sprintf('%s (%s)', $currency->name, $currency->code),
|
||||||
|
'code' => $currency->code,
|
||||||
|
'symbol' => $currency->symbol,
|
||||||
|
'decimal_places' => $currency->decimal_places,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ObjectGroupController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\ObjectGroup;
|
||||||
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ObjectGroupController
|
||||||
|
*/
|
||||||
|
class ObjectGroupController extends Controller
|
||||||
|
{
|
||||||
|
private ObjectGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CurrencyController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function objectGroups(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$return = [];
|
||||||
|
$result = $this->repository->search($data['query'], $data['limit']);
|
||||||
|
|
||||||
|
/** @var ObjectGroup $objectGroup */
|
||||||
|
foreach ($result as $objectGroup) {
|
||||||
|
$return[] = [
|
||||||
|
'id' => (string)$objectGroup->id,
|
||||||
|
'name' => $objectGroup->title,
|
||||||
|
'title' => $objectGroup->title,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
122
app/Api/V1/Controllers/Autocomplete/PiggyBankController.php
Normal file
122
app/Api/V1/Controllers/Autocomplete/PiggyBankController.php
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PiggyBankController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PiggyBankController
|
||||||
|
*/
|
||||||
|
class PiggyBankController extends Controller
|
||||||
|
{
|
||||||
|
private AccountRepositoryInterface $accountRepository;
|
||||||
|
private PiggyBankRepositoryInterface $piggyRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PiggyBankController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->piggyRepository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->piggyRepository->setUser($user);
|
||||||
|
$this->accountRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function piggyBanks(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $data['limit']);
|
||||||
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
/** @var PiggyBank $piggy */
|
||||||
|
foreach ($piggies as $piggy) {
|
||||||
|
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
|
||||||
|
$response[] = [
|
||||||
|
'id' => (string)$piggy->id,
|
||||||
|
'name' => $piggy->name,
|
||||||
|
'currency_id' => $currency->id,
|
||||||
|
'currency_name' => $currency->name,
|
||||||
|
'currency_code' => $currency->code,
|
||||||
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function piggyBanksWithBalance(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $data['limit']);
|
||||||
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
|
$response = [];
|
||||||
|
/** @var PiggyBank $piggy */
|
||||||
|
foreach ($piggies as $piggy) {
|
||||||
|
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
|
||||||
|
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
|
||||||
|
$response[] = [
|
||||||
|
'id' => (string)$piggy->id,
|
||||||
|
'name' => $piggy->name,
|
||||||
|
'name_with_balance' => sprintf(
|
||||||
|
'%s (%s / %s)', $piggy->name, app('amount')->formatAnything($currency, $currentAmount, false),
|
||||||
|
app('amount')->formatAnything($currency, $piggy->targetamount, false),
|
||||||
|
),
|
||||||
|
'currency_id' => $currency->id,
|
||||||
|
'currency_name' => $currency->name,
|
||||||
|
'currency_code' => $currency->code,
|
||||||
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
app/Api/V1/Controllers/Autocomplete/RecurrenceController.php
Normal file
78
app/Api/V1/Controllers/Autocomplete/RecurrenceController.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* RecurrenceController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Rule;
|
||||||
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RecurrenceController
|
||||||
|
*/
|
||||||
|
class RecurrenceController extends Controller
|
||||||
|
{
|
||||||
|
private RecurringRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RecurrenceController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(RecurringRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function recurring(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$rules = $this->repository->searchRecurrence($data['query'], $data['limit']);
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
/** @var Rule $rule */
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$response[] = [
|
||||||
|
'id' => (string)$rule->id,
|
||||||
|
'name' => $rule->title,
|
||||||
|
'description' => $rule->description,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
app/Api/V1/Controllers/Autocomplete/RuleController.php
Normal file
78
app/Api/V1/Controllers/Autocomplete/RuleController.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* RuleController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Rule;
|
||||||
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RuleController
|
||||||
|
*/
|
||||||
|
class RuleController extends Controller
|
||||||
|
{
|
||||||
|
private RuleRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RuleController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(RuleRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function rules(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$rules = $this->repository->searchRule($data['query'], $data['limit']);
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
/** @var Rule $rule */
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$response[] = [
|
||||||
|
'id' => (string)$rule->id,
|
||||||
|
'name' => $rule->title,
|
||||||
|
'description' => $rule->description,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
77
app/Api/V1/Controllers/Autocomplete/RuleGroupController.php
Normal file
77
app/Api/V1/Controllers/Autocomplete/RuleGroupController.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* RuleGroupController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\RuleGroup;
|
||||||
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RuleGroupController
|
||||||
|
*/
|
||||||
|
class RuleGroupController extends Controller
|
||||||
|
{
|
||||||
|
private RuleGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RuleGroupController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function ruleGroups(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$groups = $this->repository->searchRuleGroup($data['query'], $data['limit']);
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
/** @var RuleGroup $group */
|
||||||
|
foreach ($groups as $group) {
|
||||||
|
$response[] = [
|
||||||
|
'id' => (string)$group->id,
|
||||||
|
'name' => $group->title,
|
||||||
|
'description' => $group->description,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
80
app/Api/V1/Controllers/Autocomplete/TagController.php
Normal file
80
app/Api/V1/Controllers/Autocomplete/TagController.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* TagController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\Tag;
|
||||||
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TagController
|
||||||
|
*/
|
||||||
|
class TagController extends Controller
|
||||||
|
{
|
||||||
|
private TagRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TagController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(TagRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function tags(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
|
||||||
|
$result = $this->repository->searchTags($data['query'], $data['limit']);
|
||||||
|
$array = [];
|
||||||
|
/** @var Tag $tag */
|
||||||
|
foreach ($result as $tag) {
|
||||||
|
$array[] = [
|
||||||
|
'id' => (string)$tag->id,
|
||||||
|
'name' => $tag->tag,
|
||||||
|
'tag' => $tag->tag,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($array);
|
||||||
|
}
|
||||||
|
}
|
||||||
128
app/Api/V1/Controllers/Autocomplete/TransactionController.php
Normal file
128
app/Api/V1/Controllers/Autocomplete/TransactionController.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* TransactionController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TransactionController
|
||||||
|
*/
|
||||||
|
class TransactionController extends Controller
|
||||||
|
{
|
||||||
|
private TransactionGroupRepositoryInterface $groupRepository;
|
||||||
|
private JournalRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TransactionController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
|
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->groupRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function transactions(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$result = $this->repository->searchJournalDescriptions($data['query'], $data['limit']);
|
||||||
|
|
||||||
|
// limit and unique
|
||||||
|
$filtered = $result->unique('description');
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($filtered as $journal) {
|
||||||
|
$array[] = [
|
||||||
|
'id' => (string)$journal->id,
|
||||||
|
'transaction_group_id' => (string)$journal->transaction_group_id,
|
||||||
|
'name' => $journal->description,
|
||||||
|
'description' => $journal->description,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function transactionsWithID(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$result = new Collection;
|
||||||
|
if (is_numeric($data['query'])) {
|
||||||
|
// search for group, not journal.
|
||||||
|
$firstResult = $this->groupRepository->find((int)$data['query']);
|
||||||
|
if (null !== $firstResult) {
|
||||||
|
// group may contain multiple journals, each a result:
|
||||||
|
foreach ($firstResult->transactionJournals as $journal) {
|
||||||
|
$result->push($journal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is_numeric($data['query'])) {
|
||||||
|
$result = $this->repository->searchJournalDescriptions($data['query'], $data['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// limit and unique
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($result as $journal) {
|
||||||
|
$array[] = [
|
||||||
|
'id' => (string)$journal->id,
|
||||||
|
'transaction_group_id' => (string)$journal->transaction_group_id,
|
||||||
|
'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
|
||||||
|
'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($array);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* TransactionTypeController.php
|
||||||
|
* Copyright (c) 2020 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\Api\V1\Controllers\Autocomplete;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TransactionTypeController
|
||||||
|
*/
|
||||||
|
class TransactionTypeController extends Controller
|
||||||
|
{
|
||||||
|
private TransactionTypeRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TransactionTypeController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(TransactionTypeRepositoryInterface::class);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AutocompleteRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function transactionTypes(AutocompleteRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getData();
|
||||||
|
$types = $this->repository->searchTypes($data['query'], $data['limit']);
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
/** @var TransactionType $type */
|
||||||
|
foreach ($types as $type) {
|
||||||
|
// different key for consistency.
|
||||||
|
$array[] = [
|
||||||
|
'id' => (string)$type->id,
|
||||||
|
'name' => $type->type,
|
||||||
|
'type' => $type->type,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($array);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,260 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BudgetLimitController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers;
|
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
|
||||||
use FireflyIII\Models\BudgetLimit;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
|
||||||
use FireflyIII\Transformers\BudgetLimitTransformer;
|
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BudgetLimitController.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class BudgetLimitController extends Controller
|
|
||||||
{
|
|
||||||
use TransactionFilter;
|
|
||||||
/** @var BudgetLimitRepositoryInterface */
|
|
||||||
private $blRepository;
|
|
||||||
/** @var BudgetRepositoryInterface The budget repository */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BudgetLimitController constructor.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
|
||||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($user);
|
|
||||||
$this->blRepository->setUser($user);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function delete(BudgetLimit $budgetLimit): JsonResponse
|
|
||||||
{
|
|
||||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function index(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$budgetId = (int) ($request->get('budget_id') ?? 0);
|
|
||||||
$budget = $this->repository->findNull($budgetId);
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
$this->parameters->set('budget_id', $budgetId);
|
|
||||||
|
|
||||||
$collection = new Collection;
|
|
||||||
if (null === $budget) {
|
|
||||||
$collection = $this->blRepository->getAllBudgetLimits($this->parameters->get('start'), $this->parameters->get('end'));
|
|
||||||
}
|
|
||||||
if (null !== $budget) {
|
|
||||||
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = $collection->count();
|
|
||||||
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.budget_limits.index') . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the specified resource.
|
|
||||||
*
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function show(BudgetLimit $budgetLimit): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param BudgetLimitRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(BudgetLimitRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$budget = $this->repository->findNull($data['budget_id']);
|
|
||||||
if (null === $budget) {
|
|
||||||
throw new FireflyException('200004: Budget does not exist.'); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$data['budget'] = $budget;
|
|
||||||
$budgetLimit = $this->blRepository->storeBudgetLimit($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show all transactions.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function transactions(Request $request, BudgetLimit $budgetLimit): JsonResponse
|
|
||||||
{
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
$type = $request->get('type') ?? 'default';
|
|
||||||
$this->parameters->set('type', $type);
|
|
||||||
|
|
||||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
// use new group collector:
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
|
||||||
$collector = app(GroupCollectorInterface::class);
|
|
||||||
$collector
|
|
||||||
->setUser($admin)
|
|
||||||
// filter on budget.
|
|
||||||
->setBudget($budgetLimit->budget)
|
|
||||||
// all info needed for the API:
|
|
||||||
->withAPIInformation()
|
|
||||||
// set page size:
|
|
||||||
->setLimit($pageSize)
|
|
||||||
// set page to retrieve
|
|
||||||
->setPage($this->parameters->get('page'))
|
|
||||||
// set types of transactions to return.
|
|
||||||
->setTypes($types);
|
|
||||||
|
|
||||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
|
||||||
$collector->setTypes($types);
|
|
||||||
$paginator = $collector->getPaginatedGroups();
|
|
||||||
$paginator->setPath(route('api.v1.budget_limits.transactions', [$budgetLimit->id]) . $this->buildParams());
|
|
||||||
$transactions = $paginator->getCollection();
|
|
||||||
|
|
||||||
/** @var TransactionGroupTransformer $transformer */
|
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @param BudgetLimitRequest $request
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(BudgetLimitRequest $request, BudgetLimit $budgetLimit): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$data['budget'] = $budgetLimit->budget;
|
|
||||||
$budgetLimit = $this->blRepository->updateBudgetLimit($budgetLimit, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,10 +26,9 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\ApiSupport;
|
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||||
@@ -42,8 +41,9 @@ use Illuminate\Http\JsonResponse;
|
|||||||
class AccountController extends Controller
|
class AccountController extends Controller
|
||||||
{
|
{
|
||||||
use ApiSupport;
|
use ApiSupport;
|
||||||
|
|
||||||
private CurrencyRepositoryInterface $currencyRepository;
|
private CurrencyRepositoryInterface $currencyRepository;
|
||||||
private AccountRepositoryInterface $repository;
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController constructor.
|
* AccountController constructor.
|
||||||
@@ -68,92 +68,6 @@ class AccountController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DateRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function expenseOverview(DateRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
// parameters for chart:
|
|
||||||
$dates = $request->getAll();
|
|
||||||
/** @var Carbon $start */
|
|
||||||
$start = $dates['start'];
|
|
||||||
/** @var Carbon $end */
|
|
||||||
$end = $dates['end'];
|
|
||||||
|
|
||||||
$start->subDay();
|
|
||||||
|
|
||||||
// prep some vars:
|
|
||||||
$currencies = [];
|
|
||||||
$chartData = [];
|
|
||||||
$tempData = [];
|
|
||||||
|
|
||||||
// grab all accounts and names
|
|
||||||
$accounts = $this->repository->getAccountsByType([AccountType::EXPENSE]);
|
|
||||||
$accountNames = $this->extractNames($accounts);
|
|
||||||
$startBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $start);
|
|
||||||
$endBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $end);
|
|
||||||
|
|
||||||
// loop the end balances. This is an array for each account ($expenses)
|
|
||||||
foreach ($endBalances as $accountId => $expenses) {
|
|
||||||
$accountId = (int) $accountId;
|
|
||||||
// loop each expense entry (each entry can be a different currency).
|
|
||||||
foreach ($expenses as $currencyId => $endAmount) {
|
|
||||||
$currencyId = (int) $currencyId;
|
|
||||||
|
|
||||||
// see if there is an accompanying start amount.
|
|
||||||
// grab the difference and find the currency.
|
|
||||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
|
||||||
$diff = bcsub($endAmount, $startAmount);
|
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId);
|
|
||||||
if (0 !== bccomp($diff, '0')) {
|
|
||||||
// store the values in a temporary array.
|
|
||||||
$tempData[] = [
|
|
||||||
'name' => $accountNames[$accountId],
|
|
||||||
'difference' => $diff,
|
|
||||||
'diff_float' => (float) $diff,
|
|
||||||
'currency_id' => $currencyId,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort temp array by amount.
|
|
||||||
$amounts = array_column($tempData, 'diff_float');
|
|
||||||
array_multisort($amounts, SORT_DESC, $tempData);
|
|
||||||
|
|
||||||
// loop all found currencies and build the data array for the chart.
|
|
||||||
/**
|
|
||||||
* @var int $currencyId
|
|
||||||
* @var TransactionCurrency $currency
|
|
||||||
*/
|
|
||||||
foreach ($currencies as $currencyId => $currency) {
|
|
||||||
$currentSet = [
|
|
||||||
'label' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),
|
|
||||||
'currency_id' => $currency->id,
|
|
||||||
'currency_code' => $currency->code,
|
|
||||||
'currency_symbol' => $currency->symbol,
|
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
|
||||||
'type' => 'bar', // line, area or bar
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => $this->expandNames($tempData),
|
|
||||||
];
|
|
||||||
$chartData[$currencyId] = $currentSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop temp data and place data in correct array:
|
|
||||||
foreach ($tempData as $entry) {
|
|
||||||
$currencyId = $entry['currency_id'];
|
|
||||||
$name = $entry['name'];
|
|
||||||
$chartData[$currencyId]['entries'][$name] = round($entry['difference'], $chartData[$currencyId]['currency_decimal_places']);
|
|
||||||
}
|
|
||||||
$chartData = array_values($chartData);
|
|
||||||
|
|
||||||
return response()->json($chartData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DateRequest $request
|
* @param DateRequest $request
|
||||||
*
|
*
|
||||||
@@ -172,12 +86,12 @@ class AccountController extends Controller
|
|||||||
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
||||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||||
$default = app('amount')->getDefaultCurrency();
|
$default = app('amount')->getDefaultCurrency();
|
||||||
// @codeCoverageIgnoreStart
|
|
||||||
if (0 === count($frontPage->data)) {
|
if (0 === count($frontPage->data)) {
|
||||||
$frontPage->data = $defaultSet;
|
$frontPage->data = $defaultSet;
|
||||||
$frontPage->save();
|
$frontPage->save();
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
|
||||||
|
|
||||||
// get accounts:
|
// get accounts:
|
||||||
$accounts = $this->repository->getAccountsById($frontPage->data);
|
$accounts = $this->repository->getAccountsById($frontPage->data);
|
||||||
@@ -186,16 +100,16 @@ class AccountController extends Controller
|
|||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$currency = $this->repository->getAccountCurrency($account);
|
$currency = $this->repository->getAccountCurrency($account);
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = $default; // @codeCoverageIgnore
|
$currency = $default;
|
||||||
}
|
}
|
||||||
$currentSet = [
|
$currentSet = [
|
||||||
'label' => $account->name,
|
'label' => $account->name,
|
||||||
'currency_id' => $currency->id,
|
'currency_id' => (string)$currency->id,
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
'start_date' => $start->format('Y-m-d'),
|
'start_date' => $start->toAtomString(),
|
||||||
'end_date' => $end->format('Y-m-d'),
|
'end_date' => $end->toAtomString(),
|
||||||
'type' => 'line', // line, area or bar
|
'type' => 'line', // line, area or bar
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
'yAxisID' => 0, // 0, 1, 2
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
@@ -203,11 +117,11 @@ class AccountController extends Controller
|
|||||||
/** @var Carbon $currentStart */
|
/** @var Carbon $currentStart */
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
||||||
$previous = round(array_values($range)[0], 12);
|
$previous = round((float)array_values($range)[0], 12);
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$format = $currentStart->format('Y-m-d');
|
$format = $currentStart->format('Y-m-d');
|
||||||
$label = $currentStart->format('Y-m-d');
|
$label = $currentStart->toAtomString();
|
||||||
$balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
|
$balance = array_key_exists($format, $range) ? round((float)$range[$format], 12) : $previous;
|
||||||
$previous = $balance;
|
$previous = $balance;
|
||||||
$currentStart->addDay();
|
$currentStart->addDay();
|
||||||
$currentSet['entries'][$label] = $balance;
|
$currentSet['entries'][$label] = $balance;
|
||||||
@@ -217,91 +131,4 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
return response()->json($chartData);
|
return response()->json($chartData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DateRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function revenueOverview(DateRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
// parameters for chart:
|
|
||||||
$dates = $request->getAll();
|
|
||||||
/** @var Carbon $start */
|
|
||||||
$start = $dates['start'];
|
|
||||||
/** @var Carbon $end */
|
|
||||||
$end = $dates['end'];
|
|
||||||
|
|
||||||
$start->subDay();
|
|
||||||
|
|
||||||
// prep some vars:
|
|
||||||
$currencies = [];
|
|
||||||
$chartData = [];
|
|
||||||
$tempData = [];
|
|
||||||
|
|
||||||
// grab all accounts and names
|
|
||||||
$accounts = $this->repository->getAccountsByType([AccountType::REVENUE]);
|
|
||||||
$accountNames = $this->extractNames($accounts);
|
|
||||||
$startBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $start);
|
|
||||||
$endBalances = app('steam')->balancesPerCurrencyByAccounts($accounts, $end);
|
|
||||||
|
|
||||||
// loop the end balances. This is an array for each account ($expenses)
|
|
||||||
foreach ($endBalances as $accountId => $expenses) {
|
|
||||||
$accountId = (int) $accountId;
|
|
||||||
// loop each expense entry (each entry can be a different currency).
|
|
||||||
foreach ($expenses as $currencyId => $endAmount) {
|
|
||||||
$currencyId = (int) $currencyId;
|
|
||||||
|
|
||||||
// see if there is an accompanying start amount.
|
|
||||||
// grab the difference and find the currency.
|
|
||||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
|
||||||
$diff = bcsub($endAmount, $startAmount);
|
|
||||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId);
|
|
||||||
if (0 !== bccomp($diff, '0')) {
|
|
||||||
// store the values in a temporary array.
|
|
||||||
$tempData[] = [
|
|
||||||
'name' => $accountNames[$accountId],
|
|
||||||
'difference' => bcmul($diff, '-1'),
|
|
||||||
// For some reason this line is never covered in code coverage:
|
|
||||||
'diff_float' => ((float) $diff) * -1, // @codeCoverageIgnore
|
|
||||||
'currency_id' => $currencyId,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort temp array by amount.
|
|
||||||
$amounts = array_column($tempData, 'diff_float');
|
|
||||||
array_multisort($amounts, SORT_DESC, $tempData);
|
|
||||||
|
|
||||||
// loop all found currencies and build the data array for the chart.
|
|
||||||
/**
|
|
||||||
* @var int $currencyId
|
|
||||||
* @var TransactionCurrency $currency
|
|
||||||
*/
|
|
||||||
foreach ($currencies as $currencyId => $currency) {
|
|
||||||
$currentSet = [
|
|
||||||
'label' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),
|
|
||||||
'currency_id' => $currency->id,
|
|
||||||
'currency_code' => $currency->code,
|
|
||||||
'currency_symbol' => $currency->symbol,
|
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
|
||||||
'type' => 'bar', // line, area or bar
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => $this->expandNames($tempData),
|
|
||||||
];
|
|
||||||
$chartData[$currencyId] = $currentSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop temp data and place data in correct array:
|
|
||||||
foreach ($tempData as $entry) {
|
|
||||||
$currencyId = $entry['currency_id'];
|
|
||||||
$name = $entry['name'];
|
|
||||||
$chartData[$currencyId]['entries'][$name] = round($entry['difference'], $chartData[$currencyId]['currency_decimal_places']);
|
|
||||||
}
|
|
||||||
$chartData = array_values($chartData);
|
|
||||||
|
|
||||||
return response()->json($chartData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AvailableBudgetController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers\Chart;
|
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
|
||||||
use FireflyIII\Models\AvailableBudget;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AvailableBudgetController
|
|
||||||
*/
|
|
||||||
class AvailableBudgetController extends Controller
|
|
||||||
{
|
|
||||||
/** @var OperationsRepositoryInterface */
|
|
||||||
private $opsRepository;
|
|
||||||
/** @var BudgetRepositoryInterface */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AvailableBudgetController constructor.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
|
||||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($user);
|
|
||||||
$this->opsRepository->setUser($user);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param AvailableBudget $availableBudget
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function overview(AvailableBudget $availableBudget): JsonResponse
|
|
||||||
{
|
|
||||||
$currency = $availableBudget->transactionCurrency;
|
|
||||||
$budgets = $this->repository->getActiveBudgets();
|
|
||||||
$budgetInformation = $this->opsRepository->spentInPeriodMc($budgets, new Collection, $availableBudget->start_date, $availableBudget->end_date);
|
|
||||||
$spent = 0.0;
|
|
||||||
|
|
||||||
// get for current currency
|
|
||||||
foreach ($budgetInformation as $spentInfo) {
|
|
||||||
if ($spentInfo['currency_id'] === $availableBudget->transaction_currency_id) {
|
|
||||||
$spent = $spentInfo['amount'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$left = bcadd($availableBudget->amount, (string) $spent);
|
|
||||||
// left less than zero? Set to zero.
|
|
||||||
if (-1 === bccomp($left, '0')) {
|
|
||||||
$left = '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
$chartData = [
|
|
||||||
[
|
|
||||||
'label' => trans('firefly.spent'),
|
|
||||||
'currency_id' => $currency->id,
|
|
||||||
'currency_code' => $currency->code,
|
|
||||||
'currency_symbol' => $currency->symbol,
|
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
|
||||||
'type' => 'pie',
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => [$spent * -1],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'label' => trans('firefly.left'),
|
|
||||||
'currency_id' => $currency->id,
|
|
||||||
'currency_code' => $currency->code,
|
|
||||||
'currency_symbol' => $currency->symbol,
|
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
|
||||||
'type' => 'line', // line, area or bar
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => [round($left, $currency->decimal_places)],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
return response()->json($chartData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BudgetController.php
|
|
||||||
* Copyright (c) 2020 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\Api\V1\Controllers\Chart;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
|
||||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
|
||||||
use FireflyIII\Models\Budget;
|
|
||||||
use FireflyIII\Models\BudgetLimit;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BudgetController
|
|
||||||
*/
|
|
||||||
class BudgetController extends Controller
|
|
||||||
{
|
|
||||||
private BudgetLimitRepositoryInterface $blRepository;
|
|
||||||
private OperationsRepositoryInterface $opsRepository;
|
|
||||||
private BudgetRepositoryInterface $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BudgetController constructor.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
//$this->generator = app(GeneratorInterface::class);
|
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
|
||||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
|
||||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
|
||||||
|
|
||||||
//$this->nbRepository = app(NoBudgetRepositoryInterface::class);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [
|
|
||||||
* 'label' => 'label for entire set'
|
|
||||||
* 'currency_id' => 0,
|
|
||||||
* 'currency_code' => 'EUR',
|
|
||||||
* 'currency_symbol' => '$',
|
|
||||||
* 'currency_decimal_places' => 2,
|
|
||||||
* 'type' => 'bar', // line, area or bar
|
|
||||||
* 'yAxisID' => 0, // 0, 1, 2
|
|
||||||
* 'entries' => ['a' => 1, 'b' => 4],
|
|
||||||
* ],
|
|
||||||
*
|
|
||||||
* @param DateRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function overview(DateRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$dates = $request->getAll();
|
|
||||||
$budgets = $this->repository->getActiveBudgets();
|
|
||||||
$budgetNames = [];
|
|
||||||
$currencyNames = [];
|
|
||||||
$sets = [];
|
|
||||||
/** @var Budget $budget */
|
|
||||||
foreach ($budgets as $budget) {
|
|
||||||
$expenses = $this->getExpenses($budget, $dates['start'], $dates['end']);
|
|
||||||
$expenses = $this->filterNulls($expenses);
|
|
||||||
foreach ($expenses as $set) {
|
|
||||||
$budgetNames[] = $set['budget_name'];
|
|
||||||
$currencyNames[] = $set['currency_name'];
|
|
||||||
$sets[] = $set;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$budgetNames = array_unique($budgetNames);
|
|
||||||
$currencyNames = array_unique($currencyNames);
|
|
||||||
$basic = $this->createSets($budgetNames, $currencyNames);
|
|
||||||
$filled = $this->fillSets($basic, $sets);
|
|
||||||
$keys = array_values($filled);
|
|
||||||
|
|
||||||
return response()->json($keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $limits
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function getExpenses(Budget $budget, Carbon $start, Carbon $end): array
|
|
||||||
{
|
|
||||||
$limits = $this->blRepository->getBudgetLimits($budget, $start, $end);
|
|
||||||
if (0 === $limits->count()) {
|
|
||||||
return $this->getExpenseInRange($budget, $start, $end);
|
|
||||||
}
|
|
||||||
$arr = [];
|
|
||||||
/** @var BudgetLimit $limit */
|
|
||||||
foreach ($limits as $limit) {
|
|
||||||
$arr[] = $this->getExpensesForLimit($limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $budgetNames
|
|
||||||
* @param array $currencyNames
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function createSets(array $budgetNames, array $currencyNames): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
foreach ($currencyNames as $currencyName) {
|
|
||||||
$entries = [];
|
|
||||||
foreach ($budgetNames as $budgetName) {
|
|
||||||
$label = sprintf('%s (%s)', $budgetName, $currencyName);
|
|
||||||
$entries[$label] = '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
// left
|
|
||||||
$return['left'] = [
|
|
||||||
'label' => sprintf('%s (%s)', trans('firefly.left'), $currencyName),
|
|
||||||
'data_type' => 'left',
|
|
||||||
'currency_name' => $currencyName,
|
|
||||||
'type' => 'bar',
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => $entries,
|
|
||||||
];
|
|
||||||
|
|
||||||
// spent_capped
|
|
||||||
$return['spent_capped'] = [
|
|
||||||
'label' => sprintf('%s (%s)', trans('firefly.spent'), $currencyName),
|
|
||||||
'data_type' => 'spent_capped',
|
|
||||||
'currency_name' => $currencyName,
|
|
||||||
'type' => 'bar',
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => $entries,
|
|
||||||
];
|
|
||||||
|
|
||||||
// overspent
|
|
||||||
$return['overspent'] = [
|
|
||||||
'label' => sprintf('%s (%s)', trans('firefly.overspent'), $currencyName),
|
|
||||||
'data_type' => 'overspent',
|
|
||||||
'currency_name' => $currencyName,
|
|
||||||
'type' => 'bar',
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => $entries,
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $basic
|
|
||||||
* @param array $sets
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function fillSets(array $basic, array $sets): array
|
|
||||||
{
|
|
||||||
foreach ($sets as $set) {
|
|
||||||
$label = $set['label'];
|
|
||||||
//$basic['spent']['entries'][$label] = $set['entries']['spent'];
|
|
||||||
$basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped'];
|
|
||||||
$basic['left']['entries'][$label] = $set['entries']['left'];
|
|
||||||
$basic['overspent']['entries'][$label] = $set['entries']['overspent'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $expenses
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function filterNulls(array $expenses): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
/** @var array|null $arr */
|
|
||||||
foreach ($expenses as $arr) {
|
|
||||||
if (null !== $arr) {
|
|
||||||
$return[] = $arr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Budget $budget
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getExpenseInRange(Budget $budget, Carbon $start, Carbon $end): array
|
|
||||||
{
|
|
||||||
$spent = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget]), null);
|
|
||||||
$return = [];
|
|
||||||
/** @var array $set */
|
|
||||||
foreach ($spent as $set) {
|
|
||||||
$current = [
|
|
||||||
'label' => sprintf('%s (%s)', $budget->name, $set['currency_name']),
|
|
||||||
'budget_name' => $budget->name,
|
|
||||||
'start_date' => $start->format('Y-m-d'),
|
|
||||||
'end_date' => $end->format('Y-m-d'),
|
|
||||||
'currency_id' => (int) $set['currency_id'],
|
|
||||||
'currency_code' => $set['currency_code'],
|
|
||||||
'currency_name' => $set['currency_name'],
|
|
||||||
'currency_symbol' => $set['currency_symbol'],
|
|
||||||
'currency_decimal_places' => (int) $set['currency_decimal_places'],
|
|
||||||
'type' => 'bar', // line, area or bar,
|
|
||||||
'entries' => [],
|
|
||||||
];
|
|
||||||
$sumSpent = bcmul($set['sum'], '-1'); // spent
|
|
||||||
$current['entries']['spent'] = $sumSpent;
|
|
||||||
$current['entries']['amount'] = '0';
|
|
||||||
$current['entries']['spent_capped'] = $sumSpent;
|
|
||||||
$current['entries']['left'] = '0';
|
|
||||||
$current['entries']['overspent'] = '0';
|
|
||||||
$return[] = $current;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BudgetLimit $limit
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
*/
|
|
||||||
private function getExpensesForLimit(BudgetLimit $limit): ?array
|
|
||||||
{
|
|
||||||
$budget = $limit->budget;
|
|
||||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $limit->transactionCurrency);
|
|
||||||
$currency = $limit->transactionCurrency;
|
|
||||||
// when limited to a currency, the count is always one. Or it's empty.
|
|
||||||
$set = array_shift($spent);
|
|
||||||
if (null === $set) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$return = [
|
|
||||||
'label' => sprintf('%s (%s)', $budget->name, $set['currency_name']),
|
|
||||||
'budget_name' => $budget->name,
|
|
||||||
'start_date' => $limit->start_date->format('Y-m-d'),
|
|
||||||
'end_date' => $limit->end_date->format('Y-m-d'),
|
|
||||||
'currency_id' => (int) $currency->id,
|
|
||||||
'currency_code' => $currency->code,
|
|
||||||
'currency_name' => $currency->name,
|
|
||||||
'currency_symbol' => $currency->symbol,
|
|
||||||
'currency_decimal_places' => (int) $currency->decimal_places,
|
|
||||||
'type' => 'bar', // line, area or bar,
|
|
||||||
'entries' => [],
|
|
||||||
];
|
|
||||||
$sumSpent = bcmul($set['sum'], '-1'); // spent
|
|
||||||
$return['entries']['spent'] = $sumSpent;
|
|
||||||
$return['entries']['amount'] = $limit->amount;
|
|
||||||
$return['entries']['spent_capped'] = 1 === bccomp($sumSpent, $limit->amount) ? $limit->amount : $sumSpent;
|
|
||||||
$return['entries']['left'] = 1 === bccomp($limit->amount, $sumSpent) ? bcadd($set['sum'], $limit->amount) : '0'; // left
|
|
||||||
$return['entries']['overspent'] = 1 === bccomp($limit->amount, $sumSpent) ? '0' : bcmul(bcadd($set['sum'], $limit->amount), '-1'); // overspent
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CategoryController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers\Chart;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
|
||||||
use FireflyIII\Api\V1\Requests\DateRequest;
|
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class CategoryController
|
|
||||||
*/
|
|
||||||
class CategoryController extends Controller
|
|
||||||
{
|
|
||||||
/** @var CategoryRepositoryInterface */
|
|
||||||
private $categoryRepository;
|
|
||||||
/** @var NoCategoryRepositoryInterface */
|
|
||||||
private $noCatRepository;
|
|
||||||
/** @var OperationsRepositoryInterface */
|
|
||||||
private $opsRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AccountController constructor.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
|
||||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
|
||||||
$this->noCatRepository = app(NoCategoryRepositoryInterface::class);
|
|
||||||
$this->categoryRepository->setUser($user);
|
|
||||||
$this->opsRepository->setUser($user);
|
|
||||||
$this->noCatRepository->setUser($user);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DateRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function overview(DateRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
// parameters for chart:
|
|
||||||
$dates = $request->getAll();
|
|
||||||
/** @var Carbon $start */
|
|
||||||
$start = $dates['start'];
|
|
||||||
/** @var Carbon $end */
|
|
||||||
$end = $dates['end'];
|
|
||||||
|
|
||||||
|
|
||||||
$tempData = [];
|
|
||||||
$spentWith = $this->opsRepository->listExpenses($start, $end);
|
|
||||||
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
|
|
||||||
$categories = [];
|
|
||||||
|
|
||||||
|
|
||||||
foreach ([$spentWith, $spentWithout,] as $set) {
|
|
||||||
foreach ($set as $currency) {
|
|
||||||
foreach ($currency['categories'] as $category) {
|
|
||||||
$categories[] = $category['name'];
|
|
||||||
$outKey = sprintf('%d-e', $currency['currency_id']);
|
|
||||||
$tempData[$outKey] = $tempData[$outKey] ?? [
|
|
||||||
'currency_id' => $currency['currency_id'],
|
|
||||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
|
||||||
'currency_code' => $currency['currency_code'],
|
|
||||||
'currency_symbol' => $currency['currency_symbol'],
|
|
||||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
|
||||||
'type' => 'bar', // line, area or bar
|
|
||||||
'yAxisID' => 0, // 0, 1, 2
|
|
||||||
'entries' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($category['transaction_journals'] as $journal) {
|
|
||||||
// is it expense or income?
|
|
||||||
$currentKey = sprintf('%d-%s', $currency['currency_id'], 'e');
|
|
||||||
$name = $category['name'];
|
|
||||||
$tempData[$currentKey]['entries'][$name] = $tempData[$currentKey]['entries'][$name] ?? '0';
|
|
||||||
$tempData[$currentKey]['entries'][$name] = bcadd($tempData[$currentKey]['entries'][$name], $journal['amount']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// re-sort every spent array and add 0 for missing entries.
|
|
||||||
foreach ($tempData as $index => $set) {
|
|
||||||
$oldSet = $set['entries'];
|
|
||||||
$newSet = [];
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
$value = $oldSet[$category] ?? '0';
|
|
||||||
$value = -1 === bccomp($value, '0') ? bcmul($value, '-1') : $value;
|
|
||||||
$newSet[$category] = $value;
|
|
||||||
}
|
|
||||||
$tempData[$index]['entries'] = $newSet;
|
|
||||||
}
|
|
||||||
$chartData = array_values($tempData);
|
|
||||||
|
|
||||||
return response()->json($chartData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* ConfigurationController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers;
|
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\ConfigurationRequest;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Models\Configuration;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class ConfigurationController.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class ConfigurationController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/** @var UserRepositoryInterface The user repository */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ConfigurationController constructor.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
$this->repository = app(UserRepositoryInterface::class);
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
if (!$this->repository->hasRole($admin, 'owner')) {
|
|
||||||
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show all configuration.
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$configData = $this->getConfigData();
|
|
||||||
|
|
||||||
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the configuration.
|
|
||||||
*
|
|
||||||
* @param ConfigurationRequest $request
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(ConfigurationRequest $request, string $name): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
app('fireflyconfig')->set($name, $data['value']);
|
|
||||||
$configData = $this->getConfigData();
|
|
||||||
|
|
||||||
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all config values.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getConfigData(): array
|
|
||||||
{
|
|
||||||
/** @var Configuration $isDemoSite */
|
|
||||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site');
|
|
||||||
/** @var Configuration $updateCheck */
|
|
||||||
$updateCheck = app('fireflyconfig')->get('permission_update_check');
|
|
||||||
/** @var Configuration $lastCheck */
|
|
||||||
$lastCheck = app('fireflyconfig')->get('last_update_check');
|
|
||||||
/** @var Configuration $singleUser */
|
|
||||||
$singleUser = app('fireflyconfig')->get('single_user_mode');
|
|
||||||
|
|
||||||
return [
|
|
||||||
'is_demo_site' => null === $isDemoSite ? null : $isDemoSite->data,
|
|
||||||
'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data,
|
|
||||||
'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data,
|
|
||||||
'single_user_mode' => null === $singleUser ? null : $singleUser->data,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -39,61 +39,32 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
|||||||
* Class Controller.
|
* Class Controller.
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class Controller extends BaseController
|
abstract class Controller extends BaseController
|
||||||
{
|
{
|
||||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
|
||||||
/** @var ParameterBag Parameters from the URI are stored here. */
|
protected const CONTENT_TYPE = 'application/vnd.api+json';
|
||||||
protected $parameters;
|
protected ParameterBag $parameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller constructor.
|
* Controller constructor.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// get global parameters
|
// get global parameters
|
||||||
$this->parameters = $this->getParameters();
|
$this->parameters = $this->getParameters();
|
||||||
}
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
if (auth()->check()) {
|
||||||
|
$language = app('steam')->getLanguage();
|
||||||
|
app()->setLocale($language);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return $next($request);
|
||||||
* Method to help build URI's.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected function buildParams(): string
|
|
||||||
{
|
|
||||||
$return = '?';
|
|
||||||
$params = [];
|
|
||||||
foreach ($this->parameters as $key => $value) {
|
|
||||||
if ('page' === $key) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if ($value instanceof Carbon) {
|
);
|
||||||
$params[$key] = $value->format('Y-m-d');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$params[$key] = $value;
|
|
||||||
}
|
|
||||||
$return .= http_build_query($params);
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Manager
|
|
||||||
*/
|
|
||||||
protected function getManager(): Manager
|
|
||||||
{
|
|
||||||
// create some objects:
|
|
||||||
$manager = new Manager;
|
|
||||||
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
|
|
||||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
|
||||||
|
|
||||||
return $manager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +75,7 @@ class Controller extends BaseController
|
|||||||
private function getParameters(): ParameterBag
|
private function getParameters(): ParameterBag
|
||||||
{
|
{
|
||||||
$bag = new ParameterBag;
|
$bag = new ParameterBag;
|
||||||
$page = (int) request()->get('page');
|
$page = (int)request()->get('page');
|
||||||
if (0 === $page) {
|
if (0 === $page) {
|
||||||
$page = 1;
|
$page = 1;
|
||||||
}
|
}
|
||||||
@@ -131,11 +102,47 @@ class Controller extends BaseController
|
|||||||
foreach ($integers as $integer) {
|
foreach ($integers as $integer) {
|
||||||
$value = request()->query->get($integer);
|
$value = request()->query->get($integer);
|
||||||
if (null !== $value) {
|
if (null !== $value) {
|
||||||
$bag->set($integer, (int) $value);
|
$bag->set($integer, (int)$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bag;
|
return $bag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to help build URI's.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
final protected function buildParams(): string
|
||||||
|
{
|
||||||
|
$return = '?';
|
||||||
|
$params = [];
|
||||||
|
foreach ($this->parameters as $key => $value) {
|
||||||
|
if ('page' === $key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value instanceof Carbon) {
|
||||||
|
$params[$key] = $value->format('Y-m-d');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$params[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return . http_build_query($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Manager
|
||||||
|
*/
|
||||||
|
final protected function getManager(): Manager
|
||||||
|
{
|
||||||
|
// create some objects:
|
||||||
|
$manager = new Manager;
|
||||||
|
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
|
||||||
|
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||||
|
|
||||||
|
return $manager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* CurrencyExchangeRateController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
|
||||||
use FireflyIII\Services\Currency\ExchangeRateInterface;
|
|
||||||
use FireflyIII\Transformers\CurrencyExchangeRateTransformer;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class CurrencyExchangeRateController
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class CurrencyExchangeRateController extends Controller
|
|
||||||
{
|
|
||||||
/** @var CurrencyRepositoryInterface The currency repository */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CurrencyExchangeRateController constructor.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
$this->repository = app(CurrencyRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($admin);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show an exchange rate.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function index(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$fromCurrency = $this->repository->findByCodeNull($request->get('from') ?? 'EUR');
|
|
||||||
$toCurrency = $this->repository->findByCodeNull($request->get('to') ?? 'USD');
|
|
||||||
|
|
||||||
if (null === $fromCurrency) {
|
|
||||||
throw new FireflyException('200007: Unknown source currency');
|
|
||||||
}
|
|
||||||
if (null === $toCurrency) {
|
|
||||||
throw new FireflyException('200007: Unknown destination currency');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var Carbon $dateObj */
|
|
||||||
$dateObj = Carbon::createFromFormat('Y-m-d', $request->get('date') ?? date('Y-m-d'));
|
|
||||||
$this->parameters->set('from', $fromCurrency->code);
|
|
||||||
$this->parameters->set('to', $toCurrency->code);
|
|
||||||
$this->parameters->set('date', $dateObj->format('Y-m-d'));
|
|
||||||
$this->parameters->set('amount', $request->get('amount'));
|
|
||||||
|
|
||||||
$rate = $this->repository->getExchangeRate($fromCurrency, $toCurrency, $dateObj);
|
|
||||||
if (null === $rate) {
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
// create service:
|
|
||||||
/** @var ExchangeRateInterface $service */
|
|
||||||
$service = app(ExchangeRateInterface::class);
|
|
||||||
$service->setUser($admin);
|
|
||||||
$rate = $service->getRate($fromCurrency, $toCurrency, $dateObj);
|
|
||||||
}
|
|
||||||
/** @var CurrencyExchangeRateTransformer $transformer */
|
|
||||||
$transformer = app(CurrencyExchangeRateTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
$resource = new Item($rate, $transformer, 'currency_exchange_rates');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
71
app/Api/V1/Controllers/Data/Bulk/AccountController.php
Normal file
71
app/Api/V1/Controllers/Data/Bulk/AccountController.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
/*
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\Data\Bulk;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Data\Bulk\MoveTransactionsRequest;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountController
|
||||||
|
*/
|
||||||
|
class AccountController extends Controller
|
||||||
|
{
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param MoveTransactionsRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accountIds = $request->getAll();
|
||||||
|
$original = $this->repository->findNull($accountIds['original_account']);
|
||||||
|
$destination = $this->repository->findNull($accountIds['destination_account']);
|
||||||
|
|
||||||
|
/** @var AccountDestroyService $service */
|
||||||
|
$service = app(AccountDestroyService::class);
|
||||||
|
$service->moveTransactions($original, $destination);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* DestroyController.php
|
* DestroyController.php
|
||||||
* Copyright (c) 2020 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Api\V1\Controllers\Data;
|
namespace FireflyIII\Api\V1\Controllers\Data;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\DataDestroyRequest;
|
use FireflyIII\Api\V1\Requests\Data\DestroyRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
@@ -52,9 +52,12 @@ use Illuminate\Http\JsonResponse;
|
|||||||
class DestroyController extends Controller
|
class DestroyController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @param DestroyRequest $request
|
||||||
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function destroy(DataDestroyRequest $request): JsonResponse
|
public function destroy(DestroyRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$objects = $request->getObjects();
|
$objects = $request->getObjects();
|
||||||
|
|
||||||
@@ -160,31 +163,6 @@ class DestroyController extends Controller
|
|||||||
return response()->json([], 204);
|
return response()->json([], 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $types
|
|
||||||
*/
|
|
||||||
private function destroyAccounts(array $types): void
|
|
||||||
{
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
|
||||||
$collection = $repository->getAccountsByType($types);
|
|
||||||
$service = app(AccountDestroyService::class);
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($collection as $account) {
|
|
||||||
$service->destroy($account, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function destroyBills(): void
|
|
||||||
{
|
|
||||||
/** @var BillRepositoryInterface $repository */
|
|
||||||
$repository = app(BillRepositoryInterface::class);
|
|
||||||
$repository->destroyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -206,18 +184,11 @@ class DestroyController extends Controller
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function destroyCategories(): void
|
private function destroyBills(): void
|
||||||
{
|
{
|
||||||
/** @var CategoryRepositoryInterface $categoryRepos */
|
/** @var BillRepositoryInterface $repository */
|
||||||
$categoryRepos = app(CategoryRepositoryInterface::class);
|
$repository = app(BillRepositoryInterface::class);
|
||||||
$categoryRepos->destroyAll();
|
$repository->destroyAll();
|
||||||
}
|
|
||||||
|
|
||||||
private function destroyObjectGroups(): void
|
|
||||||
{
|
|
||||||
/** @var ObjectGroupRepositoryInterface $repository */
|
|
||||||
$repository = app(ObjectGroupRepositoryInterface::class);
|
|
||||||
$repository->deleteAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,16 +201,6 @@ class DestroyController extends Controller
|
|||||||
$repository->destroyAll();
|
$repository->destroyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function destroyRecurringTransactions(): void
|
|
||||||
{
|
|
||||||
/** @var RecurringRepositoryInterface $repository */
|
|
||||||
$repository = app(RecurringRepositoryInterface::class);
|
|
||||||
$repository->destroyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -250,6 +211,26 @@ class DestroyController extends Controller
|
|||||||
$repository->destroyAll();
|
$repository->destroyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function destroyRecurringTransactions(): void
|
||||||
|
{
|
||||||
|
/** @var RecurringRepositoryInterface $repository */
|
||||||
|
$repository = app(RecurringRepositoryInterface::class);
|
||||||
|
$repository->destroyAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function destroyCategories(): void
|
||||||
|
{
|
||||||
|
/** @var CategoryRepositoryInterface $categoryRepos */
|
||||||
|
$categoryRepos = app(CategoryRepositoryInterface::class);
|
||||||
|
$categoryRepos->destroyAll();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -260,6 +241,28 @@ class DestroyController extends Controller
|
|||||||
$tagRepository->destroyAll();
|
$tagRepository->destroyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function destroyObjectGroups(): void
|
||||||
|
{
|
||||||
|
/** @var ObjectGroupRepositoryInterface $repository */
|
||||||
|
$repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
$repository->deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $types
|
||||||
|
*/
|
||||||
|
private function destroyAccounts(array $types): void
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$collection = $repository->getAccountsByType($types);
|
||||||
|
$service = app(AccountDestroyService::class);
|
||||||
|
/** @var Account $account */
|
||||||
|
foreach ($collection as $account) {
|
||||||
|
$service->destroy($account, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*/
|
*/
|
||||||
@@ -267,10 +270,10 @@ class DestroyController extends Controller
|
|||||||
{
|
{
|
||||||
/** @var JournalRepositoryInterface $repository */
|
/** @var JournalRepositoryInterface $repository */
|
||||||
$repository = app(JournalRepositoryInterface::class);
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
$journals = $repository->findByType($types);
|
$journals = $repository->findByType($types);
|
||||||
$service = app(JournalDestroyService::class);
|
$service = app(JournalDestroyService::class);
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
foreach($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$service->destroy($journal);
|
$service->destroy($journal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
204
app/Api/V1/Controllers/Data/Export/ExportController.php
Normal file
204
app/Api/V1/Controllers/Data/Export/ExportController.php
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
/*
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\Data\Export;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Data\Export\ExportRequest;
|
||||||
|
use FireflyIII\Support\Export\ExportDataGenerator;
|
||||||
|
use Illuminate\Http\Response as LaravelResponse;
|
||||||
|
use League\Csv\CannotInsertRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExportController
|
||||||
|
*/
|
||||||
|
class ExportController extends Controller
|
||||||
|
{
|
||||||
|
private ExportDataGenerator $exporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ExportController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->exporter = app(ExportDataGenerator::class);
|
||||||
|
$this->exporter->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function accounts(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportAccounts(true);
|
||||||
|
|
||||||
|
return $this->returnExport('accounts');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
private function returnExport(string $key): LaravelResponse
|
||||||
|
{
|
||||||
|
$date = date('Y-m-d-H-i-s');
|
||||||
|
$fileName = sprintf('%s-export-%s.csv', $date, $key);
|
||||||
|
$data = $this->exporter->export();
|
||||||
|
|
||||||
|
/** @var LaravelResponse $response */
|
||||||
|
$response = response($data[$key]);
|
||||||
|
$response
|
||||||
|
->header('Content-Description', 'File Transfer')
|
||||||
|
->header('Content-Type', 'application/octet-stream')
|
||||||
|
->header('Content-Disposition', 'attachment; filename=' . $fileName)
|
||||||
|
->header('Content-Transfer-Encoding', 'binary')
|
||||||
|
->header('Connection', 'Keep-Alive')
|
||||||
|
->header('Expires', '0')
|
||||||
|
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||||
|
->header('Pragma', 'public')
|
||||||
|
->header('Content-Length', (string)strlen($data[$key]));
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function bills(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportBills(true);
|
||||||
|
|
||||||
|
return $this->returnExport('bills');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function budgets(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportBudgets(true);
|
||||||
|
|
||||||
|
return $this->returnExport('budgets');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function categories(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportCategories(true);
|
||||||
|
|
||||||
|
return $this->returnExport('categories');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function piggyBanks(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportPiggies(true);
|
||||||
|
|
||||||
|
return $this->returnExport('piggies');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function recurring(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportRecurring(true);
|
||||||
|
|
||||||
|
return $this->returnExport('recurrences');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function rules(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportRules(true);
|
||||||
|
|
||||||
|
return $this->returnExport('rules');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function tags(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$this->exporter->setExportTags(true);
|
||||||
|
|
||||||
|
return $this->returnExport('tags');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportRequest $request
|
||||||
|
*
|
||||||
|
* @return LaravelResponse
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public function transactions(ExportRequest $request): LaravelResponse
|
||||||
|
{
|
||||||
|
$params = $request->getAll();
|
||||||
|
$this->exporter->setStart($params['start']);
|
||||||
|
$this->exporter->setEnd($params['end']);
|
||||||
|
$this->exporter->setAccounts($params['accounts']);
|
||||||
|
$this->exporter->setExportTransactions(true);
|
||||||
|
|
||||||
|
return $this->returnExport('transactions');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
132
app/Api/V1/Controllers/Insight/Expense/AccountController.php
Normal file
132
app/Api/V1/Controllers/Insight/Expense/AccountController.php
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Class AccountController
|
||||||
|
*
|
||||||
|
* Shows expense information grouped or limited by date.
|
||||||
|
* Ie. all expenses grouped by account + currency.
|
||||||
|
*/
|
||||||
|
class AccountController extends Controller
|
||||||
|
{
|
||||||
|
use ApiSupport;
|
||||||
|
|
||||||
|
private CurrencyRepositoryInterface $currencyRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
||||||
|
$this->currencyRepository->setUser($user);
|
||||||
|
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function asset(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$expenses = $this->opsRepository->sumExpensesBySource($start, $end, $assetAccounts);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$expense['id'],
|
||||||
|
'name' => $expense['name'],
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function expense(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$expenseAccounts = $request->getExpenseAccounts();
|
||||||
|
$expenses = $this->opsRepository->sumExpensesByDestination($start, $end, $assetAccounts, $expenseAccounts);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$expense['id'],
|
||||||
|
'name' => $expense['name'],
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
166
app/Api/V1/Controllers/Insight/Expense/BillController.php
Normal file
166
app/Api/V1/Controllers/Insight/Expense/BillController.php
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BillController
|
||||||
|
*/
|
||||||
|
class BillController extends Controller
|
||||||
|
{
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses per bill, possibly filtered by bill and account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function bill(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$bills = $request->getBills();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// get all bills:
|
||||||
|
if (0 === $bills->count()) {
|
||||||
|
$bills = $this->repository->getBills();
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||||
|
$collector->setBills($bills);
|
||||||
|
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$billId = (int)$journal['bill_id'];
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
$key = sprintf('%d-%d', $billId, $currencyId);
|
||||||
|
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$key] = $response[$key] ?? [
|
||||||
|
'id' => (string)$billId,
|
||||||
|
'name' => $journal['bill_name'],
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
|
||||||
|
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignKey] = $response[$foreignKey] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
|
||||||
|
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses for no bill filtered by account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noBill(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||||
|
$collector->withoutBill();
|
||||||
|
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
127
app/Api/V1/Controllers/Insight/Expense/BudgetController.php
Normal file
127
app/Api/V1/Controllers/Insight/Expense/BudgetController.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* BudgetController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BudgetController
|
||||||
|
*/
|
||||||
|
class BudgetController extends Controller
|
||||||
|
{
|
||||||
|
private NoBudgetRepositoryInterface $noRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->noRepository = app(NoBudgetRepositoryInterface::class);
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->noRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function budget(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$budgets = $request->getBudgets();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
if (0 === $budgets->count()) {
|
||||||
|
$budgets = $this->repository->getActiveBudgets();
|
||||||
|
}
|
||||||
|
/** @var Budget $budget */
|
||||||
|
foreach ($budgets as $budget) {
|
||||||
|
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget]), null);
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$budget->id,
|
||||||
|
'name' => $budget->name,
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noBudget(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts, null);
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
127
app/Api/V1/Controllers/Insight/Expense/CategoryController.php
Normal file
127
app/Api/V1/Controllers/Insight/Expense/CategoryController.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CategoryController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CategoryController
|
||||||
|
*/
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
private NoCategoryRepositoryInterface $noRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->noRepository = app(NoCategoryRepositoryInterface::class);
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->noRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function category(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$categories = $request->getCategories();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
if (0 === $categories->count()) {
|
||||||
|
$categories = $this->repository->getCategories();
|
||||||
|
}
|
||||||
|
/** @var Category $category */
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$category]));
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$category->id,
|
||||||
|
'name' => $category->name,
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noCategory(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts);
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
83
app/Api/V1/Controllers/Insight/Expense/PeriodController.php
Normal file
83
app/Api/V1/Controllers/Insight/Expense/PeriodController.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PeriodController
|
||||||
|
*/
|
||||||
|
class PeriodController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function total(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type)
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
172
app/Api/V1/Controllers/Insight/Expense/TagController.php
Normal file
172
app/Api/V1/Controllers/Insight/Expense/TagController.php
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\Insight\Expense;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TagController
|
||||||
|
*/
|
||||||
|
class TagController extends Controller
|
||||||
|
{
|
||||||
|
private TagRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TagController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(TagRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses for no tag filtered by account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noTag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||||
|
$collector->withoutTags();
|
||||||
|
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses per tag, possibly filtered by tag and account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function tag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$tags = $request->getTags();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// get all tags:
|
||||||
|
if (0 === $tags->count()) {
|
||||||
|
$tags = $this->repository->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||||
|
$collector->setTags($tags);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
/** @var array $journal */
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
/** @var array $tag */
|
||||||
|
foreach ($journal['tags'] as $tag) {
|
||||||
|
$tagId = $tag['id'];
|
||||||
|
$key = sprintf('%d-%d', $tagId, $currencyId);
|
||||||
|
$foreignKey = sprintf('%d-%d', $tagId, $foreignCurrencyId);
|
||||||
|
|
||||||
|
// on currency ID
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$key] = $response[$key] ?? [
|
||||||
|
'id' => (string)$tagId,
|
||||||
|
'name' => $tag['name'],
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
|
||||||
|
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// on foreign ID
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignKey] = $journal[$foreignKey] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
|
||||||
|
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
136
app/Api/V1/Controllers/Insight/Income/AccountController.php
Normal file
136
app/Api/V1/Controllers/Insight/Income/AccountController.php
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Income;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Class AccountController
|
||||||
|
*
|
||||||
|
* Shows income information grouped or limited by date.
|
||||||
|
* Ie. all income grouped by account + currency.
|
||||||
|
* TODO same code as Expense/AccountController.
|
||||||
|
*/
|
||||||
|
class AccountController extends Controller
|
||||||
|
{
|
||||||
|
use ApiSupport;
|
||||||
|
|
||||||
|
private CurrencyRepositoryInterface $currencyRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
||||||
|
$this->currencyRepository->setUser($user);
|
||||||
|
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO same code as Expense/AccountController.
|
||||||
|
* TODO does not actually include the name of the expense account.
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function asset(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
|
||||||
|
$result = [];
|
||||||
|
/** @var array $entry */
|
||||||
|
foreach ($income as $entry) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$entry['id'],
|
||||||
|
'name' => $entry['name'],
|
||||||
|
'difference' => $entry['sum'],
|
||||||
|
'difference_float' => (float)$entry['sum'],
|
||||||
|
'currency_id' => (string)$entry['currency_id'],
|
||||||
|
'currency_code' => $entry['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO does not actually include the name of the expense account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function revenue(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$revenueAccounts = $request->getRevenueAccounts();
|
||||||
|
$income = $this->opsRepository->sumIncomeBySource($start, $end, $assetAccounts, $revenueAccounts);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
/** @var array $entry */
|
||||||
|
foreach ($income as $entry) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$entry['id'],
|
||||||
|
'name' => $entry['name'],
|
||||||
|
'difference' => $entry['sum'],
|
||||||
|
'difference_float' => (float)$entry['sum'],
|
||||||
|
'currency_id' => (string)$entry['currency_id'],
|
||||||
|
'currency_code' => $entry['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
128
app/Api/V1/Controllers/Insight/Income/CategoryController.php
Normal file
128
app/Api/V1/Controllers/Insight/Income/CategoryController.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CategoryController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Income;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CategoryController
|
||||||
|
* TODO same as opposing category controller
|
||||||
|
*/
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
private NoCategoryRepositoryInterface $noRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->noRepository = app(NoCategoryRepositoryInterface::class);
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->noRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function category(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$categories = $request->getCategories();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
if (0 === $categories->count()) {
|
||||||
|
$categories = $this->repository->getCategories();
|
||||||
|
}
|
||||||
|
/** @var Category $category */
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection([$category]));
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$category->id,
|
||||||
|
'name' => $category->name,
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noCategory(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
$expenses = $this->noRepository->sumIncome($start, $end, $assetAccounts);
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Api/V1/Controllers/Insight/Income/PeriodController.php
Normal file
85
app/Api/V1/Controllers/Insight/Income/PeriodController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Income;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PeriodController
|
||||||
|
*/
|
||||||
|
class PeriodController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function total(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type)
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||||
|
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
177
app/Api/V1/Controllers/Insight/Income/TagController.php
Normal file
177
app/Api/V1/Controllers/Insight/Income/TagController.php
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\Insight\Income;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TagController
|
||||||
|
*/
|
||||||
|
class TagController extends Controller
|
||||||
|
{
|
||||||
|
private TagRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TagController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(TagRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses for no tag filtered by account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noTag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$collector->withoutTags();
|
||||||
|
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||||
|
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses per tag, possibly filtered by tag and account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function tag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$tags = $request->getTags();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// get all tags:
|
||||||
|
if (0 === $tags->count()) {
|
||||||
|
$tags = $this->repository->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$collector->setTags($tags);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
/** @var array $journal */
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
/** @var array $tag */
|
||||||
|
foreach ($journal['tags'] as $tag) {
|
||||||
|
$tagId = $tag['id'];
|
||||||
|
$key = sprintf('%d-%d', $tagId, $currencyId);
|
||||||
|
$foreignKey = sprintf('%d-%d', $tagId, $foreignCurrencyId);
|
||||||
|
|
||||||
|
// on currency ID
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$key] = $response[$key] ?? [
|
||||||
|
'id' => (string)$tagId,
|
||||||
|
'name' => $tag['name'],
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// on foreign ID
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignKey] = $journal[$foreignKey] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignKey]['difference'] = bcadd(
|
||||||
|
$response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Transfer;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountController
|
||||||
|
*/
|
||||||
|
class AccountController extends Controller
|
||||||
|
{
|
||||||
|
use ApiSupport;
|
||||||
|
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO same code as Expense/AccountController.
|
||||||
|
* TODO does not actually include the name of the expense account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function asset(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$transfers = $this->opsRepository->sumTransfers($start, $end, $assetAccounts);
|
||||||
|
return response()->json($transfers);
|
||||||
|
}
|
||||||
|
}
|
||||||
126
app/Api/V1/Controllers/Insight/Transfer/CategoryController.php
Normal file
126
app/Api/V1/Controllers/Insight/Transfer/CategoryController.php
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* CategoryController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Transfer;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CategoryController
|
||||||
|
*/
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
private NoCategoryRepositoryInterface $noRepository;
|
||||||
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->noRepository = app(NoCategoryRepositoryInterface::class);
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->opsRepository->setUser($user);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->noRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function category(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$categories = $request->getCategories();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
if (0 === $categories->count()) {
|
||||||
|
$categories = $this->repository->getCategories();
|
||||||
|
}
|
||||||
|
/** @var Category $category */
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection([$category]));
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'id' => (string)$category->id,
|
||||||
|
'name' => $category->name,
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noCategory(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$assetAccounts = $request->getAssetAccounts();
|
||||||
|
$result = [];
|
||||||
|
$expenses = $this->noRepository->sumTransfers($start, $end, $assetAccounts);
|
||||||
|
/** @var array $expense */
|
||||||
|
foreach ($expenses as $expense) {
|
||||||
|
$result[] = [
|
||||||
|
'difference' => $expense['sum'],
|
||||||
|
'difference_float' => (float)$expense['sum'],
|
||||||
|
'currency_id' => (string)$expense['currency_id'],
|
||||||
|
'currency_code' => $expense['currency_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
Normal file
85
app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* PeriodController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Transfer;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PeriodController
|
||||||
|
*/
|
||||||
|
class PeriodController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function total(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type)
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||||
|
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
178
app/Api/V1/Controllers/Insight/Transfer/TagController.php
Normal file
178
app/Api/V1/Controllers/Insight/Transfer/TagController.php
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* TagController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Insight\Transfer;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TagController
|
||||||
|
*/
|
||||||
|
class TagController extends Controller
|
||||||
|
{
|
||||||
|
private TagRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TagController constructor.
|
||||||
|
* TODO lots of copying and pasting here.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(TagRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expenses for no tag filtered by account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function noTag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$collector->withoutTags();
|
||||||
|
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$currencyId] = $response[$currencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
|
||||||
|
}
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||||
|
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfers per tag, possibly filtered by tag and account.
|
||||||
|
*
|
||||||
|
* @param GenericRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function tag(GenericRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$accounts = $request->getAssetAccounts();
|
||||||
|
$tags = $request->getTags();
|
||||||
|
$start = $request->getStart();
|
||||||
|
$end = $request->getEnd();
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
// get all tags:
|
||||||
|
if (0 === $tags->count()) {
|
||||||
|
$tags = $this->repository->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||||
|
$collector->setTags($tags);
|
||||||
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
/** @var array $journal */
|
||||||
|
foreach ($genericSet as $journal) {
|
||||||
|
$currencyId = (int)$journal['currency_id'];
|
||||||
|
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
|
||||||
|
|
||||||
|
/** @var array $tag */
|
||||||
|
foreach ($journal['tags'] as $tag) {
|
||||||
|
$tagId = $tag['id'];
|
||||||
|
$key = sprintf('%d-%d', $tagId, $currencyId);
|
||||||
|
$foreignKey = sprintf('%d-%d', $tagId, $foreignCurrencyId);
|
||||||
|
|
||||||
|
// on currency ID
|
||||||
|
if (0 !== $currencyId) {
|
||||||
|
$response[$key] = $response[$key] ?? [
|
||||||
|
'id' => (string)$tagId,
|
||||||
|
'name' => $tag['name'],
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$currencyId,
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
];
|
||||||
|
$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
|
||||||
|
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// on foreign ID
|
||||||
|
if (0 !== $foreignCurrencyId) {
|
||||||
|
$response[$foreignKey] = $journal[$foreignKey] ?? [
|
||||||
|
'difference' => '0',
|
||||||
|
'difference_float' => 0,
|
||||||
|
'currency_id' => (string)$foreignCurrencyId,
|
||||||
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
|
];
|
||||||
|
$response[$foreignKey]['difference'] = bcadd(
|
||||||
|
$response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount'])
|
||||||
|
);
|
||||||
|
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(array_values($response));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,272 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* LinkTypeController.php
|
|
||||||
* Copyright (c) 2019 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\Api\V1\Controllers;
|
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\LinkTypeRequest;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
|
||||||
use FireflyIII\Models\LinkType;
|
|
||||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
|
||||||
use FireflyIII\Transformers\LinkTypeTransformer;
|
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class LinkTypeController.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class LinkTypeController extends Controller
|
|
||||||
{
|
|
||||||
use TransactionFilter;
|
|
||||||
/** @var LinkTypeRepositoryInterface The link type repository */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/** @var UserRepositoryInterface The user repository */
|
|
||||||
private $userRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LinkTypeController constructor.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
$this->repository = app(LinkTypeRepositoryInterface::class);
|
|
||||||
$this->userRepository = app(UserRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($user);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the resource.
|
|
||||||
*
|
|
||||||
* @param LinkType $linkType
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function delete(LinkType $linkType): JsonResponse
|
|
||||||
{
|
|
||||||
if (false === $linkType->editable) {
|
|
||||||
throw new FireflyException('200020: Link type cannot be changed.');
|
|
||||||
}
|
|
||||||
$this->repository->destroy($linkType);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List all of them.
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
// create some objects:
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
|
|
||||||
// get list of accounts. Count it and split it.
|
|
||||||
$collection = $this->repository->get();
|
|
||||||
$count = $collection->count();
|
|
||||||
$linkTypes = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
|
|
||||||
// make paginator:
|
|
||||||
$paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.link_types.index') . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var LinkTypeTransformer $transformer */
|
|
||||||
$transformer = app(LinkTypeTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($linkTypes, $transformer, 'link_types');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List single resource.
|
|
||||||
*
|
|
||||||
* @param LinkType $linkType
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function show(LinkType $linkType): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
/** @var LinkTypeTransformer $transformer */
|
|
||||||
$transformer = app(LinkTypeTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($linkType, $transformer, 'link_types');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store new object.
|
|
||||||
*
|
|
||||||
* @param LinkTypeRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(LinkTypeRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
|
||||||
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$data = $request->getAll();
|
|
||||||
// if currency ID is 0, find the currency by the code:
|
|
||||||
$linkType = $this->repository->store($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var LinkTypeTransformer $transformer */
|
|
||||||
$transformer = app(LinkTypeTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
$resource = new Item($linkType, $transformer, 'link_types');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the resource.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @param LinkType $linkType
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function transactions(Request $request, LinkType $linkType): JsonResponse
|
|
||||||
{
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
$type = $request->get('type') ?? 'default';
|
|
||||||
$this->parameters->set('type', $type);
|
|
||||||
|
|
||||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
// whatever is returned by the query, it must be part of these journals:
|
|
||||||
$journalIds = $this->repository->getJournalIds($linkType);
|
|
||||||
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
// use new group collector:
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
|
||||||
$collector = app(GroupCollectorInterface::class);
|
|
||||||
$collector
|
|
||||||
->setUser($admin)
|
|
||||||
// filter on journal IDs.
|
|
||||||
->setJournalIds($journalIds)
|
|
||||||
// all info needed for the API:
|
|
||||||
->withAPIInformation()
|
|
||||||
// set page size:
|
|
||||||
->setLimit($pageSize)
|
|
||||||
// set page to retrieve
|
|
||||||
->setPage($this->parameters->get('page'))
|
|
||||||
// set types of transactions to return.
|
|
||||||
->setTypes($types);
|
|
||||||
|
|
||||||
|
|
||||||
if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
|
|
||||||
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
|
|
||||||
}
|
|
||||||
$paginator = $collector->getPaginatedGroups();
|
|
||||||
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
|
|
||||||
$transactions = $paginator->getCollection();
|
|
||||||
|
|
||||||
/** @var TransactionGroupTransformer $transformer */
|
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update object.
|
|
||||||
*
|
|
||||||
* @param LinkTypeRequest $request
|
|
||||||
* @param LinkType $linkType
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(LinkTypeRequest $request, LinkType $linkType): JsonResponse
|
|
||||||
{
|
|
||||||
if (false === $linkType->editable) {
|
|
||||||
throw new FireflyException('200020: Link type cannot be changed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
|
||||||
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $request->getAll();
|
|
||||||
$this->repository->update($linkType, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
/** @var LinkTypeTransformer $transformer */
|
|
||||||
$transformer = app(LinkTypeTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($linkType, $transformer, 'link_types');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
72
app/Api/V1/Controllers/Models/Account/DestroyController.php
Normal file
72
app/Api/V1/Controllers/Models/Account/DestroyController.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2019 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\Api\V1\Controllers\Models\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
public const RESOURCE_KEY = 'accounts';
|
||||||
|
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Account $account): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($account, null);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,16 +21,13 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\Account;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\AccountStoreRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\AccountUpdateRequest;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Transformers\AccountTransformer;
|
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\Transformers\PiggyBankTransformer;
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
@@ -41,18 +38,17 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccountController.
|
* Class ListController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AccountController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
use AccountFilter, TransactionFilter;
|
use TransactionFilter;
|
||||||
|
|
||||||
|
public const RESOURCE_KEY = 'accounts';
|
||||||
|
|
||||||
private AccountRepositoryInterface $repository;
|
private AccountRepositoryInterface $repository;
|
||||||
public const RESOURCE_KEY = 'accounts';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController constructor.
|
* AccountController constructor.
|
||||||
@@ -64,11 +60,8 @@ class AccountController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
// @var AccountRepositoryInterface repository
|
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->repository->setUser($user);
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@@ -84,7 +77,7 @@ class AccountController extends Controller
|
|||||||
public function attachments(Account $account): JsonResponse
|
public function attachments(Account $account): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$collection = $this->repository->getAttachments($account);
|
$collection = $this->repository->getAttachments($account);
|
||||||
|
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
@@ -101,63 +94,9 @@ class AccountController extends Controller
|
|||||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param Account $account
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function delete(Account $account): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($account, null);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function index(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$type = $request->get('type') ?? 'all';
|
|
||||||
$this->parameters->set('type', $type);
|
|
||||||
|
|
||||||
// types to get, page size:
|
|
||||||
$types = $this->mapAccountTypes($this->parameters->get('type'));
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
|
|
||||||
// get list of accounts. Count it and split it.
|
|
||||||
$collection = $this->repository->getAccountsByType($types);
|
|
||||||
$count = $collection->count();
|
|
||||||
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
|
|
||||||
// make paginator:
|
|
||||||
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());
|
|
||||||
|
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
|
||||||
$transformer = app(AccountTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all piggies.
|
* List all piggies.
|
||||||
*
|
*
|
||||||
@@ -165,7 +104,6 @@ class AccountController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function piggyBanks(Account $account): JsonResponse
|
public function piggyBanks(Account $account): JsonResponse
|
||||||
{
|
{
|
||||||
@@ -173,7 +111,7 @@ class AccountController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
// types to get, page size:
|
// types to get, page size:
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// get list of budgets. Count it and split it.
|
// get list of budgets. Count it and split it.
|
||||||
$collection = $this->repository->getPiggyBanks($account);
|
$collection = $this->repository->getPiggyBanks($account);
|
||||||
@@ -191,51 +129,10 @@ class AccountController extends Controller
|
|||||||
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
|
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show single instance.
|
|
||||||
*
|
|
||||||
* @param Account $account
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function show(Account $account): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
|
||||||
$transformer = app(AccountTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a new instance.
|
|
||||||
*
|
|
||||||
* @param AccountStoreRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(AccountStoreRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAllAccountData();
|
|
||||||
$account = $this->repository->store($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
|
||||||
$transformer = app(AccountTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show all transaction groups related to the account.
|
* Show all transaction groups related to the account.
|
||||||
*
|
*
|
||||||
@@ -245,11 +142,10 @@ class AccountController extends Controller
|
|||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function transactions(Request $request, Account $account): JsonResponse
|
public function transactions(Request $request, Account $account): JsonResponse
|
||||||
{
|
{
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$type = $request->get('type') ?? 'default';
|
$type = $request->get('type') ?? 'default';
|
||||||
$this->parameters->set('type', $type);
|
$this->parameters->set('type', $type);
|
||||||
|
|
||||||
@@ -284,29 +180,6 @@ class AccountController extends Controller
|
|||||||
$resource = new FractalCollection($groups, $transformer, 'transactions');
|
$resource = new FractalCollection($groups, $transformer, 'transactions');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update account.
|
|
||||||
*
|
|
||||||
* @param AccountUpdateRequest $request
|
|
||||||
* @param Account $account
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(AccountUpdateRequest $request, Account $account): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getUpdateData();
|
|
||||||
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
|
||||||
$this->repository->update($account, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
|
||||||
$transformer = app(AccountTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
127
app/Api/V1/Controllers/Models/Account/ShowController.php
Normal file
127
app/Api/V1/Controllers/Models/Account/ShowController.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||||
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
use AccountFilter;
|
||||||
|
|
||||||
|
public const RESOURCE_KEY = 'accounts';
|
||||||
|
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$type = $request->get('type') ?? 'all';
|
||||||
|
$this->parameters->set('type', $type);
|
||||||
|
|
||||||
|
// types to get, page size:
|
||||||
|
$types = $this->mapAccountTypes($this->parameters->get('type'));
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
|
// get list of accounts. Count it and split it.
|
||||||
|
$this->repository->resetAccountOrder();
|
||||||
|
$collection = $this->repository->getAccountsByType($types);
|
||||||
|
$count = $collection->count();
|
||||||
|
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var AccountTransformer $transformer */
|
||||||
|
$transformer = app(AccountTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show single instance.
|
||||||
|
*
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function show(Account $account): JsonResponse
|
||||||
|
{
|
||||||
|
// get list of accounts. Count it and split it.
|
||||||
|
$this->repository->resetAccountOrder();
|
||||||
|
$account->refresh();
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AccountTransformer $transformer */
|
||||||
|
$transformer = app(AccountTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
83
app/Api/V1/Controllers/Models/Account/StoreController.php
Normal file
83
app/Api/V1/Controllers/Models/Account/StoreController.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2019 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\Api\V1\Controllers\Models\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Account\StoreRequest;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
public const RESOURCE_KEY = 'accounts';
|
||||||
|
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a new instance.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAllAccountData();
|
||||||
|
$this->repository->resetAccountOrder();
|
||||||
|
$account = $this->repository->store($data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AccountTransformer $transformer */
|
||||||
|
$transformer = app(AccountTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
86
app/Api/V1/Controllers/Models/Account/UpdateController.php
Normal file
86
app/Api/V1/Controllers/Models/Account/UpdateController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AccountController.php
|
||||||
|
* Copyright (c) 2019 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\Api\V1\Controllers\Models\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Account\UpdateRequest;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
public const RESOURCE_KEY = 'accounts';
|
||||||
|
|
||||||
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccountController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update account.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Account $account): JsonResponse
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
|
$data = $request->getUpdateData();
|
||||||
|
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||||
|
$account = $this->repository->update($account, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$account->refresh();
|
||||||
|
|
||||||
|
/** @var AccountTransformer $transformer */
|
||||||
|
$transformer = app(AccountTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Attachment;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private AttachmentRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DestroyController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*
|
||||||
|
* @param Attachment $attachment
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Attachment $attachment): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($attachment);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* AttachmentController.php
|
* ShowController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -21,39 +21,31 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\Attachment;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||||
use FireflyIII\Api\V1\Requests\AttachmentStoreRequest;
|
|
||||||
use FireflyIII\Api\V1\Requests\AttachmentUpdateRequest;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
|
||||||
use FireflyIII\Http\Middleware\IsDemoUser;
|
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Response as LaravelResponse;
|
use Illuminate\Http\Response as LaravelResponse;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use Log;
|
|
||||||
use function strlen;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AttachmentController.
|
* Class ShowController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AttachmentController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
/** @var AttachmentRepositoryInterface The attachment repository */
|
private AttachmentRepositoryInterface $repository;
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController constructor.
|
* ShowController constructor.
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
@@ -68,36 +60,19 @@ class AttachmentController extends Controller
|
|||||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||||
$this->repository->setUser($user);
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @param Attachment $attachment
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function delete(Attachment $attachment): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($attachment);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download an attachment.
|
* Download an attachment.
|
||||||
*
|
*
|
||||||
* @param Attachment $attachment
|
* @param Attachment $attachment
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @throws FireflyException
|
|
||||||
* @return LaravelResponse
|
* @return LaravelResponse
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function download(Attachment $attachment): LaravelResponse
|
public function download(Attachment $attachment): LaravelResponse
|
||||||
{
|
{
|
||||||
@@ -125,7 +100,7 @@ class AttachmentController extends Controller
|
|||||||
->header('Expires', '0')
|
->header('Expires', '0')
|
||||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||||
->header('Pragma', 'public')
|
->header('Pragma', 'public')
|
||||||
->header('Content-Length', strlen($content));
|
->header('Content-Length', (string)strlen($content));
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
@@ -143,9 +118,9 @@ class AttachmentController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
// types to get, page size:
|
// types to get, page size:
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// get list of accounts. Count it and split it.
|
// get list of attachments. Count it and split it.
|
||||||
$collection = $this->repository->get();
|
$collection = $this->repository->get();
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
@@ -161,7 +136,7 @@ class AttachmentController extends Controller
|
|||||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,78 +155,6 @@ class AttachmentController extends Controller
|
|||||||
|
|
||||||
$resource = new Item($attachment, $transformer, 'attachments');
|
$resource = new Item($attachment, $transformer, 'attachments');
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param AttachmentStoreRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(AttachmentStoreRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$attachment = $this->repository->store($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AttachmentTransformer $transformer */
|
|
||||||
$transformer = app(AttachmentTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($attachment, $transformer, 'attachments');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @param AttachmentUpdateRequest $request
|
|
||||||
* @param Attachment $attachment
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(AttachmentUpdateRequest $request, Attachment $attachment): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$this->repository->update($attachment, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AttachmentTransformer $transformer */
|
|
||||||
$transformer = app(AttachmentTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($attachment, $transformer, 'attachments');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload an attachment.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @param Attachment $attachment
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function upload(Request $request, Attachment $attachment): JsonResponse
|
|
||||||
{
|
|
||||||
/** @var AttachmentHelperInterface $helper */
|
|
||||||
$helper = app(AttachmentHelperInterface::class);
|
|
||||||
$body = $request->getContent();
|
|
||||||
if ('' === $body) {
|
|
||||||
Log::error('Body of attachment is empty.');
|
|
||||||
|
|
||||||
return response()->json([], 422);
|
|
||||||
}
|
|
||||||
$helper->saveAttachmentFromApi($attachment, $body);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
116
app/Api/V1/Controllers/Models/Attachment/StoreController.php
Normal file
116
app/Api/V1/Controllers/Models/Attachment/StoreController.php
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Attachment;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Attachment\StoreRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
private AttachmentRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StoreController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
|
$data = $request->getAll();
|
||||||
|
$attachment = $this->repository->store($data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AttachmentTransformer $transformer */
|
||||||
|
$transformer = app(AttachmentTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($attachment, $transformer, 'attachments');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload an attachment.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param Attachment $attachment
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function upload(Request $request, Attachment $attachment): JsonResponse
|
||||||
|
{
|
||||||
|
/** @var AttachmentHelperInterface $helper */
|
||||||
|
$helper = app(AttachmentHelperInterface::class);
|
||||||
|
$body = $request->getContent();
|
||||||
|
if ('' === $body) {
|
||||||
|
Log::error('Body of attachment is empty.');
|
||||||
|
|
||||||
|
return response()->json([], 422);
|
||||||
|
}
|
||||||
|
$helper->saveAttachmentFromApi($attachment, $body);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Attachment;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Attachment\UpdateRequest;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private AttachmentRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Attachment $attachment
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Attachment $attachment): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$this->repository->update($attachment, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AttachmentTransformer $transformer */
|
||||||
|
$transformer = app(AttachmentTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($attachment, $transformer, 'attachments');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\AvailableBudget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\AvailableBudget;
|
||||||
|
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private AvailableBudgetRepositoryInterface $abRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AvailableBudgetController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||||
|
$this->abRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param AvailableBudget $availableBudget
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function destroy(AvailableBudget $availableBudget): JsonResponse
|
||||||
|
{
|
||||||
|
$this->abRepository->destroyAvailableBudget($availableBudget);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* AvailableBudgetController.php
|
* ShowController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -21,12 +21,10 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\AvailableBudget;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\AvailableBudgetRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
|
||||||
use FireflyIII\Models\AvailableBudget;
|
use FireflyIII\Models\AvailableBudget;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||||
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
@@ -37,13 +35,11 @@ use League\Fractal\Resource\Collection as FractalCollection;
|
|||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AvailableBudgetController.
|
* Class ShowController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AvailableBudgetController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
/** @var AvailableBudgetRepositoryInterface */
|
private AvailableBudgetRepositoryInterface $abRepository;
|
||||||
private $abRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AvailableBudgetController constructor.
|
* AvailableBudgetController constructor.
|
||||||
@@ -65,22 +61,6 @@ class AvailableBudgetController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param AvailableBudget $availableBudget
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function delete(AvailableBudget $availableBudget): JsonResponse
|
|
||||||
{
|
|
||||||
$this->abRepository->destroyAvailableBudget($availableBudget);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
@@ -92,7 +72,7 @@ class AvailableBudgetController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
// types to get, page size:
|
// types to get, page size:
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
$start = $this->parameters->get('start');
|
$start = $this->parameters->get('start');
|
||||||
$end = $this->parameters->get('end');
|
$end = $this->parameters->get('end');
|
||||||
@@ -113,7 +93,7 @@ class AvailableBudgetController extends Controller
|
|||||||
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
|
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,77 +114,7 @@ class AvailableBudgetController extends Controller
|
|||||||
|
|
||||||
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param AvailableBudgetRequest $request
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(AvailableBudgetRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
/** @var TransactionCurrencyFactory $factory */
|
|
||||||
$factory = app(TransactionCurrencyFactory::class);
|
|
||||||
$currency = $factory->find($data['currency_id'], $data['currency_code']);
|
|
||||||
|
|
||||||
if (null === $currency) {
|
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
|
||||||
}
|
|
||||||
$data['currency'] = $currency;
|
|
||||||
$availableBudget = $this->abRepository->store($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AvailableBudgetTransformer $transformer */
|
|
||||||
$transformer = app(AvailableBudgetTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @param AvailableBudgetRequest $request
|
|
||||||
* @param AvailableBudget $availableBudget
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(AvailableBudgetRequest $request, AvailableBudget $availableBudget): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
|
|
||||||
/** @var TransactionCurrencyFactory $factory */
|
|
||||||
$factory = app(TransactionCurrencyFactory::class);
|
|
||||||
/** @var TransactionCurrency $currency */
|
|
||||||
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
|
|
||||||
|
|
||||||
if (null === $currency) {
|
|
||||||
// use default currency:
|
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
|
||||||
}
|
|
||||||
$currency->enabled = true;
|
|
||||||
$currency->save();
|
|
||||||
unset($data['currency_code']);
|
|
||||||
$data['currency_id'] = $currency->id;
|
|
||||||
|
|
||||||
|
|
||||||
$this->abRepository->updateAvailableBudget($availableBudget, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var AvailableBudgetTransformer $transformer */
|
|
||||||
$transformer = app(AvailableBudgetTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\AvailableBudget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\AvailableBudget\Request;
|
||||||
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
|
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
private AvailableBudgetRepositoryInterface $abRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AvailableBudgetController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||||
|
$this->abRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$data['start']->startOfDay();
|
||||||
|
$data['end']->endOfDay();
|
||||||
|
|
||||||
|
// currency is not mandatory:
|
||||||
|
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
|
||||||
|
$factory = app(TransactionCurrencyFactory::class);
|
||||||
|
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
|
||||||
|
$data['currency_id'] = $currency->id;
|
||||||
|
unset($data['currency_code']);
|
||||||
|
}
|
||||||
|
if (!array_key_exists('currency_id', $data)) {
|
||||||
|
$currency = app('amount')->getDefaultCurrencyByUser(auth()->user());
|
||||||
|
$data['currency_id'] = $currency->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$availableBudget = $this->abRepository->store($data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AvailableBudgetTransformer $transformer */
|
||||||
|
$transformer = app(AvailableBudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\AvailableBudget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\AvailableBudget\Request;
|
||||||
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
|
use FireflyIII\Models\AvailableBudget;
|
||||||
|
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private AvailableBudgetRepositoryInterface $abRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AvailableBudgetController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||||
|
$this->abRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param AvailableBudget $availableBudget
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(Request $request, AvailableBudget $availableBudget): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
|
||||||
|
// find and validate currency ID
|
||||||
|
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
|
||||||
|
$factory = app(TransactionCurrencyFactory::class);
|
||||||
|
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null) ?? app('amount')->getDefaultCurrency();
|
||||||
|
$currency->enabled = true;
|
||||||
|
$currency->save();
|
||||||
|
unset($data['currency_code']);
|
||||||
|
$data['currency_id'] = $currency->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->abRepository->updateAvailableBudget($availableBudget, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var AvailableBudgetTransformer $transformer */
|
||||||
|
$transformer = app(AvailableBudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($availableBudget, $transformer, 'available_budgets');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Api/V1/Controllers/Models/Bill/DestroyController.php
Normal file
72
app/Api/V1/Controllers/Models/Bill/DestroyController.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Bill;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Bill $bill
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function destroy(Bill $bill): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($bill);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
/**
|
* ListController.php
|
||||||
* BillController.php
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -22,16 +21,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\Bill;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\BillRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
|
||||||
use FireflyIII\Transformers\RuleTransformer;
|
use FireflyIII\Transformers\RuleTransformer;
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
@@ -40,17 +37,15 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BillController.
|
* Class ListController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class BillController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
use TransactionFilter;
|
use TransactionFilter;
|
||||||
/** @var BillRepositoryInterface The bill repository */
|
|
||||||
private $repository;
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillController constructor.
|
* BillController constructor.
|
||||||
@@ -62,12 +57,8 @@ class BillController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
/** @var BillRepositoryInterface repository */
|
|
||||||
$this->repository = app(BillRepositoryInterface::class);
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
$this->repository->setUser($admin);
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@@ -85,7 +76,7 @@ class BillController extends Controller
|
|||||||
public function attachments(Bill $bill): JsonResponse
|
public function attachments(Bill $bill): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$collection = $this->repository->getAttachments($bill);
|
$collection = $this->repository->getAttachments($bill);
|
||||||
|
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
@@ -102,47 +93,7 @@ class BillController extends Controller
|
|||||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param Bill $bill
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function delete(Bill $bill): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($bill);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$bills = $this->repository->getBills();
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
$count = $bills->count();
|
|
||||||
$bills = $bills->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
|
||||||
$transformer = app(BillTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($bills, $transformer, 'bills');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +109,7 @@ class BillController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
// types to get, page size:
|
// types to get, page size:
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// get list of budgets. Count it and split it.
|
// get list of budgets. Count it and split it.
|
||||||
$collection = $this->repository->getRulesForBill($bill);
|
$collection = $this->repository->getRulesForBill($bill);
|
||||||
@@ -172,57 +123,13 @@ class BillController extends Controller
|
|||||||
/** @var RuleTransformer $transformer */
|
/** @var RuleTransformer $transformer */
|
||||||
$transformer = app(RuleTransformer::class);
|
$transformer = app(RuleTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
|
||||||
$resource = new FractalCollection($rules, $transformer, 'rules');
|
$resource = new FractalCollection($rules, $transformer, 'rules');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the specified bill.
|
|
||||||
*
|
|
||||||
* @param Bill $bill
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function show(Bill $bill): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
/** @var BillTransformer $transformer */
|
|
||||||
$transformer = app(BillTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($bill, $transformer, 'bills');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a bill.
|
|
||||||
*
|
|
||||||
* @param BillRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(BillRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$bill = $this->repository->store($request->getAll());
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
|
||||||
$transformer = app(BillTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($bill, $transformer, 'bills');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show all transactions.
|
* Show all transactions.
|
||||||
*
|
*
|
||||||
@@ -235,7 +142,7 @@ class BillController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function transactions(Request $request, Bill $bill): JsonResponse
|
public function transactions(Request $request, Bill $bill): JsonResponse
|
||||||
{
|
{
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$type = $request->get('type') ?? 'default';
|
$type = $request->get('type') ?? 'default';
|
||||||
$this->parameters->set('type', $type);
|
$this->parameters->set('type', $type);
|
||||||
|
|
||||||
@@ -278,30 +185,7 @@ class BillController extends Controller
|
|||||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a bill.
|
|
||||||
*
|
|
||||||
* @param BillRequest $request
|
|
||||||
* @param Bill $bill
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(BillRequest $request, Bill $bill): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$bill = $this->repository->update($bill, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
|
||||||
$transformer = app(BillTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($bill, $transformer, 'bills');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
107
app/Api/V1/Controllers/Models/Bill/ShowController.php
Normal file
107
app/Api/V1/Controllers/Models/Bill/ShowController.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Bill;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->correctOrder();
|
||||||
|
$bills = $this->repository->getBills();
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$count = $bills->count();
|
||||||
|
$bills = $bills->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
|
||||||
|
/** @var BillTransformer $transformer */
|
||||||
|
$transformer = app(BillTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($bills, $transformer, 'bills');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified bill.
|
||||||
|
*
|
||||||
|
* @param Bill $bill
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function show(Bill $bill): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
/** @var BillTransformer $transformer */
|
||||||
|
$transformer = app(BillTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($bill, $transformer, 'bills');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Api/V1/Controllers/Models/Bill/StoreController.php
Normal file
85
app/Api/V1/Controllers/Models/Bill/StoreController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Bill;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Bill\StoreRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
use TransactionFilter;
|
||||||
|
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a bill.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$bill = $this->repository->store($data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BillTransformer $transformer */
|
||||||
|
$transformer = app(BillTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($bill, $transformer, 'bills');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
84
app/Api/V1/Controllers/Models/Bill/UpdateController.php
Normal file
84
app/Api/V1/Controllers/Models/Bill/UpdateController.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Bill;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Bill\UpdateRequest;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private BillRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BillController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BillRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a bill.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Bill $bill
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Bill $bill): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$bill = $this->repository->update($bill, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BillTransformer $transformer */
|
||||||
|
$transformer = app(BillTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($bill, $transformer, 'bills');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
70
app/Api/V1/Controllers/Models/Budget/DestroyController.php
Normal file
70
app/Api/V1/Controllers/Models/Budget/DestroyController.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Budget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DestroyController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Budget $budget
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function destroy(Budget $budget): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($budget);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* BudgetController.php
|
* ListController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -21,13 +21,9 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\Budget;
|
||||||
|
|
||||||
use Exception;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
|
|
||||||
use FireflyIII\Api\V1\Requests\BudgetStoreRequest;
|
|
||||||
use FireflyIII\Api\V1\Requests\BudgetUpdateRequest;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
@@ -35,7 +31,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\Transformers\BudgetLimitTransformer;
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||||
use FireflyIII\Transformers\BudgetTransformer;
|
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -43,22 +38,19 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
/***
|
||||||
* Class BudgetController.
|
* Class ListController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class BudgetController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
use TransactionFilter;
|
use TransactionFilter;
|
||||||
/** @var BudgetLimitRepositoryInterface */
|
|
||||||
private $blRepository;
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
/** @var BudgetRepositoryInterface The budget repository */
|
private BudgetRepositoryInterface $repository;
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetController constructor.
|
* ListController constructor.
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
@@ -67,49 +59,16 @@ class BudgetController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
$this->repository->setUser($admin);
|
$this->repository->setUser(auth()->user());
|
||||||
$this->blRepository->setUser($admin);
|
$this->blRepository->setUser(auth()->user());
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @param Budget $budget
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function budgetLimits(Budget $budget): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
$this->parameters->set('budget_id', $budget->id);
|
|
||||||
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
|
|
||||||
$count = $collection->count();
|
|
||||||
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.budgets.budget_limits', [$budget->id]) . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
|
|
||||||
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
@@ -119,7 +78,7 @@ class BudgetController extends Controller
|
|||||||
public function attachments(Budget $budget): JsonResponse
|
public function attachments(Budget $budget): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$collection = $this->repository->getAttachments($budget);
|
$collection = $this->repository->getAttachments($budget);
|
||||||
|
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
@@ -136,123 +95,35 @@ class BudgetController extends Controller
|
|||||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param Budget $budget
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function delete(Budget $budget): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($budget);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
// types to get, page size:
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
|
|
||||||
// get list of budgets. Count it and split it.
|
|
||||||
$collection = $this->repository->getBudgets();
|
|
||||||
$count = $collection->count();
|
|
||||||
$budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
|
|
||||||
// make paginator:
|
|
||||||
$paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.budgets.index') . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var BudgetTransformer $transformer */
|
|
||||||
$transformer = app(BudgetTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($budgets, $transformer, 'budgets');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a budget.
|
|
||||||
*
|
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function show(Budget $budget): JsonResponse
|
public function budgetLimits(Budget $budget): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
/** @var BudgetTransformer $transformer */
|
$this->parameters->set('budget_id', $budget->id);
|
||||||
$transformer = app(BudgetTransformer::class);
|
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
|
||||||
$transformer->setParameters($this->parameters);
|
$count = $collection->count();
|
||||||
|
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
$resource = new Item($budget, $transformer, 'budgets');
|
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.budgets.budget_limits', [$budget->id]) . $this->buildParams());
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a budget.
|
|
||||||
*
|
|
||||||
* @param BudgetStoreRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(BudgetStoreRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$budget = $this->repository->store($request->getAll());
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetTransformer $transformer */
|
|
||||||
$transformer = app(BudgetTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($budget, $transformer, 'budgets');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param BudgetLimitRequest $request
|
|
||||||
* @param Budget $budget
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function storeBudgetLimit(BudgetLimitRequest $request, Budget $budget): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$data['budget'] = $budget;
|
|
||||||
$budgetLimit = $this->blRepository->storeBudgetLimit($data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetLimitTransformer $transformer */
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
$transformer = app(BudgetLimitTransformer::class);
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,7 +138,7 @@ class BudgetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function transactions(Request $request, Budget $budget): JsonResponse
|
public function transactions(Request $request, Budget $budget): JsonResponse
|
||||||
{
|
{
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// user can overrule page size with limit parameter.
|
// user can overrule page size with limit parameter.
|
||||||
$limit = $this->parameters->get('limit');
|
$limit = $this->parameters->get('limit');
|
||||||
@@ -311,36 +182,10 @@ class BudgetController extends Controller
|
|||||||
/** @var TransactionGroupTransformer $transformer */
|
/** @var TransactionGroupTransformer $transformer */
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
$transformer = app(TransactionGroupTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
|
||||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a budget.
|
|
||||||
*
|
|
||||||
* @param BudgetUpdateRequest $request
|
|
||||||
* @param Budget $budget
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(BudgetUpdateRequest $request, Budget $budget): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$budget = $this->repository->update($budget, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var BudgetTransformer $transformer */
|
|
||||||
$transformer = app(BudgetTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($budget, $transformer, 'budgets');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
118
app/Api/V1/Controllers/Models/Budget/ShowController.php
Normal file
118
app/Api/V1/Controllers/Models/Budget/ShowController.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Budget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ListController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
$this->blRepository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// types to get, page size:
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
|
// get list of budgets. Count it and split it.
|
||||||
|
$collection = $this->repository->getBudgets();
|
||||||
|
$count = $collection->count();
|
||||||
|
$budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.budgets.index') . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var BudgetTransformer $transformer */
|
||||||
|
$transformer = app(BudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($budgets, $transformer, 'budgets');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a budget.
|
||||||
|
*
|
||||||
|
* @param Budget $budget
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function show(Budget $budget): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BudgetTransformer $transformer */
|
||||||
|
$transformer = app(BudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budget, $transformer, 'budgets');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
82
app/Api/V1/Controllers/Models/Budget/StoreController.php
Normal file
82
app/Api/V1/Controllers/Models/Budget/StoreController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Budget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Budget\StoreRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StoreController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a budget.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$budget = $this->repository->store($request->getAll());
|
||||||
|
$budget->refresh();
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BudgetTransformer $transformer */
|
||||||
|
$transformer = app(BudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budget, $transformer, 'budgets');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Api/V1/Controllers/Models/Budget/UpdateController.php
Normal file
82
app/Api/V1/Controllers/Models/Budget/UpdateController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Budget;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Budget\UpdateRequest;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a budget.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Budget $budget
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Budget $budget): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$budget = $this->repository->update($budget, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BudgetTransformer $transformer */
|
||||||
|
$transformer = app(BudgetTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budget, $transformer, 'budgets');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\BudgetLimit;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetLimitController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Budget $budget
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function destroy(Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||||
|
{
|
||||||
|
if ($budget->id !== $budgetLimit->budget_id) {
|
||||||
|
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||||
|
}
|
||||||
|
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
121
app/Api/V1/Controllers/Models/BudgetLimit/ListController.php
Normal file
121
app/Api/V1/Controllers/Models/BudgetLimit/ListController.php
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ListController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\BudgetLimit;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListController
|
||||||
|
*/
|
||||||
|
class ListController extends Controller
|
||||||
|
{
|
||||||
|
use TransactionFilter;
|
||||||
|
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetLimitController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show all transactions.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param Budget $budget
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||||
|
{
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$type = $request->get('type') ?? 'default';
|
||||||
|
$this->parameters->set('type', $type);
|
||||||
|
|
||||||
|
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
|
||||||
|
// use new group collector:
|
||||||
|
/** @var GroupCollectorInterface $collector */
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$collector
|
||||||
|
->setUser($admin)
|
||||||
|
// filter on budget.
|
||||||
|
->setBudget($budget)
|
||||||
|
// all info needed for the API:
|
||||||
|
->withAPIInformation()
|
||||||
|
// set page size:
|
||||||
|
->setLimit($pageSize)
|
||||||
|
// set page to retrieve
|
||||||
|
->setPage($this->parameters->get('page'))
|
||||||
|
// set types of transactions to return.
|
||||||
|
->setTypes($types);
|
||||||
|
|
||||||
|
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||||
|
$collector->setTypes($types);
|
||||||
|
$paginator = $collector->getPaginatedGroups();
|
||||||
|
$paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]) . $this->buildParams());
|
||||||
|
$transactions = $paginator->getCollection();
|
||||||
|
|
||||||
|
/** @var TransactionGroupTransformer $transformer */
|
||||||
|
$transformer = app(TransactionGroupTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
154
app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
Normal file
154
app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\BudgetLimit;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
private BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetLimitController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the budget limits for this budget..
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function index(Request $request, Budget $budget): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$manager->parseIncludes('budget');
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
|
||||||
|
$count = $collection->count();
|
||||||
|
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]) . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the budget limits for this budget..
|
||||||
|
*
|
||||||
|
* @param DateRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function indexAll(DateRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$manager->parseIncludes('budget');
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$collection = $this->blRepository->getAllBudgetLimits($this->parameters->get('start'), $this->parameters->get('end'));
|
||||||
|
$count = $collection->count();
|
||||||
|
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.budget-limits.index') . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param Budget $budget
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||||
|
{
|
||||||
|
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
|
||||||
|
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||||
|
}
|
||||||
|
// continue!
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\BudgetLimit;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\BudgetLimit\StoreRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetLimitController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request, Budget $budget): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$data['start_date'] = $data['start'];
|
||||||
|
$data['end_date'] = $data['end'];
|
||||||
|
$data['budget_id'] = $budget->id;
|
||||||
|
|
||||||
|
$budgetLimit = $this->blRepository->store($data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\BudgetLimit;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\BudgetLimit\UpdateRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private BudgetLimitRepositoryInterface $blRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BudgetLimitController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Budget $budget
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
|
||||||
|
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||||
|
}
|
||||||
|
$data = $request->getAll();
|
||||||
|
$data['budget_id'] = $budget->id;
|
||||||
|
$budgetLimit = $this->blRepository->update($budgetLimit, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var BudgetLimitTransformer $transformer */
|
||||||
|
$transformer = app(BudgetLimitTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
71
app/Api/V1/Controllers/Models/Category/DestroyController.php
Normal file
71
app/Api/V1/Controllers/Models/Category/DestroyController.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Category;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Category $category
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function destroy(Category $category): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($category);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* CategoryController.php
|
* ListController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -21,16 +21,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\Category;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\CategoryRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\Transformers\CategoryTransformer;
|
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -38,17 +36,15 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CategoryController.
|
* Class ListController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class CategoryController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
use TransactionFilter;
|
use TransactionFilter;
|
||||||
/** @var CategoryRepositoryInterface The category repository */
|
|
||||||
private $repository;
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryController constructor.
|
* CategoryController constructor.
|
||||||
@@ -60,12 +56,8 @@ class CategoryController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
/** @var User $admin */
|
|
||||||
$admin = auth()->user();
|
|
||||||
|
|
||||||
/** @var CategoryRepositoryInterface repository */
|
|
||||||
$this->repository = app(CategoryRepositoryInterface::class);
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
$this->repository->setUser($admin);
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@@ -81,7 +73,7 @@ class CategoryController extends Controller
|
|||||||
public function attachments(Category $category): JsonResponse
|
public function attachments(Category $category): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$collection = $this->repository->getAttachments($category);
|
$collection = $this->repository->getAttachments($category);
|
||||||
|
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
@@ -98,99 +90,7 @@ class CategoryController extends Controller
|
|||||||
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param Category $category
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function delete(Category $category): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($category);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the resource.
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
// types to get, page size:
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
|
|
||||||
// get list of budgets. Count it and split it.
|
|
||||||
$collection = $this->repository->getCategories();
|
|
||||||
$count = $collection->count();
|
|
||||||
$categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
|
|
||||||
// make paginator:
|
|
||||||
$paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.categories.index') . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var CategoryTransformer $transformer */
|
|
||||||
$transformer = app(CategoryTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
|
|
||||||
$resource = new FractalCollection($categories, $transformer, 'categories');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the category.
|
|
||||||
*
|
|
||||||
* @param Category $category
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function show(Category $category): JsonResponse
|
|
||||||
{
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var CategoryTransformer $transformer */
|
|
||||||
$transformer = app(CategoryTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($category, $transformer, 'categories');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store new category.
|
|
||||||
*
|
|
||||||
* @param CategoryRequest $request
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function store(CategoryRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$category = $this->repository->store($request->getAll());
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var CategoryTransformer $transformer */
|
|
||||||
$transformer = app(CategoryTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($category, $transformer, 'categories');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,7 +105,7 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function transactions(Request $request, Category $category): JsonResponse
|
public function transactions(Request $request, Category $category): JsonResponse
|
||||||
{
|
{
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$type = $request->get('type') ?? 'default';
|
$type = $request->get('type') ?? 'default';
|
||||||
$this->parameters->set('type', $type);
|
$this->parameters->set('type', $type);
|
||||||
|
|
||||||
@@ -246,31 +146,7 @@ class CategoryController extends Controller
|
|||||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the category.
|
|
||||||
*
|
|
||||||
* @param CategoryRequest $request
|
|
||||||
* @param Category $category
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(CategoryRequest $request, Category $category): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
$category = $this->repository->update($category, $data);
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var CategoryTransformer $transformer */
|
|
||||||
$transformer = app(CategoryTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new Item($category, $transformer, 'categories');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
113
app/Api/V1/Controllers/Models/Category/ShowController.php
Normal file
113
app/Api/V1/Controllers/Models/Category/ShowController.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Category;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\CategoryTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// types to get, page size:
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
|
// get list of budgets. Count it and split it.
|
||||||
|
$collection = $this->repository->getCategories();
|
||||||
|
$count = $collection->count();
|
||||||
|
$categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.categories.index') . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var CategoryTransformer $transformer */
|
||||||
|
$transformer = app(CategoryTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
$resource = new FractalCollection($categories, $transformer, 'categories');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the category.
|
||||||
|
*
|
||||||
|
* @param Category $category
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function show(Category $category): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var CategoryTransformer $transformer */
|
||||||
|
$transformer = app(CategoryTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($category, $transformer, 'categories');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Api/V1/Controllers/Models/Category/StoreController.php
Normal file
82
app/Api/V1/Controllers/Models/Category/StoreController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StoreController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Category;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Category\StoreRequest;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\CategoryTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class StoreController
|
||||||
|
*/
|
||||||
|
class StoreController extends Controller
|
||||||
|
{
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store new category.
|
||||||
|
*
|
||||||
|
* @param StoreRequest $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$category = $this->repository->store($request->getAll());
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var CategoryTransformer $transformer */
|
||||||
|
$transformer = app(CategoryTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($category, $transformer, 'categories');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
83
app/Api/V1/Controllers/Models/Category/UpdateController.php
Normal file
83
app/Api/V1/Controllers/Models/Category/UpdateController.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\Category;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\Category\UpdateRequest;
|
||||||
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\CategoryTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private CategoryRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the category.
|
||||||
|
*
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param Category $category
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, Category $category): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
$category = $this->repository->update($category, $data);
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var CategoryTransformer $transformer */
|
||||||
|
$transformer = app(CategoryTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($category, $transformer, 'categories');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\ObjectGroup;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\ObjectGroup;
|
||||||
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private ObjectGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObjectGroupController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param ObjectGroup $objectGroup
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function destroy(ObjectGroup $objectGroup): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($objectGroup);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
131
app/Api/V1/Controllers/Models/ObjectGroup/ListController.php
Normal file
131
app/Api/V1/Controllers/Models/ObjectGroup/ListController.php
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ListController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\ObjectGroup;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\ObjectGroup;
|
||||||
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListController
|
||||||
|
*/
|
||||||
|
class ListController extends Controller
|
||||||
|
{
|
||||||
|
private ObjectGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObjectGroupController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all bills
|
||||||
|
*
|
||||||
|
* @param ObjectGroup $objectGroup
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function bills(ObjectGroup $objectGroup): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
// get list of piggy banks. Count it and split it.
|
||||||
|
$collection = $this->repository->getBills($objectGroup);
|
||||||
|
$count = $collection->count();
|
||||||
|
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]) . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var BillTransformer $transformer */
|
||||||
|
$transformer = app(BillTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($bills, $transformer, 'bills');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all piggies under the object group.
|
||||||
|
*
|
||||||
|
* @param ObjectGroup $objectGroup
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function piggyBanks(ObjectGroup $objectGroup): JsonResponse
|
||||||
|
{
|
||||||
|
// create some objects:
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// types to get, page size:
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
|
// get list of piggy banks. Count it and split it.
|
||||||
|
$collection = $this->repository->getPiggyBanks($objectGroup);
|
||||||
|
$count = $collection->count();
|
||||||
|
$piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.object-groups.piggy_banks', [$objectGroup->id]) . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var PiggyBankTransformer $transformer */
|
||||||
|
$transformer = app(PiggyBankTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* GroupController.php
|
* ShowController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@@ -21,14 +21,12 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\ObjectGroupUpdateRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\ObjectGroup;
|
use FireflyIII\Models\ObjectGroup;
|
||||||
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
use FireflyIII\Transformers\ObjectGroupTransformer;
|
use FireflyIII\Transformers\ObjectGroupTransformer;
|
||||||
use FireflyIII\Transformers\PiggyBankTransformer;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -38,10 +36,9 @@ use League\Fractal\Resource\Collection as FractalCollection;
|
|||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GroupController.
|
* Class ShowController
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class ObjectGroupController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
private ObjectGroupRepositoryInterface $repository;
|
private ObjectGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
@@ -65,21 +62,6 @@ class ObjectGroupController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param ObjectGroup $objectGroup
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function delete(ObjectGroup $objectGroup): JsonResponse
|
|
||||||
{
|
|
||||||
$this->repository->destroy($objectGroup);
|
|
||||||
|
|
||||||
return response()->json([], 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
@@ -93,9 +75,9 @@ class ObjectGroupController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
// types to get, page size:
|
// types to get, page size:
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// get list of accounts. Count it and split it.
|
$this->repository->resetOrder();
|
||||||
$collection = $this->repository->get();
|
$collection = $this->repository->get();
|
||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
$objectGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
$objectGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
@@ -111,45 +93,7 @@ class ObjectGroupController extends Controller
|
|||||||
$resource = new FractalCollection($objectGroups, $transformer, 'object_groups');
|
$resource = new FractalCollection($objectGroups, $transformer, 'object_groups');
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List all piggies under the object group.
|
|
||||||
*
|
|
||||||
* @param ObjectGroup $objectGroup
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function piggyBanks(ObjectGroup $objectGroup): JsonResponse
|
|
||||||
{
|
|
||||||
// create some objects:
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
// types to get, page size:
|
|
||||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
|
||||||
|
|
||||||
// get list of piggy banks. Count it and split it.
|
|
||||||
$collection = $this->repository->getPiggyBanks($objectGroup);
|
|
||||||
$count = $collection->count();
|
|
||||||
$piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
|
||||||
|
|
||||||
// make paginator:
|
|
||||||
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
|
|
||||||
$paginator->setPath(route('api.v1.object-groups.piggy_banks', [$objectGroup->id]) . $this->buildParams());
|
|
||||||
|
|
||||||
/** @var PiggyBankTransformer $transformer */
|
|
||||||
$transformer = app(PiggyBankTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
|
|
||||||
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
|
|
||||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,35 +106,14 @@ class ObjectGroupController extends Controller
|
|||||||
public function show(ObjectGroup $objectGroup): JsonResponse
|
public function show(ObjectGroup $objectGroup): JsonResponse
|
||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
$this->repository->resetOrder();
|
||||||
|
$objectGroup->refresh();
|
||||||
|
|
||||||
/** @var ObjectGroupTransformer $transformer */
|
/** @var ObjectGroupTransformer $transformer */
|
||||||
$transformer = app(ObjectGroupTransformer::class);
|
$transformer = app(ObjectGroupTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
$resource = new Item($objectGroup, $transformer, 'object_groups');
|
$resource = new Item($objectGroup, $transformer, 'object_groups');
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update object.
|
|
||||||
*
|
|
||||||
* @param ObjectGroupUpdateRequest $request
|
|
||||||
* @param Account $account
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(ObjectGroupUpdateRequest $request, ObjectGroup $objectGroup): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getUpdateData();
|
|
||||||
$this->repository->update($objectGroup, $data);
|
|
||||||
$this->repository->sort();
|
|
||||||
$manager = $this->getManager();
|
|
||||||
|
|
||||||
/** @var ObjectGroupTransformer $transformer */
|
|
||||||
$transformer = app(ObjectGroupTransformer::class);
|
|
||||||
$transformer->setParameters($this->parameters);
|
|
||||||
$resource = new Item($objectGroup, $transformer, 'object_groups');
|
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* UpdateController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\ObjectGroup;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\Models\ObjectGroup\UpdateRequest;
|
||||||
|
use FireflyIII\Models\ObjectGroup;
|
||||||
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\ObjectGroupTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UpdateController
|
||||||
|
*/
|
||||||
|
class UpdateController extends Controller
|
||||||
|
{
|
||||||
|
private ObjectGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObjectGroupController constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
$this->repository->setUser($user);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param UpdateRequest $request
|
||||||
|
* @param ObjectGroup $objectGroup
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRequest $request, ObjectGroup $objectGroup): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getUpdateData();
|
||||||
|
$this->repository->update($objectGroup, $data);
|
||||||
|
$this->repository->resetOrder();
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var ObjectGroupTransformer $transformer */
|
||||||
|
$transformer = app(ObjectGroupTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
$resource = new Item($objectGroup, $transformer, 'object_groups');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* DestroyController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\PiggyBank;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DestroyController
|
||||||
|
*/
|
||||||
|
class DestroyController extends Controller
|
||||||
|
{
|
||||||
|
private PiggyBankRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the resource.
|
||||||
|
*
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function destroy(PiggyBank $piggyBank): JsonResponse
|
||||||
|
{
|
||||||
|
$this->repository->destroy($piggyBank);
|
||||||
|
|
||||||
|
return response()->json([], 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
122
app/Api/V1/Controllers/Models/PiggyBank/ListController.php
Normal file
122
app/Api/V1/Controllers/Models/PiggyBank/ListController.php
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ListController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\PiggyBank;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
|
use FireflyIII\Transformers\PiggyBankEventTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListController
|
||||||
|
*/
|
||||||
|
class ListController extends Controller
|
||||||
|
{
|
||||||
|
private PiggyBankRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function attachments(PiggyBank $piggyBank): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$collection = $this->repository->getAttachments($piggyBank);
|
||||||
|
|
||||||
|
$count = $collection->count();
|
||||||
|
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.piggy_banks.attachments', [$piggyBank->id]) . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var AttachmentTransformer $transformer */
|
||||||
|
$transformer = app(AttachmentTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($attachments, $transformer, 'attachments');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List single resource.
|
||||||
|
*
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse
|
||||||
|
{
|
||||||
|
// types to get, page size:
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
$collection = $this->repository->getEvents($piggyBank);
|
||||||
|
$count = $collection->count();
|
||||||
|
$events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.piggy_banks.events', [$piggyBank->id]) . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var PiggyBankEventTransformer $transformer */
|
||||||
|
$transformer = app(PiggyBankEventTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
114
app/Api/V1/Controllers/Models/PiggyBank/ShowController.php
Normal file
114
app/Api/V1/Controllers/Models/PiggyBank/ShowController.php
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ShowController.php
|
||||||
|
* Copyright (c) 2021 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\Api\V1\Controllers\Models\PiggyBank;
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ShowController
|
||||||
|
*/
|
||||||
|
class ShowController extends Controller
|
||||||
|
{
|
||||||
|
private PiggyBankRepositoryInterface $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
$this->repository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$this->repository->setUser(auth()->user());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all of them.
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
// types to get, page size:
|
||||||
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
|
|
||||||
|
// get list of budgets. Count it and split it.
|
||||||
|
$collection = $this->repository->getPiggyBanks();
|
||||||
|
$count = $collection->count();
|
||||||
|
$piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// make paginator:
|
||||||
|
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
|
||||||
|
$paginator->setPath(route('api.v1.piggy_banks.index') . $this->buildParams());
|
||||||
|
|
||||||
|
/** @var PiggyBankTransformer $transformer */
|
||||||
|
$transformer = app(PiggyBankTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List single resource.
|
||||||
|
*
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function show(PiggyBank $piggyBank): JsonResponse
|
||||||
|
{
|
||||||
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
/** @var PiggyBankTransformer $transformer */
|
||||||
|
$transformer = app(PiggyBankTransformer::class);
|
||||||
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
$resource = new Item($piggyBank, $transformer, 'piggy_banks');
|
||||||
|
|
||||||
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user