mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix storage bug in #845
This commit is contained in:
parent
519ca4b2af
commit
38bb074751
@ -17,6 +17,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class ImportBill
|
||||
@ -26,6 +27,8 @@ use Log;
|
||||
class ImportBill
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $amount = '1';
|
||||
/** @var Bill */
|
||||
private $bill;
|
||||
/** @var array */
|
||||
@ -59,6 +62,14 @@ class ImportBill
|
||||
return $this->bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*/
|
||||
public function setAmount(string $amount)
|
||||
{
|
||||
$this->amount = Steam::positive($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $id
|
||||
*/
|
||||
@ -220,12 +231,22 @@ class ImportBill
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::debug('Found no bill so must create one ourselves.');
|
||||
|
||||
$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);
|
||||
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:
|
||||
$this->storeCategory($journal, $importJournal->category->getCategory());
|
||||
$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->storeMeta($journal, $importJournal->metaDates);
|
||||
$journal->setMeta('notes', $importJournal->notes);
|
||||
|
Loading…
Reference in New Issue
Block a user