Allow user to set multi-currency available budget. WIP

This commit is contained in:
James Cole
2019-08-31 21:47:55 +02:00
parent ca777857c2
commit 509276e20b
10 changed files with 434 additions and 164 deletions

View File

@@ -227,14 +227,14 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$q1->where(
static function (Builder $q2) use ($start, $end) {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d 00:00:00'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d 00:00:00'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d 23:59:59'));
}
)
// budget limit start within period
->orWhere(
static function (Builder $q3) use ($start, $end) {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d 00:00:00'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d 00:00:00'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d 23:59:59'));
}
);
}
@@ -242,7 +242,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
->orWhere(
static function (Builder $q4) use ($start, $end) {
// or start is before start AND end is after end.
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d 00:00:00'));
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d 23:59:59'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d 00:00:00'));
}
);
@@ -265,6 +265,17 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
*
* @return BudgetLimit
*/
public function store(array $data): BudgetLimit
{
return BudgetLimit::create($data);
}
/**
* @param array $data
*
* @return BudgetLimit
* @deprecated
*/
public function storeBudgetLimit(array $data): BudgetLimit
{
/** @var Budget $budget */
@@ -303,12 +314,27 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
return $limit;
}
/**
* @param BudgetLimit $budgetLimit
* @param array $data
*
* @return BudgetLimit
*/
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit
{
$budgetLimit->amount = $data['amount'] ?? $budgetLimit->amount;
$budgetLimit->save();
return $budgetLimit;
}
/**
* @param BudgetLimit $budgetLimit
* @param array $data
*
* @return BudgetLimit
* @throws Exception
* @deprecated
*/
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit
{