mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Update source account detection.
This commit is contained in:
@@ -88,7 +88,8 @@ class InfiniteListRequest extends FormRequest
|
|||||||
return 0 === $page || $page > 65536 ? 1 : $page;
|
return 0 === $page || $page > 65536 ? 1 : $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSortInstructions(): array {
|
public function getSortInstructions(): array
|
||||||
|
{
|
||||||
$allowed = config('firefly.sorting.allowed.transactions');
|
$allowed = config('firefly.sorting.allowed.transactions');
|
||||||
$set = $this->get('sorting', []);
|
$set = $this->get('sorting', []);
|
||||||
$result = [];
|
$result = [];
|
||||||
@@ -102,12 +103,13 @@ class InfiniteListRequest extends FormRequest
|
|||||||
// skip invalid direction
|
// skip invalid direction
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(in_array($column, $allowed, true) === false) {
|
if (false === in_array($column, $allowed, true)) {
|
||||||
// skip invalid column
|
// skip invalid column
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$result[$column] = $direction;
|
$result[$column] = $direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
*/
|
*/
|
||||||
trait CollectorProperties
|
trait CollectorProperties
|
||||||
{
|
{
|
||||||
|
|
||||||
public array $sorting;
|
public array $sorting;
|
||||||
public const string TEST = 'Test';
|
public const string TEST = 'Test';
|
||||||
private ?int $endRow;
|
private ?int $endRow;
|
||||||
|
@@ -988,7 +988,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'transactions as source',
|
'transactions as source',
|
||||||
static function (JoinClause $join): void {
|
static function (JoinClause $join): void {
|
||||||
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
|
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('source.amount', '<', 0);
|
->where('source.amount', '<', 0)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// join destination transaction
|
// join destination transaction
|
||||||
@@ -996,7 +997,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'transactions as destination',
|
'transactions as destination',
|
||||||
static function (JoinClause $join): void {
|
static function (JoinClause $join): void {
|
||||||
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
|
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('destination.amount', '>', 0);
|
->where('destination.amount', '>', 0)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// left join transaction type.
|
// left join transaction type.
|
||||||
@@ -1011,7 +1013,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->orderBy('transaction_journals.description', 'DESC')
|
->orderBy('transaction_journals.description', 'DESC')
|
||||||
->orderBy('source.amount', 'DESC');
|
->orderBy('source.amount', 'DESC')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1042,7 +1045,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'transactions as source',
|
'transactions as source',
|
||||||
static function (JoinClause $join): void {
|
static function (JoinClause $join): void {
|
||||||
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
|
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('source.amount', '<', 0);
|
->where('source.amount', '<', 0)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// join destination transaction
|
// join destination transaction
|
||||||
@@ -1050,7 +1054,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'transactions as destination',
|
'transactions as destination',
|
||||||
static function (JoinClause $join): void {
|
static function (JoinClause $join): void {
|
||||||
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
|
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('destination.amount', '>', 0);
|
->where('destination.amount', '>', 0)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// left join transaction type.
|
// left join transaction type.
|
||||||
@@ -1065,7 +1070,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->orderBy('transaction_journals.description', 'DESC')
|
->orderBy('transaction_journals.description', 'DESC')
|
||||||
->orderBy('source.amount', 'DESC');
|
->orderBy('source.amount', 'DESC')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1080,19 +1086,18 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
// include budget ID + name (if any)
|
// include budget ID + name (if any)
|
||||||
->withBudgetInformation()
|
->withBudgetInformation()
|
||||||
// include bill ID + name (if any)
|
// include bill ID + name (if any)
|
||||||
->withBillInformation();
|
->withBillInformation()
|
||||||
|
;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[\Override]
|
||||||
* @inheritDoc
|
public function sortCollection(Collection $collection): Collection
|
||||||
*/
|
|
||||||
#[\Override] public function sortCollection(Collection $collection): Collection
|
|
||||||
{
|
{
|
||||||
foreach ($this->sorting as $field => $direction) {
|
foreach ($this->sorting as $field => $direction) {
|
||||||
$func = $direction === 'ASC' ? 'sortBy' : 'sortByDesc';
|
$func = 'ASC' === $direction ? 'sortBy' : 'sortByDesc';
|
||||||
$collection = $collection->$func(function (array $product, int $key) use ($field, $direction) {
|
$collection = $collection->{$func}(function (array $product, int $key) use ($field) {
|
||||||
// depends on $field:
|
// depends on $field:
|
||||||
if ('description' === $field) {
|
if ('description' === $field) {
|
||||||
if (1 === count($product['transactions'])) {
|
if (1 === count($product['transactions'])) {
|
||||||
@@ -1101,22 +1106,22 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
if (count($product['transactions']) > 1) {
|
if (count($product['transactions']) > 1) {
|
||||||
return $product['title'];
|
return $product['title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'zzz';
|
return 'zzz';
|
||||||
}
|
}
|
||||||
die('here we are');
|
|
||||||
|
exit('here we are');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[\Override]
|
||||||
* @inheritDoc
|
public function setSorting(array $instructions): GroupCollectorInterface
|
||||||
*/
|
|
||||||
#[\Override] public function setSorting(array $instructions): GroupCollectorInterface
|
|
||||||
{
|
{
|
||||||
$this->sorting = $instructions;
|
$this->sorting = $instructions;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -285,22 +285,10 @@ interface GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function getPaginatedGroups(): LengthAwarePaginator;
|
public function getPaginatedGroups(): LengthAwarePaginator;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param array $instructions
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function setSorting(array $instructions): self;
|
public function setSorting(array $instructions): self;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort the collection on a column.
|
* Sort the collection on a column.
|
||||||
*
|
|
||||||
* @param Collection $collection
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
*/
|
||||||
public function sortCollection(Collection $collection): Collection;
|
public function sortCollection(Collection $collection): Collection;
|
||||||
|
|
||||||
|
1
public/build/assets/create-0e590bfb.js
Normal file
1
public/build/assets/create-0e590bfb.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -121,7 +121,7 @@
|
|||||||
"integrity": "sha384-ptHLIPXakGRWe8dWim7Qxgub4wolfi5rktBj2EjNw5tyt8hLq+8p+lTsBKZe5Vay"
|
"integrity": "sha384-ptHLIPXakGRWe8dWim7Qxgub4wolfi5rktBj2EjNw5tyt8hLq+8p+lTsBKZe5Vay"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/pages/transactions/create.js": {
|
"resources/assets/v2/pages/transactions/create.js": {
|
||||||
"file": "assets/create-6dc4ec8c.js",
|
"file": "assets/create-0e590bfb.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_format-money-2cbd3c32.js",
|
"_format-money-2cbd3c32.js",
|
||||||
"_create-empty-split-c1e678fd.js",
|
"_create-empty-split-c1e678fd.js",
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
],
|
],
|
||||||
"isEntry": true,
|
"isEntry": true,
|
||||||
"src": "resources/assets/v2/pages/transactions/create.js",
|
"src": "resources/assets/v2/pages/transactions/create.js",
|
||||||
"integrity": "sha384-OUiIH870uiZ8Y+/Gl2WLNSLwS8bi6mFgbixL18oCvpeSSN3pLbbmO9M+kzLlXNc9"
|
"integrity": "sha384-E0yymaxo99O2vsNgsuJ2KZD4tBnB+ly/ZlpuS9gJakCJIWWHGxK5z7G1wayhnrK3"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/pages/transactions/edit.js": {
|
"resources/assets/v2/pages/transactions/edit.js": {
|
||||||
"file": "assets/edit-0910e359.js",
|
"file": "assets/edit-0910e359.js",
|
||||||
|
@@ -180,6 +180,12 @@ let transactions = function () {
|
|||||||
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
|
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ('Expense account' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {
|
||||||
|
this.groupProperties.transactionType = 'deposit';
|
||||||
|
console.warn('FORCE transaction type to be "' + this.groupProperties.transactionType + '".');
|
||||||
|
this.entries[0].source_account.id = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Asset account' === destType) {
|
if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Asset account' === destType) {
|
||||||
this.groupProperties.transactionType = 'deposit';
|
this.groupProperties.transactionType = 'deposit';
|
||||||
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
|
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
|
||||||
|
Reference in New Issue
Block a user