inline "x of y" recurrence limit fields; Follow-FinanceBuddy governs the stop (v1.6.2)

This commit is contained in:
2026-07-10 09:36:32 -03:00
parent daac5f3b54
commit 9b486970d3
4 changed files with 30 additions and 23 deletions

View File

@@ -121,17 +121,21 @@ class RecoRecoModel extends Base
// Default off: only keep the duplicate link when explicitly turned on.
$linkCopies = isset($meta['recoreco_link_copies']) && $meta['recoreco_link_copies'] == 1;
// Finite-plan stop. RecoReco caps its own recurrence: either by its own limit (standalone),
// or by following FinanceBuddy's installment total. In follow mode both numbers are read LIVE
// from FinanceBuddy (never copied into RecoReco), so a mid-plan start, a re-purchase, or an
// extend all just work by editing FinanceBuddy. A blank/0 limit means recur forever. The
// spawn loop below stops when counter > limit (1-based; the counter ends on limit+1).
// Finite-plan stop. RecoReco caps its own recurrence, either by its own limit (standalone) or
// by following FinanceBuddy. When follow is on, FinanceBuddy governs: the plan is finite only
// if the card has a numeric installment total, so an ordinary recurring bill (money but no
// installments) recurs forever -- and any stale standalone limit is ignored. In follow mode
// the numbers are read LIVE from FinanceBuddy (never copied), so a mid-plan start, a
// re-purchase, or an extend all just work by editing FinanceBuddy. A blank/0 limit means
// recur forever. The spawn loop below stops when counter > limit (1-based; counter ends on
// limit+1).
$followIntent = isset($meta['recoreco_follow_finance']) && $meta['recoreco_follow_finance'] == 1;
$fbTotal = isset($meta['financebuddy_installment_total']) ? (string) $meta['financebuddy_installment_total'] : '';
$follow = isset($meta['recoreco_follow_finance']) && $meta['recoreco_follow_finance'] == 1
&& $fbTotal !== '' && ctype_digit($fbTotal);
$fbHasTotal = $fbTotal !== '' && ctype_digit($fbTotal);
$follow = $followIntent && $fbHasTotal;
if ($follow) {
$limit = (int) $fbTotal;
if ($followIntent) {
$limit = $fbHasTotal ? (int) $fbTotal : 0; // following FinanceBuddy; no total => forever
} else {
$limitRaw = isset($meta['recoreco_limit']) ? (string) $meta['recoreco_limit'] : '';
$limit = ($limitRaw !== '' && ctype_digit($limitRaw)) ? (int) $limitRaw : 0;

View File

@@ -62,7 +62,7 @@ class Plugin extends Base
public function getPluginVersion()
{
return '1.6.1';
return '1.6.2';
}
public function getPluginHomepage()

View File

@@ -63,26 +63,29 @@
<p class="form-help"><?= t('Links each copy back to the template (a count and quick navigation). Off by default.') ?></p>
<?php $following = $fb_enabled && $values['recoreco_follow_finance'] == 1 ?>
<?php $limit_display = (int) $values['recoreco_limit'] > 0 ? (int) $values['recoreco_limit'] : '' ?>
<div class="recoreco-limit-group"
data-fb-current="<?= $this->text->e($fb_current === '' ? '1' : $fb_current) ?>"
data-fb-total="<?= $this->text->e($fb_total === '' ? '0' : $fb_total) ?>"
data-fb-current="<?= $this->text->e($fb_current) ?>"
data-fb-total="<?= $this->text->e($fb_total) ?>"
data-rr-count="<?= (int) $values['recoreco_count'] ?>"
data-rr-limit="<?= (int) $values['recoreco_limit'] ?>">
data-rr-limit="<?= $this->text->e($limit_display) ?>">
<?php if ($fb_enabled): ?>
<?= $this->form->checkbox('recoreco_follow_finance', t('Follow FinanceBuddy installments'), 1, $following) ?>
<p class="form-help"><?= t('Stop recurring when the installment plan ends, following the card total and current installment.') ?></p>
<?php endif ?>
<?= $this->form->label(t('Current recurrence'), 'recoreco_count') ?>
<input type="number" name="recoreco_count" min="1"
value="<?= $this->text->e($following ? ($fb_current === '' ? '1' : $fb_current) : $values['recoreco_count']) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>>
<?= $this->form->label(t('Stop after this many recurrences (0 = never)'), 'recoreco_limit') ?>
<input type="number" name="recoreco_limit" min="0"
value="<?= $this->text->e($following ? ($fb_total === '' ? '0' : $fb_total) : $values['recoreco_limit']) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>>
<?= $this->form->label(t('Recurrence'), 'recoreco_count') ?>
<div class="recoreco-limit-inline" style="display:flex; align-items:center; gap:6px;">
<input type="number" name="recoreco_count" min="1" style="width:5em;"
value="<?= $this->text->e($following ? $fb_current : $values['recoreco_count']) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>>
<span><?= t('of') ?></span>
<input type="number" name="recoreco_limit" min="1" style="width:5em;"
value="<?= $this->text->e($following ? $fb_total : $limit_display) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>>
</div>
<p class="form-help"><?= t('Current recurrence and how many to run. Leave the second box empty to recur forever.') ?></p>
</div>
<?= $this->modal->submitButtons() ?>

View File

@@ -1 +1 @@
RecoReco v1.6.1
RecoReco v1.6.2