Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b4b7ef74d6 | |||
| eac8617723 | |||
| 3e0cf10d6c | |||
| 524f293e37 | |||
| 5ba4029912 | |||
| 305ee59477 | |||
| 7fde8cb3d9 |
@@ -2,13 +2,27 @@
|
|||||||
* FinanceBuddy styles.
|
* FinanceBuddy styles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Per-column net total in the column header (its own line, subtle pill). */
|
/* The column header (.board-column-expanded-header) is a flex row, so the total is a flex item. To
|
||||||
|
drop it onto its own line under the title, let that header wrap (scoped with :has to headers that
|
||||||
|
actually contain the total -- i.e. enabled boards only) and give the total full width. No
|
||||||
|
background (dropped per request); "Total:" stays black, only the amount span is colored by sign. */
|
||||||
|
.board-column-expanded-header:has(.fb-column-total) {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
.fb-column-total {
|
.fb-column-total {
|
||||||
|
flex-basis: 100%;
|
||||||
|
margin-top: 2px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The visible pill hugs the text (not the full width) and is right-justified on its line. */
|
||||||
|
.fb-total-pill {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: 3px;
|
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.95em;
|
font-size: 0.95em;
|
||||||
|
color: #000;
|
||||||
background: rgba(0, 0, 0, 0.05);
|
background: rgba(0, 0, 0, 0.05);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,19 @@ class FinancePersistence extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* recoreco:task:spawned -- RecoReco (calendar recurrence) just spawned a copy. Its ongoing card
|
||||||
|
* is the TEMPLATE that stays (unlike native recurrence, whose ongoing card is the new child), so
|
||||||
|
* advance the SOURCE template's installment. The clone already copied the current installment
|
||||||
|
* verbatim via onDuplication during RecoReco's duplicate() call.
|
||||||
|
*/
|
||||||
|
public function onRecoRecoSpawn(array &$payload)
|
||||||
|
{
|
||||||
|
if (! empty($payload['source_task_id'])) {
|
||||||
|
$this->advanceInstallment((int) $payload['source_task_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* model:task:modification:prepare -- fires before UPDATE, $values by reference. The task id is
|
* model:task:modification:prepare -- fires before UPDATE, $values by reference. The task id is
|
||||||
* removed from $values by core, but it is the route parameter of the modification request.
|
* removed from $values by core, but it is the route parameter of the modification request.
|
||||||
@@ -176,6 +189,34 @@ class FinancePersistence extends Base
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advance a task's current installment by one, in place. A finite plan clamps at total+1, one
|
||||||
|
* past the last installment: that overflow is the "plan complete" tombstone (p4/3) that RecoReco
|
||||||
|
* reads to stop a following recurrence, and it caps runaway when nothing follows. Clones still
|
||||||
|
* read p1/total .. pTotal/total because a clone snapshots current BEFORE this advance. An
|
||||||
|
* open-ended plan (no total) increments unbounded (p2 -> p3); cards with no numeric current
|
||||||
|
* installment are left alone.
|
||||||
|
*/
|
||||||
|
private function advanceInstallment($task_id)
|
||||||
|
{
|
||||||
|
$current = $this->taskMetadataModel->get($task_id, FinanceHelper::INSTALLMENT_CURRENT_KEY, '');
|
||||||
|
|
||||||
|
if ($current === '' || ! ctype_digit((string) $current)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = $this->taskMetadataModel->get($task_id, FinanceHelper::INSTALLMENT_TOTAL_KEY, '');
|
||||||
|
$next = (int) $current + 1;
|
||||||
|
|
||||||
|
if ($total !== '' && ctype_digit((string) $total) && $next > (int) $total + 1) {
|
||||||
|
$next = (int) $total + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->taskMetadataModel->save($task_id, array(
|
||||||
|
FinanceHelper::INSTALLMENT_CURRENT_KEY => (string) $next,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function intOrBlank($raw)
|
private function intOrBlank($raw)
|
||||||
{
|
{
|
||||||
$raw = trim((string) $raw);
|
$raw = trim((string) $raw);
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ class Plugin extends Base
|
|||||||
// and a manual Duplicate copies it verbatim.
|
// and a manual Duplicate copies it verbatim.
|
||||||
$this->hook->on('model:task:duplication:aftersave', array($persistence, 'onDuplication'));
|
$this->hook->on('model:task:duplication:aftersave', array($persistence, 'onDuplication'));
|
||||||
|
|
||||||
|
// RecoReco (calendar recurrence) spawns a copy and emits this signal. The clone already got
|
||||||
|
// the finance verbatim (via onDuplication above); here we advance the SOURCE template's
|
||||||
|
// installment, since RecoReco's ongoing card is the template that stays.
|
||||||
|
$this->hook->on('recoreco:task:spawned', array($persistence, 'onRecoRecoSpawn'));
|
||||||
|
|
||||||
// The line-3 money badge on each board card, rendered directly under the title. Two hooks:
|
// The line-3 money badge on each board card, rendered directly under the title. Two hooks:
|
||||||
// "private" is the normal board, "public" is the read-only board shared by token.
|
// "private" is the normal board, "public" is the read-only board shared by token.
|
||||||
$this->template->hook->attach('template:board:private:task:after-title', 'financeBuddy:board/task_money');
|
$this->template->hook->attach('template:board:private:task:after-title', 'financeBuddy:board/task_money');
|
||||||
@@ -72,7 +77,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '1.0.1';
|
return '1.1.2';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
26
README.md
26
README.md
@@ -51,6 +51,15 @@ Each column header shows a **`Total:`** of its cards -- credits positive, debits
|
|||||||
net): red when negative (what you owe), green when positive, gray at zero. It is shown for every
|
net): red when negative (what you owe), green when positive, gray at zero. It is shown for every
|
||||||
column, including `Total: R$0,00`.
|
column, including `Total: R$0,00`.
|
||||||
|
|
||||||
|
### Installments and recurrence
|
||||||
|
|
||||||
|
FinanceBuddy carries the money across copies. Kanboard's built-in recurrence and RecoReco's
|
||||||
|
calendar recurrence advance the installment on the next occurrence (`p2/10 -> p3/10`); a manual
|
||||||
|
duplicate copies it as-is. When a RecoReco-followed plan finishes, the parked template is left one
|
||||||
|
past the last installment (`p3/3 -> p4/3`) as a "plan complete" marker that RecoReco reads to stop
|
||||||
|
recurring; the copies themselves still read `p1/3 .. p3/3`. Open-ended plans (blank total) keep
|
||||||
|
counting.
|
||||||
|
|
||||||
## Money format
|
## Money format
|
||||||
|
|
||||||
Amounts show in R$ with a comma decimal and no thousand separator (for example `R$1234,56`).
|
Amounts show in R$ with a comma decimal and no thousand separator (for example `R$1234,56`).
|
||||||
@@ -78,3 +87,20 @@ Settings -> Integrations and tick "Enable FinanceBuddy on this board".
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
AGPL-3.0. See LICENSE.
|
AGPL-3.0. See LICENSE.
|
||||||
|
|
||||||
|
## More Kanboard plugins by Ruben (drbeco)
|
||||||
|
|
||||||
|
All free and AGPL-3.0, at [code.beco.cc](https://code.beco.cc/beco):
|
||||||
|
|
||||||
|
- **[RecoReco](https://code.beco.cc/beco/RecoReco)** -- calendar-scheduled recurring cards (yearly,
|
||||||
|
monthly, weekly, daily), driven by the card due date. Pairs directly with FinanceBuddy: recurring
|
||||||
|
bills spawn on schedule and their installments count down until the plan is paid off.
|
||||||
|
- **[OrganonTweaks](https://code.beco.cc/beco/OrganonTweaks)** -- an umbrella of small
|
||||||
|
quality-of-life board tweaks: remove an empty column, always show the comment icon, emphasize due
|
||||||
|
dates, extra search keywords and shared board filters, and more.
|
||||||
|
- **[BulkMoveTasks](https://code.beco.cc/beco/BulkMoveTasks)** -- move every task from one board
|
||||||
|
column to another in a single action.
|
||||||
|
- **[ShrinkVertically](https://code.beco.cc/beco/ShrinkVertically)** -- shrink vertically-collapsed
|
||||||
|
board columns so the horizontal scrollbar stays within reach.
|
||||||
|
- **[TweakDrag](https://code.beco.cc/beco/TweakDrag)** -- board drag and touch niceties:
|
||||||
|
drag-to-scroll, a wider column gap, and smoother card dragging.
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
// Per-column net total in the column header (credits - debits). Shown in every column of an
|
// Per-column net total in the column header (credits - debits). Shown in every column of an
|
||||||
// enabled board, including "total R$0,00" -- never hidden on zero. Server-side, re-renders on
|
// enabled board, including "Total: R$0,00" -- never hidden on zero. Server-side, re-renders on
|
||||||
// every board refresh.
|
// every board refresh. Rendered on its own full-width line under the title; "Total:" stays the
|
||||||
|
// default (black) and only the amount is colored by sign.
|
||||||
if (empty($column['project_id']) || ! $this->FinanceHelper->isEnabled($column['project_id'])) {
|
if (empty($column['project_id']) || ! $this->FinanceHelper->isEnabled($column['project_id'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -9,16 +10,16 @@ if (empty($column['project_id']) || ! $this->FinanceHelper->isEnabled($column['p
|
|||||||
$net = $this->FinanceHelper->columnNet($column);
|
$net = $this->FinanceHelper->columnNet($column);
|
||||||
|
|
||||||
if ($net > 0) {
|
if ($net > 0) {
|
||||||
$class = 'fb-column-total fb-total-credit';
|
$amount_class = 'fb-total-credit';
|
||||||
$sign = '+';
|
$sign = '+';
|
||||||
} elseif ($net < 0) {
|
} elseif ($net < 0) {
|
||||||
$class = 'fb-column-total fb-total-debit';
|
$amount_class = 'fb-total-debit';
|
||||||
$sign = '-';
|
$sign = '-';
|
||||||
} else {
|
} else {
|
||||||
$class = 'fb-column-total fb-total-zero';
|
$amount_class = 'fb-total-zero';
|
||||||
$sign = '';
|
$sign = '';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="<?= $class ?>">
|
<div class="fb-column-total">
|
||||||
<?= t('Total') ?>: <span class="fb-amount"><?= $sign ?>R$<?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::money(abs($net)) ?></span>
|
<span class="fb-total-pill"><?= t('Total') ?>: <span class="fb-amount <?= $amount_class ?>"><?= $sign ?>R$<?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::money(abs($net)) ?></span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,13 +15,18 @@ if ($fb['amount'] === '' || (float) $fb['amount'] <= 0) {
|
|||||||
$credit = $fb['direction'] === 'credit';
|
$credit = $fb['direction'] === 'credit';
|
||||||
$sign = $credit ? '+' : '-';
|
$sign = $credit ? '+' : '-';
|
||||||
$total = $fb['installment_total'];
|
$total = $fb['installment_total'];
|
||||||
$current = $fb['installment_current'] !== '' ? $fb['installment_current'] : '1';
|
$current = $fb['installment_current'];
|
||||||
|
|
||||||
|
// Installments: "p2/10" when a total is set; "p2" (open-ended) when only the current is set;
|
||||||
|
// nothing when neither is set. Default the current to 1 if only a total was entered.
|
||||||
|
$show_installments = $current !== '' || $total !== '';
|
||||||
|
$current_display = $current !== '' ? $current : '1';
|
||||||
?>
|
?>
|
||||||
<div class="fb-line">
|
<div class="fb-line">
|
||||||
<span class="fb-badge <?= $credit ? 'fb-badge-credit' : 'fb-badge-debit' ?>">
|
<span class="fb-badge <?= $credit ? 'fb-badge-credit' : 'fb-badge-debit' ?>">
|
||||||
<?= $sign ?>R$<?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::money($fb['amount']) ?>
|
<?= $sign ?>R$<?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::money($fb['amount']) ?>
|
||||||
</span>
|
</span>
|
||||||
<?php if ($total !== ''): ?>
|
<?php if ($show_installments): ?>
|
||||||
<span class="fb-installments">p<?= $this->text->e($current) ?>/<?= $this->text->e($total) ?></span>
|
<span class="fb-installments">p<?= $this->text->e($current_display) ?><?= $total !== '' ? '/'.$this->text->e($total) : '' ?></span>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,3 +18,4 @@
|
|||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
<span><?= t('of') ?></span>
|
<span><?= t('of') ?></span>
|
||||||
<input type="number" min="1" name="financebuddy_installment_total" value="<?= $this->text->e($fb['installment_total']) ?>" class="fb-form-num">
|
<input type="number" min="1" name="financebuddy_installment_total" value="<?= $this->text->e($fb['installment_total']) ?>" class="fb-form-num">
|
||||||
</div>
|
</div>
|
||||||
<p class="form-help"><?= t('Leave the total blank for an open-ended recurring bill.') ?></p>
|
<p class="form-help"><?= t('Set a total for a finite plan (shows p2/10); leave it blank for an open-ended count (shows p2).') ?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user