forked from accordproject/template-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.ts
More file actions
105 lines (80 loc) · 2.23 KB
/
playground.ts
File metadata and controls
105 lines (80 loc) · 2.23 KB
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
101
102
103
104
105
const MODEL = `namespace org.accordproject.service@1.0.0
concept ServiceItem {
o String description
o Double rate
o Integer quantity
}
concept Compensation {
o ServiceItem[] services
o Integer paymentTerms
}
@template
concept ServiceAgreement {
o String clientName
o String clientAddress
o String providerName
o String providerAddress
o DateTime effectiveDate
o Compensation compensation
}`;
const TEMPLATE = `# SERVICE AGREEMENT
This Service Agreement is made and entered into as of
{{effectiveDate as "D MMMM YYYY"}}
by and between {{clientName}}, located at {{clientAddress}} (Client),
and {{providerName}}, located at {{providerAddress}} (Provider).
---
## 1. Services
{{#clause compensation}}
### Services Provided
{{#ulist services}}
- {{description}} at {{rate as "0.00"}} per unit × {{quantity}}
{{/ulist}}
### Payment Terms
Payment is due within {{paymentTerms}} days of invoice.
{{/clause}}
---
## 2. Total Compensation
**Total Service Value:** {{%
return '$' + compensation.services
.map(s => s.rate * s.quantity)
.reduce((sum, cur) => sum + cur, 0)
.toFixed(2);
%}}
---
## 3. Execution
IN WITNESS WHEREOF, the parties hereto have executed this Agreement.
### Client:

{{clientName}}
### Provider:

{{providerName}}
`;
const DATA = {
"$class": "org.accordproject.service@1.0.0.ServiceAgreement",
"effectiveDate": "2026-02-01T00:00:00Z",
"clientName": "Acme Corp",
"clientAddress": "123 Business Road, London, UK",
"providerName": "DevConsult Ltd",
"providerAddress": "456 Tech Street, Berlin, Germany",
"compensation": {
"$class": "org.accordproject.service@1.0.0.Compensation",
"paymentTerms": 30,
"services": [
{
"$class": "org.accordproject.service@1.0.0.ServiceItem",
"description": "Backend Development",
"rate": 80,
"quantity": 40
},
{
"$class": "org.accordproject.service@1.0.0.ServiceItem",
"description": "Code Review",
"rate": 60,
"quantity": 10
}
]
}
};
const NAME = 'Service Agreement';
export { NAME, MODEL, DATA, TEMPLATE };