mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Allow user to set multi-currency available budget. WIP
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
@@ -35,6 +35,19 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface BudgetLimitRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Tells you which amount has been budgeted (for the given budgets)
|
||||
* in the selected query. Returns a positive amount as a string.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection|null $budgets
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function budgeted(Carbon $start, Carbon $end, TransactionCurrency $currency, ?Collection $budgets = null): string;
|
||||
|
||||
/**
|
||||
* Destroy a budget limit.
|
||||
*
|
||||
@@ -80,20 +93,15 @@ interface BudgetLimitRepositoryInterface
|
||||
*
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function storeBudgetLimit(array $data): BudgetLimit;
|
||||
public function store(array $data): BudgetLimit;
|
||||
|
||||
/**
|
||||
* Tells you which amount has been budgeted (for the given budgets)
|
||||
* in the selected query. Returns a positive amount as a string.
|
||||
* @param array $data
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection|null $budgets
|
||||
*
|
||||
* @return string
|
||||
* @return BudgetLimit
|
||||
* @deprecated
|
||||
*/
|
||||
public function budgeted(Carbon $start, Carbon $end, TransactionCurrency $currency, ?Collection $budgets = null): string;
|
||||
public function storeBudgetLimit(array $data): BudgetLimit;
|
||||
|
||||
/**
|
||||
* @param BudgetLimit $budgetLimit
|
||||
@@ -101,6 +109,15 @@ interface BudgetLimitRepositoryInterface
|
||||
*
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit;
|
||||
|
||||
/**
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param array $data
|
||||
*
|
||||
* @return BudgetLimit
|
||||
* @deprecated
|
||||
*/
|
||||
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user