Skip to content

Commit 90eb012

Browse files
committed
feat(playground): improve default agreement sample to better reflect legal use case
Signed-off-by: Vaishnavi <majojuvaishnavi@gmail.com>
1 parent 08cf368 commit 90eb012

File tree

1 file changed

+64
-79
lines changed

1 file changed

+64
-79
lines changed

src/samples/playground.ts

Lines changed: 64 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,84 @@
1-
const MODEL = `namespace hello@1.0.0
2-
import org.accordproject.money@0.3.0.{MonetaryAmount} from https://models.accordproject.org/money@0.3.0.cto
3-
4-
concept Address {
5-
o String line1
6-
o String city
7-
o String state
8-
o String country
9-
}
1+
const MODEL = `namespace org.accordproject.service@1.0.0
102
11-
concept OrderLine {
12-
o String sku
3+
concept ServiceItem {
4+
o String description
5+
o Double rate
136
o Integer quantity
14-
o Double price
15-
}
16-
17-
concept Order {
18-
o DateTime createdAt
19-
o OrderLine[] orderLines
207
}
218
229
@template
23-
concept TemplateData {
24-
o String name
25-
o Address address
26-
o Integer age optional
27-
o MonetaryAmount salary
28-
o String[] favoriteColors
29-
o Order order
10+
concept ServiceAgreement {
11+
o String clientName
12+
o String clientAddress
13+
o String providerName
14+
o String providerAddress
15+
o DateTime effectiveDate
16+
o ServiceItem[] services
17+
o Integer paymentTerms
3018
}`;
3119

32-
const TEMPLATE = `> A general sample that uses a range of features
33-
### Welcome {{name}}!
34-
35-
![AP Logo](https://avatars.githubusercontent.com/u/29445438?s=64)
20+
const TEMPLATE = `# SERVICE AGREEMENT
3621
37-
{{#clause address}}
38-
#### Address
39-
> {{line1}},
40-
{{city}}, {{state}},
41-
{{country}}
42-
{{/clause}}
22+
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}} (SProvider).
4323
44-
- You are *{{age}}* years old
45-
- Your monthly salary is {{salary as "0,0.00 CCC"}}
46-
- Your favorite colours are {{#join favoriteColors}}
24+
## 1. Services
4725
48-
{{#clause order}}
49-
## Orders
50-
Your last order was placed {{createdAt as "D MMMM YYYY"}} ({{% return now.diff(order.createdAt, 'day')%}} days ago).
26+
Provider shall perform the following services for Client:
5127
52-
{{#ulist orderLines}}
53-
- {{quantity}}x _{{sku}}_ @ £{{price as "0,0.00"}}
28+
{{#ulist services}}
29+
- {{description}} at {{rate as "0.00"}} per unit × {{quantity}}
5430
{{/ulist}}
55-
Order total: {{% return '£' + order.orderLines.map(ol => ol.price * ol.quantity).reduce((sum, cur) => sum + cur).toFixed(2);%}}
56-
{{/clause}}
5731
58-
Thank you.
32+
## 2. Compensation
33+
34+
In consideration for the services provided, Client shall pay Provider the total amount calculated below:
35+
36+
**Total Service Value:** {{%
37+
return '$' + services
38+
.map(s => s.rate * s.quantity)
39+
.reduce((sum, cur) => sum + cur, 0)
40+
.toFixed(2);
41+
%}}
42+
43+
Payment is due within {{paymentTerms}} days of invoice.
44+
45+
## 3. Execution
46+
47+
IN WITNESS WHEREOF, the parties hereto have executed this Agreement as of the date first written above.
48+
49+
---
50+
51+
### Client:
52+
{{clientName}}
53+
54+
### Provider:
55+
{{providerName}}
5956
`;
6057

6158
const DATA = {
62-
"$class" : "hello@1.0.0.TemplateData",
63-
"name": "John Doe",
64-
"address" : {
65-
"line1" : "1 Main Street",
66-
"city" : "Boson",
67-
"state" : "MA",
68-
"country" : "USA"
69-
},
70-
"age" : 42,
71-
"salary": {
72-
"$class": "org.accordproject.money@0.3.0.MonetaryAmount",
73-
"doubleValue": 1500,
74-
"currencyCode": "EUR"
59+
"$class": "org.accordproject.service@1.0.0.ServiceAgreement",
60+
"effectiveDate": "2026-02-01T00:00:00Z",
61+
"paymentTerms": 30,
62+
"clientName": "Acme Corp",
63+
"clientAddress": "123 Business Road, London, UK",
64+
"providerName": "DevConsult Ltd",
65+
"providerAddress": "456 Tech Street, Berlin, Germany",
66+
"services": [
67+
{
68+
"$class": "org.accordproject.service@1.0.0.ServiceItem",
69+
"description": "Backend Development",
70+
"rate": 80,
71+
"quantity": 40
7572
},
76-
"favoriteColors" : ['red', 'green', 'blue'],
77-
"order" : {
78-
"createdAt" : "2023-05-01",
79-
"$class" : "hello@1.0.0.Order",
80-
"orderLines":
81-
[
82-
{
83-
"$class" : "hello@1.0.0.OrderLine",
84-
"sku" : "ABC-123",
85-
"quantity" : 3,
86-
"price" : 29.99
87-
},
88-
{
89-
"$class" : "hello@1.0.0.OrderLine",
90-
"sku" : "DEF-456",
91-
"quantity" : 5,
92-
"price" : 19.99
93-
}
94-
]
73+
{
74+
"$class": "org.accordproject.service@1.0.0.ServiceItem",
75+
"description": "Code Review",
76+
"rate": 60,
77+
"quantity": 10
9578
}
79+
]
9680
};
9781

98-
const NAME = 'Customer Order';
99-
export {NAME, MODEL,DATA,TEMPLATE};
82+
const NAME = 'Service Agreement';
83+
84+
export { NAME, MODEL, DATA, TEMPLATE };

0 commit comments

Comments
 (0)