mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some new converters.
This commit is contained in:
parent
65122f0144
commit
1069db3c13
@ -11,10 +11,15 @@ class BasicConverter
|
||||
{
|
||||
/** @var array */
|
||||
protected $data;
|
||||
/** @var string */
|
||||
protected $field;
|
||||
/** @var int */
|
||||
protected $index;
|
||||
/** @var array */
|
||||
protected $mapped;
|
||||
/** @var string */
|
||||
protected $role;
|
||||
/** @var string */
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
@ -28,13 +33,29 @@ class BasicConverter
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function setData($data)
|
||||
public function setData(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getField()
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*/
|
||||
public function setField($field)
|
||||
{
|
||||
$this->field = $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
@ -42,7 +63,7 @@ class BasicConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $index
|
||||
* @param int $index
|
||||
*/
|
||||
public function setIndex($index)
|
||||
{
|
||||
@ -66,7 +87,7 @@ class BasicConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getRole()
|
||||
{
|
||||
@ -74,7 +95,7 @@ class BasicConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $role
|
||||
* @param string $role
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
@ -82,7 +103,7 @@ class BasicConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
@ -90,7 +111,7 @@ class BasicConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
|
@ -22,30 +22,34 @@ interface ConverterInterface
|
||||
public function convert();
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @param int $index
|
||||
*/
|
||||
public function setIndex($index);
|
||||
|
||||
/**
|
||||
* @param $mapped
|
||||
* @param array $mapped
|
||||
*/
|
||||
public function setMapped($mapped);
|
||||
|
||||
/**
|
||||
* @param $role
|
||||
* @param string $role
|
||||
*/
|
||||
public function setRole($role);
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setData(array $data);
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
*/
|
||||
public function setField($field);
|
||||
|
||||
}
|
24
app/Helpers/Csv/Converter/OpposingName.php
Normal file
24
app/Helpers/Csv/Converter/OpposingName.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
/**
|
||||
* Class OpposingName
|
||||
*
|
||||
* @package FireflyIII\Helpers\Csv\Converter
|
||||
*/
|
||||
class OpposingName extends BasicConverter implements ConverterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This method cannot search yet for the correct account (Expense account or Revenue account) because simply put,
|
||||
* Firefly doesn't know yet if this account needs to be an Expense account or a Revenue account. This depends
|
||||
* on the amount which is in the current row and that's a big unknown.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function convert()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
@ -78,6 +78,7 @@ class Importer
|
||||
/** @var ConverterInterface $converter */
|
||||
$converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class);
|
||||
$converter->setData($data); // the complete array so far.
|
||||
$converter->setField($field);
|
||||
$converter->setIndex($index);
|
||||
$converter->setValue($value);
|
||||
$converter->setRole($role);
|
||||
|
@ -2,8 +2,8 @@
|
||||
return [
|
||||
'roles' => [
|
||||
'_ignore' => [
|
||||
'name' => '(ignore this column)',
|
||||
'mappable' => false,
|
||||
'name' => '(ignore this column)',
|
||||
'mappable' => false,
|
||||
'converter' => 'Ignore',
|
||||
'field' => 'ignored',
|
||||
],
|
||||
@ -46,6 +46,8 @@ return [
|
||||
'date-rent' => [
|
||||
'name' => 'Rent calculation date',
|
||||
'mappable' => false,
|
||||
'converter' => 'Date',
|
||||
'field' => 'date-rent',
|
||||
],
|
||||
'budget-id' => [
|
||||
'name' => 'Budget ID (matching Firefly)',
|
||||
@ -96,8 +98,10 @@ return [
|
||||
'mappable' => true,
|
||||
],
|
||||
'opposing-name' => [
|
||||
'name' => 'Expense or revenue account name',
|
||||
'mappable' => true,
|
||||
'name' => 'Expense or revenue account name',
|
||||
'mappable' => true,
|
||||
'converter' => 'OpposingName',
|
||||
'field' => 'opposing-account'
|
||||
],
|
||||
'opposing-iban' => [
|
||||
'name' => 'Expense or revenue account IBAN',
|
||||
|
Loading…
Reference in New Issue
Block a user