mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some last-minute fixes.
This commit is contained in:
parent
53addcf99a
commit
18b06ff283
@ -90,6 +90,7 @@ class VerifyDatabase extends Command
|
|||||||
$this->createAccessTokens();
|
$this->createAccessTokens();
|
||||||
$this->fixDoubleAmounts();
|
$this->fixDoubleAmounts();
|
||||||
$this->fixBadMeta();
|
$this->fixBadMeta();
|
||||||
|
$this->removeBills();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,6 +256,23 @@ class VerifyDatabase extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function removeBills(): void
|
||||||
|
{
|
||||||
|
/** @var TransactionType $withdrawal */
|
||||||
|
$withdrawal = TransactionType::where('type', TransactionType::WITHDRAWAL)->first();
|
||||||
|
$journals = TransactionJournal::whereNotNull('bill_id')
|
||||||
|
->where('transaction_type_id', '!=', $withdrawal->id)->get();
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($journals as $journal) {
|
||||||
|
$this->line(sprintf('Transaction journal #%d should not be linked to bill #%d.', $journal->id, $journal->bill_id));
|
||||||
|
$journal->bill_id = null;
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Eeport (and fix) piggy banks. Make sure there are only transfers linked to piggy bank events.
|
* Eeport (and fix) piggy banks. Make sure there are only transfers linked to piggy bank events.
|
||||||
*/
|
*/
|
||||||
|
@ -161,10 +161,8 @@ class IndexController extends Controller
|
|||||||
$config['delimiter'] = $config['delimiter'] ?? ',';
|
$config['delimiter'] = $config['delimiter'] ?? ',';
|
||||||
$config['delimiter'] = "\t" === $config['delimiter'] ? 'tab' : $config['delimiter'];
|
$config['delimiter'] = "\t" === $config['delimiter'] ? 'tab' : $config['delimiter'];
|
||||||
|
|
||||||
// this prevents private information from escaping
|
$result = json_encode($config, JSON_PRETTY_PRINT);
|
||||||
$config['column-mapping-config'] = [];
|
$name = sprintf('"%s"', addcslashes('import-configuration-' . date('Y-m-d') . '.json', '"\\'));
|
||||||
$result = json_encode($config, JSON_PRETTY_PRINT);
|
|
||||||
$name = sprintf('"%s"', addcslashes('import-configuration-' . date('Y-m-d') . '.json', '"\\'));
|
|
||||||
/** @var LaravelResponse $response */
|
/** @var LaravelResponse $response */
|
||||||
$response = response($result, 200);
|
$response = response($result, 200);
|
||||||
$response->header('Content-disposition', 'attachment; filename=' . $name)
|
$response->header('Content-disposition', 'attachment; filename=' . $name)
|
||||||
|
@ -36,6 +36,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property int $order
|
* @property int $order
|
||||||
* @property bool $active
|
* @property bool $active
|
||||||
* @property bool $stop_processing
|
* @property bool $stop_processing
|
||||||
|
* @property Rule $rule
|
||||||
*/
|
*/
|
||||||
class RuleAction extends Model
|
class RuleAction extends Model
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
* @property Collection $categories
|
* @property Collection $categories
|
||||||
* @property bool $completed
|
* @property bool $completed
|
||||||
* @property string $description
|
* @property string $description
|
||||||
|
* @property string $transaction_type_id
|
||||||
*/
|
*/
|
||||||
class TransactionJournal extends Model
|
class TransactionJournal extends Model
|
||||||
{
|
{
|
||||||
|
@ -101,6 +101,11 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
$transaction->budgets()->detach();
|
$transaction->budgets()->detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if journal is not a withdrawal, remove the bill ID.
|
||||||
|
if (TransactionType::WITHDRAWAL !== $type->type) {
|
||||||
|
$journal->bill_id = null;
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
|
@ -185,8 +185,15 @@ class ImportableConverter
|
|||||||
|
|
||||||
Log::debug(sprintf('"%s" (#%d) is source and "%s" (#%d) is destination.', $source->name, $source->id, $destination->name, $destination->id));
|
Log::debug(sprintf('"%s" (#%d) is source and "%s" (#%d) is destination.', $source->name, $source->id, $destination->name, $destination->id));
|
||||||
|
|
||||||
if (bccomp($amount, '0') === 1) {
|
|
||||||
// amount is positive? Then switch:
|
if ($source->accountType->type === AccountType::ASSET && $destination->accountType->type === AccountType::ASSET) {
|
||||||
|
Log::debug('Source and destination are asset accounts. This is a transfer.');
|
||||||
|
$transactionType = 'transfer';
|
||||||
|
}
|
||||||
|
|
||||||
|
// amount is positive and its not a transfer? Then switch:
|
||||||
|
if ($transactionType !== 'transfer' && bccomp($amount, '0') === 1) {
|
||||||
|
|
||||||
[$destination, $source] = [$source, $destination];
|
[$destination, $source] = [$source, $destination];
|
||||||
Log::debug(
|
Log::debug(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -195,6 +202,17 @@ class ImportableConverter
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// amount is negative and type is transfer? then switch.
|
||||||
|
if ($transactionType === 'transfer' && bccomp($amount, '0') === -1) {
|
||||||
|
// amount is positive? Then switch:
|
||||||
|
[$destination, $source] = [$source, $destination];
|
||||||
|
Log::debug(
|
||||||
|
sprintf(
|
||||||
|
'%s is negative, so "%s" (#%d) is now source and "%s" (#%d) is now destination.',
|
||||||
|
$amount, $source->name, $source->id, $destination->name, $destination->id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// get currency preference from source asset account (preferred)
|
// get currency preference from source asset account (preferred)
|
||||||
// or destination asset account
|
// or destination asset account
|
||||||
@ -218,10 +236,7 @@ class ImportableConverter
|
|||||||
$currency = $this->defaultCurrency;
|
$currency = $this->defaultCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($source->accountType->type === AccountType::ASSET && $destination->accountType->type === AccountType::ASSET) {
|
|
||||||
Log::debug('Source and destination are asset accounts. This is a transfer.');
|
|
||||||
$transactionType = 'transfer';
|
|
||||||
}
|
|
||||||
if ($source->accountType->type === AccountType::REVENUE) {
|
if ($source->accountType->type === AccountType::REVENUE) {
|
||||||
Log::debug('Source is a revenue account. This is a deposit.');
|
Log::debug('Source is a revenue account. This is a deposit.');
|
||||||
$transactionType = 'deposit';
|
$transactionType = 'deposit';
|
||||||
|
@ -46,8 +46,8 @@ return [
|
|||||||
'belongs_to_user' => 'The value of :attribute is unknown.',
|
'belongs_to_user' => 'The value of :attribute is unknown.',
|
||||||
'accepted' => 'The :attribute must be accepted.',
|
'accepted' => 'The :attribute must be accepted.',
|
||||||
'bic' => 'This is not a valid BIC.',
|
'bic' => 'This is not a valid BIC.',
|
||||||
'at_least_one_trigger' => 'Rule must have at least one trigger',
|
'at_least_one_trigger' => 'Rule must have at least one trigger.',
|
||||||
'at_least_one_action' => 'Rule must have at least one action',
|
'at_least_one_action' => 'Rule must have at least one action.',
|
||||||
'base64' => 'This is not valid base64 encoded data.',
|
'base64' => 'This is not valid base64 encoded data.',
|
||||||
'model_id_invalid' => 'The given ID seems invalid for this model.',
|
'model_id_invalid' => 'The given ID seems invalid for this model.',
|
||||||
'more' => ':attribute must be larger than zero.',
|
'more' => ':attribute must be larger than zero.',
|
||||||
|
Loading…
Reference in New Issue
Block a user