Merge remote-tracking branch 'upstream/develop' into fix-transfer-sign

This commit is contained in:
Florian Dupret
2020-07-27 11:06:00 +02:00
850 changed files with 78825 additions and 14247 deletions

View File

@@ -60,6 +60,7 @@ class General extends AbstractExtension
$this->activeRouteStrict(),
$this->activeRoutePartial(),
$this->activeRoutePartialObjectType(),
$this->menuOpenRoutePartial(),
$this->formatDate(),
$this->getMetaField(),
$this->hasRole(),
@@ -89,9 +90,32 @@ class General extends AbstractExtension
);
}
/**
* Will return "menu-open" when a part of the route matches the argument.
* ie. "accounts" will match "accounts.index".
*
* @return TwigFunction
*/
protected function menuOpenRoutePartial(): TwigFunction
{
return new TwigFunction(
'menuOpenRoutePartial',
static function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = Route::getCurrentRoute()->getName() ?? '';
if (!(false === strpos($name, $route))) {
return 'menu-open';
}
return '';
}
);
}
/**
* This function will return "active" when the current route matches the first argument (even partly)
* but, the variable $what has been set and matches the second argument.
* but, the variable $objectType has been set and matches the second argument.
*
* @return TwigFunction
*/

View File

@@ -286,6 +286,12 @@ class TransactionGroupTwig extends AbstractExtension
$sourceAccountId = $journal['source_account_id'];
$amount = $this->signAmount($amount, $type, $destinationType, $sourceAccountId, $account->id);
// withdrawals are negative
if ($type !== TransactionType::WITHDRAWAL) {
$amount = bcmul($amount, '-1');
}
if ($type === TransactionType::TRANSFER) {
$colored = false;
}
@@ -345,9 +351,8 @@ class TransactionGroupTwig extends AbstractExtension
$amount = bcmul($amount, '-1');
}
// negative opening balance
if ($type === TransactionType::OPENING_BALANCE)
if (AccountType::INITIAL_BALANCE === $destinationType) {
// opening balance and it goes to initial balance? its expense.
if ($type === TransactionType::OPENING_BALANCE && AccountType::INITIAL_BALANCE === $destinationType) {
$amount = bcmul($amount, '-1');
}
@@ -357,6 +362,11 @@ class TransactionGroupTwig extends AbstractExtension
$amount = bcmul($amount, '-1');
}
// reconciliation and it goes to reconciliation?
if ($type === TransactionType::RECONCILIATION && AccountType::RECONCILIATION === $destinationType) {
$amount = bcmul($amount, '-1');
}
return $amount;
}
}