mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Recurring transactions.
This commit is contained in:
@@ -122,7 +122,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
'order' => (int) $piggyBank->order,
|
||||
'active' => true,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => (string) $objectGroupId,
|
||||
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
'links' => [
|
||||
|
||||
@@ -42,14 +42,10 @@ use Log;
|
||||
*/
|
||||
class RecurrenceTransformer extends AbstractTransformer
|
||||
{
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $budgetRepos;
|
||||
/** @var CategoryFactory */
|
||||
private $factory;
|
||||
/** @var PiggyBankRepositoryInterface */
|
||||
private $piggyRepos;
|
||||
/** @var RecurringRepositoryInterface */
|
||||
private $repository;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private CategoryFactory $factory;
|
||||
private PiggyBankRepositoryInterface $piggyRepos;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* RecurrenceTransformer constructor.
|
||||
@@ -86,9 +82,10 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$notes = $this->repository->getNoteText($recurrence);
|
||||
$reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions;
|
||||
Log::debug('Get basic data.');
|
||||
|
||||
// basic data.
|
||||
return [
|
||||
'id' => (int)$recurrence->id,
|
||||
'id' => (string)$recurrence->id,
|
||||
'created_at' => $recurrence->created_at->toAtomString(),
|
||||
'updated_at' => $recurrence->updated_at->toAtomString(),
|
||||
'type' => $shortType,
|
||||
@@ -127,13 +124,13 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
foreach ($recurrence->recurrenceRepetitions as $repetition) {
|
||||
$repetitionArray = [
|
||||
'id' => (int) $repetition->id,
|
||||
'id' => (string)$repetition->id,
|
||||
'created_at' => $repetition->created_at->toAtomString(),
|
||||
'updated_at' => $repetition->updated_at->toAtomString(),
|
||||
'type' => $repetition->repetition_type,
|
||||
'moment' => $repetition->repetition_moment,
|
||||
'skip' => (int) $repetition->repetition_skip,
|
||||
'weekend' => (int) $repetition->weekend,
|
||||
'skip' => (int)$repetition->repetition_skip,
|
||||
'weekend' => (int)$repetition->weekend,
|
||||
'description' => $this->repository->repetitionDescription($repetition),
|
||||
'occurrences' => [],
|
||||
];
|
||||
@@ -182,21 +179,21 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
case 'piggy_bank_id':
|
||||
$piggy = $this->piggyRepos->findNull((int)$transactionMeta->value);
|
||||
if (null !== $piggy) {
|
||||
$array['piggy_bank_id'] = (int) $piggy->id;
|
||||
$array['piggy_bank_id'] = (string)$piggy->id;
|
||||
$array['piggy_bank_name'] = $piggy->name;
|
||||
}
|
||||
break;
|
||||
case 'category_name':
|
||||
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
|
||||
if (null !== $category) {
|
||||
$array['category_id'] = (int) $category->id;
|
||||
$array['category_id'] = (string)$category->id;
|
||||
$array['category_name'] = $category->name;
|
||||
}
|
||||
break;
|
||||
case 'budget_id':
|
||||
$budget = $this->budgetRepos->findNull((int)$transactionMeta->value);
|
||||
if (null !== $budget) {
|
||||
$array['budget_id'] = (int) $budget->id;
|
||||
$array['budget_id'] = (string)$budget->id;
|
||||
$array['budget_name'] = $budget->name;
|
||||
}
|
||||
break;
|
||||
@@ -227,10 +224,10 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$foreignCurrencyDp = null;
|
||||
$foreignCurrencyId = null;
|
||||
if (null !== $transaction->foreign_currency_id) {
|
||||
$foreignCurrencyId = (int) $transaction->foreign_currency_id;
|
||||
$foreignCurrencyId = (int)$transaction->foreign_currency_id;
|
||||
$foreignCurrencyCode = $transaction->foreignCurrency->code;
|
||||
$foreignCurrencySymbol = $transaction->foreignCurrency->symbol;
|
||||
$foreignCurrencyDp = (int) $transaction->foreignCurrency->decimal_places;
|
||||
$foreignCurrencyDp = (int)$transaction->foreignCurrency->decimal_places;
|
||||
}
|
||||
|
||||
// source info:
|
||||
@@ -240,7 +237,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$sourceIban = null;
|
||||
if (null !== $sourceAccount) {
|
||||
$sourceName = $sourceAccount->name;
|
||||
$sourceId = (int) $sourceAccount->id;
|
||||
$sourceId = (int)$sourceAccount->id;
|
||||
$sourceType = $sourceAccount->accountType->type;
|
||||
$sourceIban = $sourceAccount->iban;
|
||||
}
|
||||
@@ -250,31 +247,31 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$destinationIban = null;
|
||||
if (null !== $destinationAccount) {
|
||||
$destinationName = $destinationAccount->name;
|
||||
$destinationId = (int) $destinationAccount->id;
|
||||
$destinationId = (int)$destinationAccount->id;
|
||||
$destinationType = $destinationAccount->accountType->type;
|
||||
$destinationIban = $destinationAccount->iban;
|
||||
}
|
||||
|
||||
|
||||
$amount = number_format((float) $transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
|
||||
$amount = number_format((float)$transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
|
||||
$foreignAmount = null;
|
||||
if (null !== $transaction->foreign_currency_id && null !== $transaction->foreign_amount) {
|
||||
$foreignAmount = number_format((float) $transaction->foreign_amount, $foreignCurrencyDp, '.', '');
|
||||
$foreignAmount = number_format((float)$transaction->foreign_amount, $foreignCurrencyDp, '.', '');
|
||||
}
|
||||
$transactionArray = [
|
||||
'currency_id' => (int) $transaction->transaction_currency_id,
|
||||
'currency_id' => (string)$transaction->transaction_currency_id,
|
||||
'currency_code' => $transaction->transactionCurrency->code,
|
||||
'currency_symbol' => $transaction->transactionCurrency->symbol,
|
||||
'currency_decimal_places' => (int) $transaction->transactionCurrency->decimal_places,
|
||||
'foreign_currency_id' => $foreignCurrencyId,
|
||||
'currency_decimal_places' => (int)$transaction->transactionCurrency->decimal_places,
|
||||
'foreign_currency_id' => null === $foreignCurrencyId ? null : (string)$foreignCurrencyId,
|
||||
'foreign_currency_code' => $foreignCurrencyCode,
|
||||
'foreign_currency_symbol' => $foreignCurrencySymbol,
|
||||
'foreign_currency_decimal_places' => $foreignCurrencyDp,
|
||||
'source_id' => $sourceId,
|
||||
'source_id' => (string)$sourceId,
|
||||
'source_name' => $sourceName,
|
||||
'source_iban' => $sourceIban,
|
||||
'source_type' => $sourceType,
|
||||
'destination_id' => $destinationId,
|
||||
'destination_id' => (string)$destinationId,
|
||||
'destination_name' => $destinationName,
|
||||
'destination_iban' => $destinationIban,
|
||||
'destination_type' => $destinationType,
|
||||
|
||||
Reference in New Issue
Block a user