mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Fix storage bug in #845
This commit is contained in:
@@ -17,6 +17,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Steam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ImportBill
|
* Class ImportBill
|
||||||
@@ -26,6 +27,8 @@ use Log;
|
|||||||
class ImportBill
|
class ImportBill
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $amount = '1';
|
||||||
/** @var Bill */
|
/** @var Bill */
|
||||||
private $bill;
|
private $bill;
|
||||||
/** @var array */
|
/** @var array */
|
||||||
@@ -59,6 +62,14 @@ class ImportBill
|
|||||||
return $this->bill;
|
return $this->bill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $amount
|
||||||
|
*/
|
||||||
|
public function setAmount(string $amount)
|
||||||
|
{
|
||||||
|
$this->amount = Steam::positive($amount);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $id
|
* @param array $id
|
||||||
*/
|
*/
|
||||||
@@ -220,12 +231,22 @@ class ImportBill
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug('Found no bill so must create one ourselves.');
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
'match' => $name,
|
||||||
|
'amount_min' => bcmul($this->amount, '0.9'),
|
||||||
|
'amount_max' => bcmul($this->amount, '1.1'),
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'date' => date('Y-m-d'),
|
||||||
|
'repeat_freq' => 'monthly',
|
||||||
|
'skip' => '0',
|
||||||
|
'automatch' => '0',
|
||||||
|
'active' => '1',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Log::debug('Found no bill so must create one ourselves. Assume default values.', $data);
|
||||||
|
|
||||||
|
|
||||||
$this->bill = $this->repository->store($data);
|
$this->bill = $this->repository->store($data);
|
||||||
Log::debug(sprintf('Successfully stored new bill #%d: %s', $this->bill->id, $this->bill->name));
|
Log::debug(sprintf('Successfully stored new bill #%d: %s', $this->bill->id, $this->bill->name));
|
||||||
|
|
||||||
|
@@ -173,6 +173,10 @@ class ImportStorage
|
|||||||
// store meta object things:
|
// store meta object things:
|
||||||
$this->storeCategory($journal, $importJournal->category->getCategory());
|
$this->storeCategory($journal, $importJournal->category->getCategory());
|
||||||
$this->storeBudget($journal, $importJournal->budget->getBudget());
|
$this->storeBudget($journal, $importJournal->budget->getBudget());
|
||||||
|
|
||||||
|
// to save bill, also give it the amount:
|
||||||
|
$importJournal->bill->setAmount($amount);
|
||||||
|
|
||||||
$this->storeBill($journal, $importJournal->bill->getBill());
|
$this->storeBill($journal, $importJournal->bill->getBill());
|
||||||
$this->storeMeta($journal, $importJournal->metaDates);
|
$this->storeMeta($journal, $importJournal->metaDates);
|
||||||
$journal->setMeta('notes', $importJournal->notes);
|
$journal->setMeta('notes', $importJournal->notes);
|
||||||
|
Reference in New Issue
Block a user