payday tests
This commit is contained in:
@@ -17,13 +17,13 @@
|
|||||||
clockIcon,
|
clockIcon,
|
||||||
giftIcon,
|
giftIcon,
|
||||||
handCoinsIcon,
|
handCoinsIcon,
|
||||||
moneyIcon,
|
|
||||||
coinsIcon,
|
coinsIcon,
|
||||||
walletIcon,
|
walletIcon,
|
||||||
chevronLeftIcon,
|
chevronLeftIcon,
|
||||||
chevronRightIcon
|
chevronRightIcon
|
||||||
} from '$lib/components/icons';
|
} from '$lib/components/icons';
|
||||||
import type { AssignedChore, Completion, ChoreTemplate, BonusConfig, Reward } from '$lib/types';
|
import type { AssignedChore, Completion, ChoreTemplate, BonusConfig, Reward } from '$lib/types';
|
||||||
|
import PiggyBank from '@lucide/svelte/icons/piggy-bank';
|
||||||
import { handleOf } from '@shared/slugify';
|
import { handleOf } from '@shared/slugify';
|
||||||
import {
|
import {
|
||||||
weekStart as tzWeekStart,
|
weekStart as tzWeekStart,
|
||||||
@@ -501,6 +501,15 @@
|
|||||||
return sum + (chore?.type === 'money' ? Number(chore.value) : 0);
|
return sum + (chore?.type === 'money' ? Number(chore.value) : 0);
|
||||||
}, 0)
|
}, 0)
|
||||||
);
|
);
|
||||||
|
// Week's cash-reward earnings (pocket money, bonuses) count while still
|
||||||
|
// pending AND once claimed — auto-created money-todo rewards are skipped
|
||||||
|
// (already counted via the chore completion above).
|
||||||
|
let weekRewardCash = $derived.by(() =>
|
||||||
|
weekRewards
|
||||||
|
.filter((r) => r.rewardType === 'cash' && !autoRewardIds.has(r.id))
|
||||||
|
.reduce((sum, r) => sum + Number(r.value), 0)
|
||||||
|
);
|
||||||
|
let weekCashTotal = $derived(weekChoreCash + weekRewardCash);
|
||||||
let weekChorePoints = $derived.by(() =>
|
let weekChorePoints = $derived.by(() =>
|
||||||
weekCompletions.reduce((sum, c) => {
|
weekCompletions.reduce((sum, c) => {
|
||||||
const chore = assigned.find((a) => a.id === c.assignedChoreId);
|
const chore = assigned.find((a) => a.id === c.assignedChoreId);
|
||||||
@@ -1250,7 +1259,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if showCountdown}
|
{#if showCountdown}
|
||||||
<div class="payday-countdown">
|
<div class="payday-countdown">
|
||||||
<div class="pd-icon">{@html moneyIcon}</div>
|
<div class="pd-icon"><PiggyBank size={44} strokeWidth={2} /></div>
|
||||||
<div class="pd-body">
|
<div class="pd-body">
|
||||||
<p class="pd-title">Payday is today!</p>
|
<p class="pd-title">Payday is today!</p>
|
||||||
<p class="pd-num">
|
<p class="pd-num">
|
||||||
@@ -1439,7 +1448,7 @@
|
|||||||
<!-- WEEK-TO-DATE TILES -->
|
<!-- WEEK-TO-DATE TILES -->
|
||||||
<div class="tiles">
|
<div class="tiles">
|
||||||
<div class="tile tile-cash">
|
<div class="tile tile-cash">
|
||||||
<span class="tile-val">£{weekChoreCash.toFixed(2)}</span>
|
<span class="tile-val">£{weekCashTotal.toFixed(2)}</span>
|
||||||
<span class="tile-lbl">cash this week</span>
|
<span class="tile-lbl">cash this week</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tile tile-pts">
|
<div class="tile tile-pts">
|
||||||
@@ -3066,12 +3075,14 @@
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
padding: 1rem 1.2rem;
|
padding: 1rem 1.2rem;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: linear-gradient(135deg, #4f46e5, #7c3aed);
|
background: linear-gradient(135deg, #f59e0b, #fbbf24);
|
||||||
color: #fff;
|
color: #451a03;
|
||||||
box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
|
box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
|
||||||
}
|
}
|
||||||
.pd-icon {
|
.pd-icon {
|
||||||
font-size: 1.8rem;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
.pd-body {
|
.pd-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -80,6 +80,12 @@
|
|||||||
detectedTz = '';
|
detectedTz = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 'auto' resolves to the SERVER's timezone (UTC in prod), not the
|
||||||
|
// family's — so during BST everything lands an hour late. Pre-select
|
||||||
|
// the admin's own zone so saving stores a real IANA zone (DST-aware).
|
||||||
|
if ((timezone === 'auto' || !timezone) && detectedTz && timezoneOptions.includes(detectedTz)) {
|
||||||
|
timezone = detectedTz;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let qrDataUrl = $state('');
|
let qrDataUrl = $state('');
|
||||||
let copied = $state(false);
|
let copied = $state(false);
|
||||||
@@ -262,8 +268,9 @@
|
|||||||
<Button type="submit" size="sm">Set payday</Button>
|
<Button type="submit" size="sm">Set payday</Button>
|
||||||
</form>
|
</form>
|
||||||
<p class="hint">
|
<p class="hint">
|
||||||
Payday: the week starts on this day and weekly earnings are settled at this time. Auto
|
Payday: the week starts on this day and weekly earnings are settled at this time. Pick
|
||||||
timezone follows each device.
|
your city so payday lands at the right local time — Auto uses the server's timezone
|
||||||
|
(UTC), which is an hour out during daylight saving.
|
||||||
</p>
|
</p>
|
||||||
</Card>
|
</Card>
|
||||||
<Card title="Seasons" cols={1}>
|
<Card title="Seasons" cols={1}>
|
||||||
|
|||||||
Reference in New Issue
Block a user