mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expanded import routine.
This commit is contained in:
@@ -15,11 +15,49 @@ namespace FireflyIII\Import\Object;
|
||||
class ImportAccount
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $accountIds = [];
|
||||
/** @var array */
|
||||
private $accountId = [];
|
||||
|
||||
public function setAccountId(string $value)
|
||||
/** @var array */
|
||||
private $accountIban = [];
|
||||
/** @var array */
|
||||
private $accountName = [];
|
||||
|
||||
/** @var array */
|
||||
private $accountNumber = [];
|
||||
|
||||
/**
|
||||
* @param array $accountNumber
|
||||
*/
|
||||
public function setAccountNumber(array $accountNumber)
|
||||
{
|
||||
$this->accountIds[] = $value;
|
||||
$this->accountNumber = $accountNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountName
|
||||
*/
|
||||
public function setAccountName(array $accountName)
|
||||
{
|
||||
$this->accountName = $accountName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $value
|
||||
*/
|
||||
public function setAccountId(array $value)
|
||||
{
|
||||
$this->accountId = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountIban
|
||||
*/
|
||||
public function setAccountIban(array $accountIban)
|
||||
{
|
||||
$this->accountIban = $accountIban;
|
||||
}
|
||||
|
||||
|
||||
}
|
40
app/Import/Object/ImportBill.php
Normal file
40
app/Import/Object/ImportBill.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportBill.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Object;
|
||||
|
||||
|
||||
class ImportBill
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $id = [];
|
||||
/** @var array */
|
||||
private $name = [];
|
||||
|
||||
/**
|
||||
* @param array $id
|
||||
*/
|
||||
public function setId(array $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $name
|
||||
*/
|
||||
public function setName(array $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
40
app/Import/Object/ImportBudget.php
Normal file
40
app/Import/Object/ImportBudget.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportBudget.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Object;
|
||||
|
||||
|
||||
class ImportBudget
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $id = [];
|
||||
/** @var array */
|
||||
private $name = [];
|
||||
|
||||
/**
|
||||
* @param array $id
|
||||
*/
|
||||
public function setId(array $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $name
|
||||
*/
|
||||
public function setName(array $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
40
app/Import/Object/ImportCategory.php
Normal file
40
app/Import/Object/ImportCategory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportCategory.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Object;
|
||||
|
||||
|
||||
class ImportCategory
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $id = [];
|
||||
/** @var array */
|
||||
private $name = [];
|
||||
|
||||
/**
|
||||
* @param array $id
|
||||
*/
|
||||
public function setId(array $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $name
|
||||
*/
|
||||
public function setName(array $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
55
app/Import/Object/ImportCurrency.php
Normal file
55
app/Import/Object/ImportCurrency.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportCurrency.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Object;
|
||||
|
||||
|
||||
class ImportCurrency
|
||||
{
|
||||
private $code = [];
|
||||
private $symbol = [];
|
||||
private $name = [];
|
||||
private $id = [];
|
||||
|
||||
/**
|
||||
* @param array $code
|
||||
*/
|
||||
public function setCode(array $code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $symbol
|
||||
*/
|
||||
public function setSymbol(array $symbol)
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $name
|
||||
*/
|
||||
public function setName(array $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $id
|
||||
*/
|
||||
public function setId(array $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -22,10 +22,20 @@ class ImportObject
|
||||
public $errors;
|
||||
/** @var ImportAccount */
|
||||
private $asset;
|
||||
/** @var ImportBill */
|
||||
private $bill;
|
||||
/** @var ImportBudget */
|
||||
private $budget;
|
||||
/** @var ImportCategory */
|
||||
private $category;
|
||||
/** @var string */
|
||||
private $description;
|
||||
private $externalId = '';
|
||||
/** @var string */
|
||||
private $hash;
|
||||
/** @var ImportAccount */
|
||||
private $opposing;
|
||||
private $tags = [];
|
||||
/** @var ImportTransaction */
|
||||
private $transaction;
|
||||
/** @var User */
|
||||
@@ -40,6 +50,9 @@ class ImportObject
|
||||
$this->transaction = new ImportTransaction;
|
||||
$this->asset = new ImportAccount;
|
||||
$this->opposing = new ImportAccount;
|
||||
$this->bill = new ImportBill;
|
||||
$this->category = new ImportCategory;
|
||||
$this->budget = new ImportBudget;
|
||||
}
|
||||
|
||||
public function setHash(string $hash)
|
||||
@@ -57,6 +70,8 @@ class ImportObject
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setValue(array $array)
|
||||
{
|
||||
@@ -64,11 +79,83 @@ class ImportObject
|
||||
default:
|
||||
throw new FireflyException(sprintf('ImportObject cannot handle "%s" with value "%s".', $array['role'], $array['value']));
|
||||
case 'account-id':
|
||||
$this->asset->setAccountId($array['value']);
|
||||
$this->asset->setAccountId($array);
|
||||
break;
|
||||
case 'amount':
|
||||
$this->transaction->setAmount($array['value']);
|
||||
break;
|
||||
case 'account-iban':
|
||||
$this->asset->setAccountIban($array);
|
||||
break;
|
||||
case 'account-name':
|
||||
$this->asset->setAccountName($array);
|
||||
break;
|
||||
case 'account-number':
|
||||
$this->asset->setAccountNumber($array);
|
||||
break;
|
||||
case 'bill-id':
|
||||
$this->bill->setId($array);
|
||||
break;
|
||||
case 'bill-name':
|
||||
$this->bill->setName($array);
|
||||
break;
|
||||
case 'budget-id':
|
||||
$this->budget->setId($array);
|
||||
break;
|
||||
case 'budget-name':
|
||||
$this->budget->setName($array);
|
||||
break;
|
||||
case 'category-id':
|
||||
$this->category->setId($array);
|
||||
break;
|
||||
case 'category-name':
|
||||
$this->category->setName($array);
|
||||
break;
|
||||
case 'currency-code':
|
||||
$this->transaction->getCurrency()->setCode($array);
|
||||
break;
|
||||
case 'currency-id':
|
||||
$this->transaction->getCurrency()->setId($array);
|
||||
break;
|
||||
case 'currency-name':
|
||||
$this->transaction->getCurrency()->setName($array);
|
||||
break;
|
||||
case 'currency-symbol':
|
||||
$this->transaction->getCurrency()->setSymbol($array);
|
||||
break;
|
||||
case 'date-transaction':
|
||||
$this->transaction->setDate($array['value']);
|
||||
break;
|
||||
case 'description':
|
||||
$this->description = $array['value'];
|
||||
$this->transaction->setDescription($array['value']);
|
||||
break;
|
||||
case 'external-id':
|
||||
$this->externalId = $array['value'];
|
||||
break;
|
||||
case '_ignore':
|
||||
break;
|
||||
case 'ing-debet-credit':
|
||||
case 'rabo-debet-credit':
|
||||
$this->transaction->addToModifier($array);
|
||||
break;
|
||||
case 'opposing-iban':
|
||||
$this->opposing->setAccountIban($array);
|
||||
break;
|
||||
case 'opposing-name':
|
||||
$this->opposing->setAccountName($array);
|
||||
break;
|
||||
case 'opposing-number':
|
||||
$this->opposing->setAccountNumber($array);
|
||||
break;
|
||||
case 'opposing-id':
|
||||
$this->opposing->setAccountId($array);
|
||||
break;
|
||||
case 'tags-comma':
|
||||
case 'tags-space':
|
||||
$this->tags[] = $array;
|
||||
break;
|
||||
}
|
||||
//var_dump($array);
|
||||
//exit;
|
||||
}
|
||||
|
||||
}
|
@@ -14,5 +14,77 @@ namespace FireflyIII\Import\Object;
|
||||
|
||||
class ImportTransaction
|
||||
{
|
||||
/** @var string */
|
||||
private $amount;
|
||||
|
||||
/** @var ImportCurrency */
|
||||
private $currency;
|
||||
|
||||
/** @var string */
|
||||
private $date;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
private $modifiers = [];
|
||||
/** @var bool */
|
||||
private $positive = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->currency = new ImportCurrency;
|
||||
}
|
||||
|
||||
public function addToModifier(array $modifier)
|
||||
{
|
||||
$this->modifiers[] = $modifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImportCurrency
|
||||
*/
|
||||
public function getCurrency(): ImportCurrency
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportCurrency $currency
|
||||
*/
|
||||
public function setCurrency(ImportCurrency $currency)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*/
|
||||
public function setAmount(string $amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
*/
|
||||
public function setDate(string $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription(string $description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $positive
|
||||
*/
|
||||
public function setPositive(bool $positive)
|
||||
{
|
||||
$this->positive = $positive;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user