Compare commits

..

132 Commits

Author SHA1 Message Date
James Cole
4b7460c1cf Merge branch 'release/5.1.0-beta.1' 2020-02-23 07:47:37 +01:00
James Cole
8c8a2a1596 Fix query for attachment icon. 2020-02-23 07:38:23 +01:00
James Cole
ee7731b1a1 Render new JS 2020-02-23 07:09:51 +01:00
James Cole
36e4462957 Update some language strings. 2020-02-23 07:09:09 +01:00
James Cole
e71a4a5595 update version 2020-02-23 07:05:45 +01:00
James Cole
287aa76d8d update composer 2020-02-23 07:05:36 +01:00
James Cole
a9738fc2a9 Update changelog. 2020-02-23 07:05:30 +01:00
James Cole
bc485363ca Restore attachment icon (not yet in all views). Fixes #3142 2020-02-23 06:59:41 +01:00
James Cole
f53e9d91c0 Fix #3143 2020-02-23 06:37:37 +01:00
James Cole
99fd90ee49 Add installation ID 2020-02-23 06:37:04 +01:00
James Cole
fb77210f2c Add installation ID 2020-02-23 06:36:58 +01:00
James Cole
6c163ebef3 Add debug information. 2020-02-22 11:05:16 +01:00
James Cole
1d8f34275a Flash success message. 2020-02-22 06:28:18 +01:00
James Cole
1fcc2f6b39 Updated a lot of language strings. 2020-02-22 06:21:56 +01:00
James Cole
2eaa31163c Fix link #3140 2020-02-21 20:58:20 +01:00
James Cole
3de4441bcd Trigger cache to fix #3141 2020-02-21 20:47:10 +01:00
James Cole
cbc43b9dc1 Merge pull request #3137 from DanYoSon/trans-format-fix
add 2 <th> to fix header row border, fix alignment on action btn
2020-02-21 05:05:10 +00:00
Daniel Idzerda
d018c57b17 add 2 <th> to fix header row border, fix alignment on action btn 2020-02-20 20:21:03 -05:00
James Cole
a5d0658241 Fix #3135 2020-02-19 20:13:09 +01:00
James Cole
ce29beaf55 Fix bad role names #3129 2020-02-19 20:06:41 +01:00
James Cole
b11bcc1fbe Trigger cache, fixes #3127 2020-02-19 19:55:35 +01:00
James Cole
ab0e77a2e8 New and optimised Vue code, courtesy of @GaryQ 2020-02-19 17:13:01 +01:00
James Cole
80f0637c77 Fix #3130 2020-02-19 07:17:58 +01:00
James Cole
a280319a0b Merge pull request #3131 from cpmsmith/patch-1
Fix search modifiers claiming the whole query
2020-02-18 04:19:51 +00:00
Calum Smith
eb3a55d6e0 Fix search modifiers claiming the whole query
The regex was only restricting to characters without the Unicode property Other, which is most characters, including spaces.
2020-02-17 20:35:15 -05:00
James Cole
64a6661ea4 Update email address. 2020-02-16 14:00:57 +01:00
James Cole
7f46cf805c Update email address. 2020-02-16 13:59:55 +01:00
James Cole
d0d5dea5ce Update email address. 2020-02-16 13:59:41 +01:00
James Cole
018ca29184 Update email address. 2020-02-16 13:58:48 +01:00
James Cole
4b4f78b9eb Update email address. 2020-02-16 13:58:33 +01:00
James Cole
f084e742c9 Update email address. 2020-02-16 13:58:22 +01:00
James Cole
ab4de3fdd6 Update email address. 2020-02-16 13:57:18 +01:00
James Cole
9f7d5b8e88 Update email address. 2020-02-16 13:57:05 +01:00
James Cole
4958f6e4a6 Update email address. 2020-02-16 13:56:52 +01:00
James Cole
b3e3a17add Update email address. 2020-02-16 13:56:35 +01:00
James Cole
0b25fdd043 Update email address. 2020-02-16 13:56:25 +01:00
James Cole
cfc48ccc26 Update email address. 2020-02-16 13:55:59 +01:00
James Cole
3810085ea6 Update email address. 2020-02-16 13:55:52 +01:00
James Cole
0088886915 Update email address. 2020-02-16 13:55:32 +01:00
James Cole
c427404e5d Merge tag '5.1.0-alpha.1' into develop
5.1.0-alpha.1
2020-02-16 06:57:54 +01:00
James Cole
e8bf53ad11 Merge branch 'release/5.1.0-alpha.1' 2020-02-16 06:57:52 +01:00
James Cole
5f7f4328c1 Final files for the 5.1.0-alpha.1 release. 2020-02-16 06:53:52 +01:00
James Cole
1f1829e3b5 Fix a rare issue where ID's are missing. Probably the root cause is something else. 2020-02-15 06:56:39 +01:00
James Cole
8079fab472 Final file update before alpha release. 2020-02-14 13:54:26 +01:00
James Cole
19a428bf2d Fix null pointers. 2020-02-14 13:14:06 +01:00
James Cole
39cdbc461e Fix #3114 2020-02-14 08:43:57 +01:00
James Cole
ccc80dd437 Commit untranslated sentences. 2020-02-14 08:43:23 +01:00
James Cole
f1539c4cba Fix budget limit redirect for #3111 2020-02-14 08:13:12 +01:00
James Cole
796188603b Remove HTML from string. 2020-02-14 08:09:05 +01:00
James Cole
b7210e296f Update JS + language strings. 2020-02-14 08:08:51 +01:00
James Cole
6df03e2537 Updated and new strings. 2020-02-14 08:07:45 +01:00
James Cole
7843e781da Fix #3073 2020-02-14 07:49:29 +01:00
James Cole
bf2d1c223b Throw error for invalid transactions. 2020-02-14 05:46:34 +01:00
James Cole
400c0ccaca Add checks to fix #3119 2020-02-14 05:40:46 +01:00
James Cole
db05839b87 Add checks to fix #3119 2020-02-14 05:39:21 +01:00
James Cole
50d4774907 Merge tag '5.0.5' into develop
5.0.5

# Conflicts:
#	changelog.md
2020-02-13 20:16:17 +01:00
James Cole
5361fbb76f Merge branch 'hotfix/5.0.5' 2020-02-13 20:15:46 +01:00
James Cole
a389cbe521 Fix the issue. 2020-02-13 20:15:36 +01:00
James Cole
08b85cfa1a update version 2020-02-13 20:15:29 +01:00
James Cole
7e354b9c30 Add info to changelog. 2020-02-13 20:15:21 +01:00
James Cole
4cdc2ade01 update libraries and config. 2020-02-13 20:13:17 +01:00
James Cole
dee6c0e1e4 New string for #3118 2020-02-13 20:11:10 +01:00
James Cole
72491250b7 Add more details to 500 page if user has debug disabled. 2020-02-13 20:10:54 +01:00
James Cole
88e2d8cd55 Fix 500 page. 2020-02-13 20:10:09 +01:00
James Cole
fd04a38359 Fix some button issues. 2020-02-13 20:09:59 +01:00
James Cole
529cb3d387 Fix #3118 2020-02-13 20:09:27 +01:00
James Cole
8d806e6a1d Fix issues related to #3111 2020-02-11 05:34:36 +01:00
James Cole
2a38c9b4ef Fix a rare null pointer 2020-02-10 19:15:35 +01:00
James Cole
2e3e18d836 Merge pull request #3104 from GeoffreyFrogeye/fix_attach_dialog
Fixed Transaction page attachment broken due to #3097
2020-02-09 15:27:33 +00:00
Geoffrey “Frogeye” Preud'homme
156c51798d Fixed Transaction attachment broken due to #3097 2020-02-09 15:36:20 +01:00
James Cole
8fb72fe697 Add todo, uncomment cache line. Expand count 2020-02-09 10:06:38 +01:00
James Cole
ccb1f56573 Various JS changes. 2020-02-09 09:32:33 +01:00
James Cole
c8d2053500 Append changelog. 2020-02-09 09:22:38 +01:00
James Cole
4b5b47a078 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-02-09 09:21:27 +01:00
James Cole
930695b188 Add line 2020-02-09 09:21:20 +01:00
James Cole
d51e5798ef Merge pull request #3100 from Agraphie/master
Move redis comment to different line
2020-02-08 13:40:08 +00:00
Agraphie
edaa2c168a Move redis comment to different line
The comment in the variable caused redis to use `"0" #always use quotes` as redis db index instead of just "0"
2020-02-08 13:55:31 +01:00
James Cole
4dc24939ba Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-02-08 12:59:56 +01:00
James Cole
4cd642b8da Fix #3099 2020-02-08 12:59:43 +01:00
James Cole
b77b3f0c21 Merge pull request #3098 from GeoffreyFrogeye/link_type_id
API: Add link_type_id when reading TransactionLink
2020-02-08 11:54:27 +00:00
James Cole
0acc2c5727 Merge pull request #3097 from GeoffreyFrogeye/att_unif
API: Unified attachment_* and model_* for Attachments
2020-02-08 11:54:01 +00:00
Geoffrey “Frogeye” Preud'homme
5aae8b7743 API: Add link_type_id when reading TransactionLink 2020-02-08 12:38:15 +01:00
Geoffrey “Frogeye” Preud'homme
e81ce3317c API: Unified attachment_* and model_* for Attachments 2020-02-08 12:29:23 +01:00
James Cole
cebc0d7568 Add a debug view for transactions. 2020-02-08 06:42:07 +01:00
James Cole
d5cfc12bf3 Clone button. 2020-02-07 20:52:13 +01:00
James Cole
ac931698d3 Code for #3052 2020-02-07 20:51:25 +01:00
James Cole
0c13ac2e93 Fix some old debug code. 2020-02-07 20:50:46 +01:00
James Cole
685107e950 Add DNS to debug. 2020-02-07 18:27:49 +01:00
James Cole
ae57be74e0 Add port to DSN 2020-02-07 18:26:47 +01:00
James Cole
58c0a69737 Fix #3083 2020-02-07 11:16:52 +01:00
James Cole
ab73322c58 Update email addresses. 2020-02-07 11:16:38 +01:00
James Cole
c2e7e00cdd Demo user can trigger error. 2020-02-06 22:01:59 +01:00
James Cole
554a702c0a A special commit for @SuperSandro2000 😉 2020-02-06 21:54:47 +01:00
James Cole
2a3775968c Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-02-06 21:48:44 +01:00
James Cole
3cb01a9b50 Update groups.twig 2020-02-06 15:05:29 +01:00
James Cole
e54a011e0c More validation for #3080 2020-02-05 20:37:23 +01:00
James Cole
fc81833b50 Update email address 2020-02-05 05:53:12 +01:00
James Cole
067246be79 Check if object is countable, fix #3080 2020-02-04 19:20:34 +01:00
James Cole
11997f0f97 Fix #3082 2020-02-04 17:39:38 +01:00
James Cole
635ef0de77 Fix #3075 2020-02-03 20:00:02 +01:00
James Cole
7f3522339c Simplify update check. 2020-02-02 10:39:37 +01:00
James Cole
f99f166623 Merge tag '5.0.4' into develop
5.0.4

# Conflicts:
#	changelog.md
#	config/firefly.php
2020-02-01 16:17:24 +01:00
James Cole
fb574cb173 Expand changelog. 2020-02-01 15:54:36 +01:00
James Cole
cf4adae604 Refactor category chart code. 2020-02-01 15:54:26 +01:00
James Cole
3f6719dc70 Add Lando to readme. 2020-02-01 15:44:03 +01:00
James Cole
7cdfbc48a9 Fix #3070 2020-02-01 06:32:28 +01:00
James Cole
28b7bd4d71 Improve box for #3071 2020-02-01 06:19:12 +01:00
James Cole
d056f0d221 Allows the user to set the default language for new and unauthenticated visitors. 2020-01-31 07:39:24 +01:00
James Cole
3771cc3b75 Update email address 2020-01-31 07:32:04 +01:00
James Cole
c7f25c5486 Middleware to generate unique ID for Firefly III installation. 2020-01-31 07:24:41 +01:00
James Cole
b697b71e59 Some updates to the tag overview for #3066 and #3067 2020-01-30 18:56:08 +01:00
James Cole
a6fab50c20 Fix #3064 2020-01-30 18:35:00 +01:00
James Cole
43232c208f Merge tag '5.0.3' into develop
5.0.3

# Conflicts:
#	config/firefly.php
2020-01-30 04:49:28 +01:00
James Cole
1c502667b1 Merge tag '5.0.2' into develop
5.0.2
2020-01-30 04:44:24 +01:00
James Cole
d28bf1f8a4 Update email address 2020-01-28 08:46:01 +01:00
James Cole
091cd05527 Update email address 2020-01-28 08:45:38 +01:00
James Cole
08b9cfa221 Update email address 2020-01-28 08:45:28 +01:00
James Cole
42f585f630 Update email address 2020-01-28 08:44:57 +01:00
James Cole
67fb906855 Expand accounts for #2999 2020-01-27 19:53:05 +01:00
James Cole
6655d2e3d0 Add startofday 2020-01-27 19:37:22 +01:00
James Cole
3711cbd9d7 Fix name of language. 2020-01-27 19:37:14 +01:00
James Cole
17c8be37f5 Update language configuration. 2020-01-27 19:33:58 +01:00
James Cole
90b3bce361 Fix #3042 2020-01-26 07:36:11 +01:00
James Cole
51aca7f415 Second try for #3050 2020-01-26 07:15:47 +01:00
James Cole
a381dc1cfe It's the little things. Fixed #3050 2020-01-25 23:29:26 +01:00
James Cole
bf07859718 Various CSS fixes. 2020-01-25 06:40:41 +01:00
James Cole
996fc4dc7c Code for #2575 2020-01-25 06:32:15 +01:00
James Cole
f598c39c6e Add debug info for #3051 2020-01-25 06:17:17 +01:00
James Cole
f4fd9e5a15 Update email address 2020-01-25 06:08:56 +01:00
James Cole
3adc43938e Make 'stack' log to 'stdout' AND 'daily' to satisfy both Docker and self-hosted users. 2020-01-24 20:40:23 +01:00
James Cole
3f7891f4e8 Fix #3045 2020-01-24 06:02:18 +01:00
James Cole
68d53a2066 Merge tag '5.0.1' into develop
5.0.1
2020-01-24 05:39:29 +01:00
1560 changed files with 9286 additions and 4877 deletions

View File

@@ -15,3 +15,4 @@ el_GR
sv_SE
zh-hans_CN
zh-hant_CN
fi_FI

View File

@@ -15,6 +15,12 @@ SITE_OWNER=mail@example.com
# 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/master/resources/lang
#
# If text is still in English, remember that not everything may have been translated.
DEFAULT_LANGUAGE=en_US
# Change this value to your preferred time zone.
# Example: Europe/Amsterdam
@@ -48,6 +54,7 @@ APP_LOG_LEVEL=notice
# 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 "mysql" for MySQL and MariaDB. Use "sqlite" for SQLite.
DB_CONNECTION=pgsql
DB_HOST=firefly_iii_db
DB_PORT=5432
@@ -73,7 +80,8 @@ SESSION_DRIVER=file
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_DB="0" # always use quotes
# 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.
@@ -206,6 +214,11 @@ DISABLE_CSP_HEADER=false
TRACKER_SITE_ID=
TRACKER_URL=
#
# Firefly III could (in the future) collect telemetry on how you use Firefly III.
# In order to allow this, change the following variable to true:
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.

View File

@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at thegrumpydictator@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at james@firefly-iii.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

View File

@@ -4,7 +4,7 @@
## Feature requests
I am always interested in expanding Firefly III's many features. Just open a ticket or [drop me a line](mailto:thegrumpydictator@gmail.com).
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

2
.github/security.md vendored
View File

@@ -6,7 +6,7 @@ Only the latest version of Firefly III is supported. If you're not running the l
## Reporting a Vulnerability
If you find something that compromises the security of Firefly III, you should [send me a message](mailto:thegrumpydictator@gmail.com) as soon as possible. These issues will be fixed immediately. You can also open an issue, but if you feel the issue is sensitive, please drop me a message instead.
If you find something that compromises the security of Firefly III, you should [send me a message](mailto:james@firefly-iii.org) as soon as possible. These issues will be fixed immediately. You can also open an issue, but if you feel the issue is sensitive, please drop me a message instead.
You can use my [GPG key](https://keybase.io/jc5) for extra security. My [GitHub commits](https://github.com/firefly-iii/firefly-iii/commits/master) are almost always signed with this key.

View File

@@ -90,12 +90,12 @@ class CategoryController extends Controller
$tempData = [];
$spentWith = $this->opsRepository->listExpenses($start, $end);
$earnedWith = $this->opsRepository->listIncome($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
$earnedWithout = $this->noCatRepository->listIncome($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end); // refactored
$earnedWithout = $this->noCatRepository->listIncome($start, $end); // refactored
$categories = [];
foreach ([$spentWith, $earnedWith] as $set) {
foreach ([$spentWith, $earnedWith, $spentWithout, $earnedWithout] as $set) {
foreach ($set as $currency) {
foreach ($currency['categories'] as $category) {
$categories[] = $category['name'];
@@ -141,48 +141,48 @@ class CategoryController extends Controller
}
}
foreach ([$spentWithout, $earnedWithout] as $set) {
foreach ($set as $currency) {
$inKey = sprintf('%d-i', $currency['currency_id']);
$outKey = sprintf('%d-e', $currency['currency_id']);
$categories[] = (string)trans('firefly.no_category');
// make data arrays if not yet present.
$tempData[$inKey] = $tempData[$inKey] ?? [
'currency_id' => $currency['currency_id'],
'label' => (string)trans('firefly.box_earned_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' => [
// per category:
// "category" => 5,
],
];
$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' => [
// per category:
// "category" => 5,
],
];
foreach ($currency['transaction_journals'] as $journal) {
// is it expense or income?
$letter = -1 === bccomp($journal['amount'], '0') ? 'e' : 'i';
$currentKey = sprintf('%d-%s', $currency['currency_id'], $letter);
$name = (string)trans('firefly.no_category');
$tempData[$currentKey]['entries'][$name] = $tempData[$currentKey]['entries'][$name] ?? '0';
$tempData[$currentKey]['entries'][$name] = bcadd($tempData[$currentKey]['entries'][$name], $journal['amount']);
}
}
}
// foreach ([] as $set) {
// foreach ($set as $currency) {
// $inKey = sprintf('%d-i', $currency['currency_id']);
// $outKey = sprintf('%d-e', $currency['currency_id']);
// $categories[] = (string)trans('firefly.no_category');
// // make data arrays if not yet present.
// $tempData[$inKey] = $tempData[$inKey] ?? [
// 'currency_id' => $currency['currency_id'],
// 'label' => (string)trans('firefly.box_earned_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' => [
// // per category:
// // "category" => 5,
// ],
// ];
// $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' => [
// // per category:
// // "category" => 5,
// ],
// ];
// foreach ($currency['transaction_journals'] as $journal) {
// // is it expense or income?
// $letter = -1 === bccomp($journal['amount'], '0') ? 'e' : 'i';
// $currentKey = sprintf('%d-%s', $currency['currency_id'], $letter);
// $name = (string)trans('firefly.no_category');
// $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) {

View File

@@ -318,6 +318,10 @@ class CurrencyController extends Controller
if ($this->repository->currencyInUse($currency)) {
throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore
}
if ($this->repository->isFallbackCurrency($currency)) {
throw new FireflyException('200026: Currency is fallback.'); // @codeCoverageIgnore
}
$this->repository->destroy($currency);
return response()->json([], 204);

View File

@@ -32,6 +32,7 @@ use Illuminate\Http\Response;
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use Log;
/**
* Class AccountController
@@ -62,6 +63,7 @@ class AccountController extends Controller
*/
public function search(Request $request)
{
Log::debug('Now in account search()');
$manager = $this->getManager();
$query = $request->get('query');
$field = $request->get('field');
@@ -70,6 +72,8 @@ class AccountController extends Controller
return response(null, 422);
}
$types = $this->mapAccountTypes($type);
Log::debug(sprintf('Going to search for "%s" in types', $query), $types);
/** @var AccountSearch $search */
$search = app(AccountSearch::class);
$search->setUser(auth()->user());
@@ -79,6 +83,8 @@ class AccountController extends Controller
$accounts = $search->search();
Log::debug(sprintf('Found %d accounts', $accounts->count()));
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
$transformer->setParameters($this->parameters);

View File

@@ -274,6 +274,7 @@ class TransactionController extends Controller
*/
public function store(TransactionStoreRequest $request): JsonResponse
{
Log::debug('Now in API TransactionController::store()');
$data = $request->getAll();
$data['user'] = auth()->user()->id;
@@ -283,6 +284,7 @@ class TransactionController extends Controller
try {
$transactionGroup = $this->groupRepository->store($data);
} catch (DuplicateTransactionException $e) {
Log::warning('Caught a duplicate. Return error message.');
// return bad validation message.
// TODO use Laravel's internal validation thing to do this.
$response = [
@@ -294,7 +296,7 @@ class TransactionController extends Controller
return response()->json($response, 422);
}
app('preferences')->mark();
event(new StoredTransactionGroup($transactionGroup));
$manager = $this->getManager();
@@ -338,6 +340,7 @@ class TransactionController extends Controller
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);
$manager = $this->getManager();
app('preferences')->mark();
event(new UpdatedTransactionGroup($transactionGroup));
/** @var User $admin */

View File

@@ -57,8 +57,8 @@ class AttachmentStoreRequest extends Request
'filename' => $this->string('filename'),
'title' => $this->string('title'),
'notes' => $this->nlString('notes'),
'model' => $this->string('model'),
'model_id' => $this->integer('model_id'),
'model' => $this->string('attachable_type'),
'model_id' => $this->integer('attachable_id'),
];
}
@@ -77,14 +77,14 @@ class AttachmentStoreRequest extends Request
str_replace('FireflyIII\\Models\\', '', TransactionJournal::class),
]
);
$model = $this->string('model');
$model = $this->string('attachable_type');
return [
'filename' => 'required|between:1,255',
'title' => 'between:1,255',
'notes' => 'between:1,65000',
'model' => sprintf('required|in:%s', $models),
'model_id' => ['required', 'numeric', new IsValidAttachmentModel($model)],
'filename' => 'required|between:1,255',
'title' => 'between:1,255',
'notes' => 'between:1,65000',
'attachable_type' => sprintf('required|in:%s', $models),
'attachable_id' => ['required', 'numeric', new IsValidAttachmentModel($model)],
];
}
}

View File

@@ -52,8 +52,8 @@ class AttachmentUpdateRequest extends Request
'filename' => $this->string('filename'),
'title' => $this->string('title'),
'notes' => $this->nlString('notes'),
'model' => $this->string('model'),
'model_id' => $this->integer('model_id'),
'model' => $this->string('attachable_type'),
'model_id' => $this->integer('attachable_id'),
];
}

View File

@@ -30,7 +30,7 @@ use FireflyIII\Rules\IsDateOrTime;
use FireflyIII\Support\NullArrayObject;
use FireflyIII\Validation\TransactionValidation;
use Illuminate\Validation\Validator;
use Log;
/**
* Class TransactionStoreRequest
@@ -46,6 +46,7 @@ class TransactionStoreRequest extends Request
*/
public function authorize(): bool
{
Log::debug('Authorize TransactionStoreRequest');
// Only allow authenticated users
return auth()->check();
}
@@ -57,6 +58,7 @@ class TransactionStoreRequest extends Request
*/
public function getAll(): array
{
Log::debug('get all data in TransactionStoreRequest');
$data = [
'group_title' => $this->string('group_title'),
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
@@ -73,6 +75,7 @@ class TransactionStoreRequest extends Request
*/
public function rules(): array
{
Log::debug('Collect rules of TransactionStoreRequest');
$rules = [
// basic fields for group:
'group_title' => 'between:1,1000|nullable',

View File

@@ -90,11 +90,40 @@ class FixUnevenAmount extends Command
}
/** @var Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
if (null === $source) {
$this->error(
sprintf(
'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.', $journal->id ?? 0,
$journal->description ?? ''
)
);
Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();
TransactionJournal::where('id', $journal->description ?? 0)->forceDelete();
return;
}
$amount = bcmul('-1', (string)$source->amount);
// fix amount of destination:
/** @var Transaction $destination */
$destination = $journal->transactions()->where('amount', '>', 0)->first();
$destination = $journal->transactions()->where('amount', '>', 0)->first();
if (null === $destination) {
$this->error(
sprintf(
'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.', $journal->id ?? 0,
$journal->description ?? ''
)
);
Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();
TransactionJournal::where('id', $journal->description ?? 0)->forceDelete();
return;
}
$destination->amount = $amount;
$destination->save();

View File

@@ -55,10 +55,11 @@ class CreateDatabase extends Command
{
if ('mysql' !== env('DB_CONNECTION')) {
$this->info(sprintf('CreateDB does not apply to "%s", skipped.', env('DB_CONNECTION')));
return 0;
}
// try to set up a raw connection:
$dsn = sprintf('mysql:host=%s;charset=utf8mb4', env('DB_HOST'));
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,

View File

@@ -32,7 +32,7 @@ class SetLatestVersion extends Command
*
* @var string
*/
protected $description = 'Command description';
protected $description = 'Set latest version in DB.';
/**
* The name and signature of the console command.
*

View File

@@ -2,7 +2,7 @@
/**
* AdminRequestedTestMessage.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* Event.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* RegisteredUser.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* RequestedNewPassword.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* RequestedReportOnJournals.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* RequestedVersionCheckStatus.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* StoredTransactionGroup.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* UpdatedTransactionGroup.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* UserChangedEmail.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* DuplicateTransactionException.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* FireflyException.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* GracefulNotFoundHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -65,6 +65,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
return parent::render($request, $exception);
case 'accounts.show':
case 'accounts.show.all':
return $this->handleAccount($request, $exception);
case 'transactions.show':
return $this->handleGroup($request, $exception);
@@ -85,6 +86,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
return redirect(route('currencies.index'));
break;
case 'budgets.show':
case 'budgets.edit':
$request->session()->reflash();
return redirect(route('budgets.index'));

View File

@@ -2,7 +2,7 @@
/**
* Handler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* NotImplementedException.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* ValidationException.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* AccountFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* AccountMetaFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* AttachmentFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* BillFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* BudgetFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* CategoryFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* PiggyBankEventFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* PiggyBankFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* RecurrenceFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* TagFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* TransactionCurrencyFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* TransactionFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* TransactionGroupFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -26,6 +26,7 @@ namespace FireflyIII\Factory;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\User;
use Log;
/**
* Class TransactionGroupFactory
@@ -60,7 +61,12 @@ class TransactionGroupFactory
$this->journalFactory->setUser($this->user);
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
$collection = $this->journalFactory->create($data);
try {
$collection = $this->journalFactory->create($data);
} catch(DuplicateTransactionException $e) {
Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');
throw new DuplicateTransactionException($e->getMessage());
}
$title = $data['group_title'] ?? null;
$title = '' === $title ? null : $title;

View File

@@ -2,7 +2,7 @@
/**
* TransactionJournalFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -129,11 +129,11 @@ class TransactionJournalFactory
public function create(array $data): Collection
{
// convert to special object.
$data = new NullArrayObject($data);
$dataObject = new NullArrayObject($data);
Log::debug('Start of TransactionJournalFactory::create()');
$collection = new Collection;
$transactions = $data['transactions'] ?? [];
$transactions = $dataObject['transactions'] ?? [];
if (0 === count($transactions)) {
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
@@ -145,7 +145,12 @@ class TransactionJournalFactory
Log::debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions)));
Log::debug('Going to call createJournal', $row);
$journal = $this->createJournal(new NullArrayObject($row));
try {
$journal = $this->createJournal(new NullArrayObject($row));
} catch (DuplicateTransactionException|Exception $e) {
Log::warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');
throw new DuplicateTransactionException($e->getMessage());
}
if (null !== $journal) {
$collection->push($journal);
}
@@ -395,17 +400,20 @@ class TransactionJournalFactory
*/
private function errorIfDuplicate(string $hash): void
{
Log::debug(sprintf('In errorIfDuplicate(%s)', $hash));
if (false === $this->errorOnHash) {
return;
}
$result = null;
if ($this->errorOnHash) {
Log::debug('Will verify duplicate!');
/** @var TransactionJournalMeta $result */
$result = TransactionJournalMeta::where('data', json_encode($hash, JSON_THROW_ON_ERROR))
->with(['transactionJournal', 'transactionJournal.transactionGroup'])
->first();
}
if (null !== $result) {
Log::warning('Found a duplicate!');
throw new DuplicateTransactionException(sprintf('Duplicate of transaction #%d.', $result->transactionJournal->transaction_group_id));
}
}
@@ -526,6 +534,9 @@ class TransactionJournalFactory
public function setErrorOnHash(bool $errorOnHash): void
{
$this->errorOnHash = $errorOnHash;
if (true === $errorOnHash) {
Log::info('Will trigger duplication alert for this journal.');
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* TransactionJournalMetaFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -2,7 +2,7 @@
/**
* TransactionTypeFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ChartJsGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -32,6 +32,7 @@ class ChartJsGenerator implements GeneratorInterface
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -118,7 +119,10 @@ class ChartJsGenerator implements GeneratorInterface
public function multiSet(array $data): array
{
reset($data);
$first = current($data);
$first = current($data);
if (!is_array($first)) {
return [];
}
$labels = is_array($first['entries']) ? array_keys($first['entries']) : [];
$chartData = [
@@ -186,7 +190,7 @@ class ChartJsGenerator implements GeneratorInterface
$chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$value);
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key;
$chartData['labels'][] = $key;
++$index;
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* GeneratorInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ReportGeneratorFactory.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ReportGeneratorInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MonthReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* MultiYearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* YearReportGenerator.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* APIEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* AdminEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* AutomationHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* StoredGroupEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* UpdatedGroupEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* UserEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* VersionCheckEventHandler.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
use Carbon\Carbon;
use FireflyIII\Events\RequestedVersionCheckStatus;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Update\UpdateTrait;
@@ -55,7 +56,6 @@ class VersionCheckEventHandler
$value = (int)$permission->data;
if (1 !== $value) {
Log::info('Update check is not enabled.');
return;
}
@@ -65,7 +65,6 @@ class VersionCheckEventHandler
$user = $event->user;
if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.');
return;
}
@@ -76,26 +75,13 @@ class VersionCheckEventHandler
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return;
}
// last check time was more than a week ago.
Log::debug('Have not checked for a new version in a week!');
try {
$latestRelease = $this->getLatestRelease();
} catch (FireflyException $e) {
Log::error($e);
session()->flash('error', (string)trans('firefly.update_check_error'));
$release = $this->getLatestRelease();
// softfail.
return;
}
$versionCheck = $this->versionCheck($latestRelease);
$resultString = $this->parseResult($versionCheck, $latestRelease);
if (0 !== $versionCheck && '' !== $resultString) {
// flash info
session()->flash('info', $resultString);
}
session()->flash($release['level'], $release['message']);
app('fireflyconfig')->set('last_update_check', time());
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* AttachmentHelper.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* AttachmentHelperInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* GroupCollector.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -60,6 +60,8 @@ class GroupCollector implements GroupCollectorInterface
private $hasCatInformation;
/** @var bool Will be true of the query has the tag info tables joined. */
private $hasJoinedTagTables;
/** @var bool Will be true for attachments */
private $hasJoinedAttTables;
/** @var int The maximum number of results. */
private $limit;
/** @var int The page to return. */
@@ -86,7 +88,8 @@ class GroupCollector implements GroupCollectorInterface
$this->hasBudgetInformation = false;
$this->hasBillInformation = false;
$this->hasJoinedTagTables = false;
$this->integerFields = [
$this->hasJoinedAttTables = false;
$this->integerFields = [
'transaction_group_id',
'user_id',
'transaction_journal_id',
@@ -101,10 +104,10 @@ class GroupCollector implements GroupCollectorInterface
'destination_transaction_id',
'destination_account_id',
'category_id',
'budget_id'
'budget_id',
];
$this->total = 0;
$this->fields = [
$this->total = 0;
$this->fields = [
# group
'transaction_groups.id as transaction_group_id',
'transaction_groups.user_id as user_id',
@@ -281,11 +284,10 @@ class GroupCollector implements GroupCollectorInterface
*/
public function getGroups(): Collection
{
$start = microtime(true);
//$start = microtime(true);
/** @var Collection $result */
$result = $this->query->get($this->fields);
$end = round(microtime(true) - $start, 5);
//$end = round(microtime(true) - $start, 5);
// log info about query time.
//Log::info(sprintf('Query took Firefly III %s seconds', $end));
//Log::info($this->query->toSql(), $this->query->getBindings());
@@ -950,6 +952,24 @@ class GroupCollector implements GroupCollectorInterface
}
}
/**
* Join table to get attachment information.
*/
private function joinAttachmentTables(): void
{
if (false === $this->hasJoinedAttTables) {
// join some extra tables:
$this->hasJoinedAttTables = true;
$this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
->where(
static function (EloquentBuilder $q1) {
$q1->where('attachments.attachable_type', TransactionJournal::class);
$q1->orWhereNull('attachments.attachable_type');
}
);
}
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
@@ -980,6 +1000,26 @@ class GroupCollector implements GroupCollectorInterface
return $existingJournal;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeAttachments(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (isset($newArray['attachment_id'])) {
$attachmentId = (int)$newJournal['tag_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $existingJournal;
}
/**
* @param Collection $collection
*
@@ -994,7 +1034,7 @@ class GroupCollector implements GroupCollectorInterface
if (!isset($groups[$groupId])) {
// make new array
$parsedGroup = $this->parseAugmentedGroup($augumentedJournal);
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
$groupArray = [
'id' => (int)$augumentedJournal->transaction_group_id,
'user_id' => (int)$augumentedJournal->user_id,
@@ -1014,11 +1054,14 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groupId]['count']++;
if (isset($groups[$groupId]['transactions'][$journalId])) {
// append data to existing group + journal (for multiple tags or multiple attachments)
$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
$groups[$groupId]['transactions'][$journalId] = $this->mergeAttachments($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
}
if (!isset($groups[$groupId]['transactions'][$journalId])) {
$groups[$groupId]['transactions'][$journalId] = $this->parseAugmentedGroup($augumentedJournal);
// create second, third, fourth split:
$groups[$groupId]['transactions'][$journalId] = $this->parseAugmentedJournal($augumentedJournal);
}
@@ -1034,10 +1077,11 @@ class GroupCollector implements GroupCollectorInterface
*
* @return array
*/
private function parseAugmentedGroup(TransactionJournal $augumentedJournal): array
private function parseAugmentedJournal(TransactionJournal $augumentedJournal): array
{
$result = $augumentedJournal->toArray();
$result['tags'] = [];
$result = $augumentedJournal->toArray();
$result['tags'] = [];
$result['attachments'] = [];
try {
$result['date'] = new Carbon($result['date']);
$result['created_at'] = new Carbon($result['created_at']);
@@ -1067,6 +1111,14 @@ class GroupCollector implements GroupCollectorInterface
];
}
// also merge attachments:
if (isset($augumentedJournal['attachment_id'])) {
$attachmentId = (int)$augumentedJournal['attachment_id'];
$result['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $result;
}
@@ -1230,4 +1282,15 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* @inheritDoc
*/
public function withAttachmentInformation(): GroupCollectorInterface
{
$this->fields[] = 'attachments.id as attachment_id';
$this->joinAttachmentTables();
return $this;
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* GroupCollectorInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -57,6 +57,13 @@ interface GroupCollectorInterface
*/
public function amountLess(string $amount): GroupCollectorInterface;
/**
* Add basic info on attachments of transactions.
*
* @return GroupCollectorInterface
*/
public function withAttachmentInformation(): GroupCollectorInterface;
/**
* Get transactions where the amount is more than.
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* FiscalHelper.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* FiscalHelperInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* Help.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* HelpInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* NetWorth.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* NetWorthInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* PopupReport.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* PopupReportInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ReportHelper.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ReportHelperInterface.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* UpdateTrait.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Update;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
use Log;
@@ -35,10 +33,11 @@ use Log;
trait UpdateTrait
{
/**
* Get object for the latest release from GitHub.
* Returns an array with info on the next release, if any.
* 'message' => 'A new version is available.
* 'level' => 'info' / 'success' / 'error'
*
* @return array
* @throws FireflyException
*/
public function getLatestRelease(): array
{
@@ -47,81 +46,6 @@ trait UpdateTrait
$checker = app(UpdateRequestInterface::class);
$channel = app('fireflyconfig')->get('update_channel', 'stable')->data;
return $checker->getVersion($channel);
}
/**
* Parses the version check result in a human readable sentence.
*
* @param int $versionCheck
* @param array $information
*
* @return string
*/
public function parseResult(int $versionCheck, array $information): string
{
Log::debug(sprintf('Now in parseResult(%d)', $versionCheck));
$current = (string)config('firefly.version');
$return = '';
$triggered = false;
if (-1 === $versionCheck) {
$triggered = true;
$monthAndDayFormat = (string)trans('config.month_and_day');
$carbon = Carbon::createFromFormat('Y-m-d', $information['date']);
$return = (string)trans(
'firefly.update_new_version_alert',
[
'your_version' => $current,
'new_version' => $information['version'],
'date' => $carbon->formatLocalized($monthAndDayFormat),
]
);
// append warning if beta or alpha.
$isBeta = $information['is_beta'] ?? false;
if (true === $isBeta) {
$return = sprintf('%s %s', $return, trans('firefly.update_version_beta'));
}
$isAlpha = $information['is_alpha'] ?? false;
if (true === $isAlpha) {
$return = sprintf('%s %s', $return, trans('firefly.update_version_alpha'));
}
}
if (0 === $versionCheck) {
$triggered = true;
Log::debug('User is running current version.');
// you are running the current version!
$return = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
}
if (1 === $versionCheck) {
$triggered = true;
Log::debug('User is running NEWER version.');
// you are running a newer version!
$return = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $information['version']]);
}
if (false === $triggered) {
Log::debug('No option was triggered.');
$return = (string)trans('firefly.update_check_error');
}
return $return;
}
/**
* Compare version and store result.
*
* @param array $information
*
* @return int
*/
public function versionCheck(array $information): int
{
Log::debug('Now in versionCheck()');
$current = (string)config('firefly.version');
$check = version_compare($current, $information['version']);
Log::debug(sprintf('Comparing %s with %s, result is %s', $current, $information['version'], $check), $information);
return $check;
return $checker->getUpdateInformation($channel);
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* CreateController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* DeleteController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* EditController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* IndexController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ReconcileController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ShowController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* ConfigurationController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* HomeController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* LinkController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* UpdateController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -23,14 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Log;
/**
* Class HomeController.
@@ -110,46 +108,12 @@ class UpdateController extends Controller
/**
* Does a manual update check.
*/
public function updateCheck(): JsonResponse
public function updateCheck(): RedirectResponse
{
$success = true;
$latestRelease = '1.0';
$resultString = '';
$versionCheck = -2;
$channel = app('fireflyconfig')->get('update_channel', 'stable')->data;
$release = $this->getLatestRelease();
try {
$latestRelease = $this->getLatestRelease();
} catch (FireflyException $e) {
Log::error($e->getMessage());
$success = false;
}
session()->flash($release['level'], $release['message']);
// if error, tell the user.
if (false === $success) {
$resultString = (string)trans('firefly.update_check_error');
session()->flash('error', $resultString);
}
// if not, compare and tell the user.
if (true === $success) {
$versionCheck = $this->versionCheck($latestRelease);
$resultString = $this->parseResult($versionCheck, $latestRelease);
}
Log::debug(sprintf('Result string is: "%s"', $resultString));
if (0 !== $versionCheck && '' !== $resultString) {
// flash info
session()->flash('info', $resultString);
}
app('fireflyconfig')->set('last_update_check', time());
return response()->json(
[
'result' => $resultString,
'channel' => $channel,
]
);
return redirect(route('admin.update-check'));
}
}

Some files were not shown because too many files have changed in this diff Show More