1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource npm:hono/jsx **/
import { invoices } from "https://esm.town/v/pomdtr/invoice_deta_data";
import stylesheet from "https://esm.town/v/pomdtr/invoice_stylesheet";
import { Hono } from "npm:hono";
const router = new Hono();
router.get("/", (c) => {
return c.html(
<html>
<body>
<ul>
{Object.keys(invoices).map((key) => (
<li key={key}>
<a href={`/${key}`}>{key}</a>
</li>
))}
</ul>
</body>
</html>
);
});
router.get("/:id", (c) => {
const invoice = invoices[c.req.param("id")];
const items = invoice.tasks.map((task) => ({
title: `${task.title} (${task.hours}h)`,
price: task.hours * 70,
}));
if (invoice.extras) {
items.push(...invoice.extras);
}
const total_price = items.reduce(
(total, current) => total + current.price,
0
);
return c.html(
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="https://fav.farm/🧾" />
<title>
Invoice {formatDateShort(invoice.start)}{" "}
{formatDateShort(invoice.end)}
</title>
<style dangerouslySetInnerHTML={{ __html: stylesheet }}></style>
</head>
<body>
<div class="invoice-box">
<table cellpadding="0" cellspacing="0">
<tr>
<td colspan={2}></td>
<td colspan={2}>
<table>
<tr>
<td>
<b>Invoice #:</b> {c.req.param("id")}
<br />
<b>Created:</b> {formatDateLong(invoice.created)}
<br />
<b>Due:</b> {formatDateLong(addWeeks(invoice.created, 2))}
</td>
</tr>
</table>
</td>
</tr>
<tr class="information">
<td colspan={4}>
<table>
<tr>
<td>
Achille Lacoin
<br />
9 rue Philibert Lucot, Paris, France
<br />
+33 7 55 68 90 12‬
<br />
achille.lacoin@gmail.com
<br />
SIREN 94752390800012
</td>
<td>
Deta Gmbh
<br />
Sophienstr. 8, 10178 Berlin, Germany
<br />
Berlin, Germany
<br />
team@deta.town
</td>
</tr>
</table>