codex-work-receipt 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.en.md +28 -111
- package/README.md +29 -189
- package/docs/cli.en.md +133 -0
- package/docs/cli.md +133 -0
- package/docs/codex-skill.en.md +45 -0
- package/docs/codex-skill.md +45 -0
- package/docs/data-schema.en.md +35 -0
- package/docs/data-schema.md +19 -9
- package/docs/images/social-preview-source.svg +84 -0
- package/docs/images/social-preview.png +0 -0
- package/docs/mobile-import.en.md +19 -0
- package/docs/mobile-import.md +13 -9
- package/docs/privacy.en.md +30 -0
- package/docs/privacy.md +26 -8
- package/package.json +1 -1
- package/skills/ai-work-receipt/SKILL.md +5 -2
- package/src/cli.mjs +23 -4
- package/src/core/args.mjs +35 -4
- package/src/core/metrics.mjs +37 -25
- package/src/core/presentation.mjs +22 -7
- package/src/core/qr-payload.mjs +10 -2
- package/src/core/range.mjs +99 -0
- package/src/core/receipt-record.mjs +10 -3
- package/src/core/selector.mjs +71 -0
- package/src/parsers/codex.mjs +77 -11
- package/src/renderers/html.mjs +14 -2
package/src/renderers/html.mjs
CHANGED
|
@@ -20,6 +20,12 @@ function formatCount(value, units, locale) {
|
|
|
20
20
|
return `${formatNumber(amount, locale)} ${unit}`;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function formatDateKey(value, locale) {
|
|
24
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(value || ""));
|
|
25
|
+
if (!match) return String(value || "");
|
|
26
|
+
return locale === "en" ? `${match[2]}/${match[3]}/${match[1]}` : `${match[1]}/${match[2]}/${match[3]}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
export function renderHtml({ record, dataQrDataUrl, miniProgramCodeDataUrl = null }) {
|
|
24
30
|
const locale = record.locale || DEFAULT_LOCALE;
|
|
25
31
|
const copy = getReceiptCopy(locale);
|
|
@@ -27,7 +33,13 @@ export function renderHtml({ record, dataQrDataUrl, miniProgramCodeDataUrl = nul
|
|
|
27
33
|
const endAt = new Date(record.period.end_at);
|
|
28
34
|
const timezone = record.period.timezone;
|
|
29
35
|
const displayDate = formatDate(endAt, timezone, locale);
|
|
30
|
-
const
|
|
36
|
+
const rangeStartDate = record.period.range_start_date || formatDateKey(record.period.start_at.slice(0, 10), "zh-CN").replaceAll("/", "-");
|
|
37
|
+
const rangeEndDate = record.period.range_end_date || formatDateKey(record.period.end_at.slice(0, 10), "zh-CN").replaceAll("/", "-");
|
|
38
|
+
const spansMultipleDates = rangeStartDate !== rangeEndDate;
|
|
39
|
+
const businessPeriod = spansMultipleDates
|
|
40
|
+
? `${formatDateKey(rangeStartDate, locale)}—${formatDateKey(rangeEndDate, locale)}`
|
|
41
|
+
: `${formatTime(startAt, timezone, locale)}—${formatTime(endAt, timezone, locale)}`;
|
|
42
|
+
const businessPeriodLabel = spansMultipleDates ? copy.meta.period : copy.meta.hours;
|
|
31
43
|
const scopeLabel = copy.scope[record.source.scope] || copy.scope.latest;
|
|
32
44
|
const modelLabel = record.stats.models.length ? record.stats.models.join(" / ") : copy.modelMissing;
|
|
33
45
|
const receiptNumber = `${record.id.slice(4, 12).toUpperCase()}-${String(record.stats.completed_turns).padStart(3, "0")}`;
|
|
@@ -329,7 +341,7 @@ export function renderHtml({ record, dataQrDataUrl, miniProgramCodeDataUrl = nul
|
|
|
329
341
|
|
|
330
342
|
<section class="meta">
|
|
331
343
|
<div>${escapeHtml(copy.meta.date)}: ${escapeHtml(displayDate)}</div>
|
|
332
|
-
<div>${escapeHtml(
|
|
344
|
+
<div>${escapeHtml(businessPeriodLabel)}: ${escapeHtml(businessPeriod)}</div>
|
|
333
345
|
<div>${escapeHtml(copy.meta.number)}: ${escapeHtml(receiptNumber)}</div>
|
|
334
346
|
<div>${escapeHtml(copy.meta.timezone)}: ${escapeHtml(timezone)}</div>
|
|
335
347
|
</section>
|