-
-
Notifications
You must be signed in to change notification settings - Fork 213
feat(playground): improve default agreement sample #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mttrbrts
merged 3 commits into
accordproject:main
from
mi-vaishnavi:improve-default-agreement-sample
Mar 2, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,99 +1,105 @@ | ||
| const MODEL = `namespace hello@1.0.0 | ||
| import org.accordproject.money@0.3.0.{MonetaryAmount} from https://models.accordproject.org/money@0.3.0.cto | ||
|
|
||
| concept Address { | ||
| o String line1 | ||
| o String city | ||
| o String state | ||
| o String country | ||
| } | ||
| const MODEL = `namespace org.accordproject.service@1.0.0 | ||
|
|
||
| concept OrderLine { | ||
| o String sku | ||
| concept ServiceItem { | ||
| o String description | ||
| o Double rate | ||
| o Integer quantity | ||
| o Double price | ||
| } | ||
|
|
||
| concept Order { | ||
| o DateTime createdAt | ||
| o OrderLine[] orderLines | ||
| concept Compensation { | ||
| o ServiceItem[] services | ||
| o Integer paymentTerms | ||
| } | ||
|
|
||
| @template | ||
| concept TemplateData { | ||
| o String name | ||
| o Address address | ||
| o Integer age optional | ||
| o MonetaryAmount salary | ||
| o String[] favoriteColors | ||
| o Order order | ||
| concept ServiceAgreement { | ||
| o String clientName | ||
| o String clientAddress | ||
| o String providerName | ||
| o String providerAddress | ||
| o DateTime effectiveDate | ||
| o Compensation compensation | ||
| }`; | ||
|
|
||
| const TEMPLATE = `> A general sample that uses a range of features | ||
| ### Welcome {{name}}! | ||
| 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). | ||
|
|
||
| {{#clause address}} | ||
| #### Address | ||
| > {{line1}}, | ||
| {{city}}, {{state}}, | ||
| {{country}} | ||
| {{/clause}} | ||
| --- | ||
|
|
||
| - You are *{{age}}* years old | ||
| - Your monthly salary is {{salary as "0,0.00 CCC"}} | ||
| - Your favorite colours are {{#join favoriteColors}} | ||
| ## 1. Services | ||
|
|
||
| {{#clause order}} | ||
| ## Orders | ||
| Your last order was placed {{createdAt as "D MMMM YYYY"}} ({{% return now.diff(order.createdAt, 'day')%}} days ago). | ||
| {{#clause compensation}} | ||
| ### Services Provided | ||
|
|
||
| {{#ulist orderLines}} | ||
| - {{quantity}}x _{{sku}}_ @ £{{price as "0,0.00"}} | ||
| {{#ulist services}} | ||
| - {{description}} at {{rate as "0.00"}} per unit × {{quantity}} | ||
| {{/ulist}} | ||
| Order total: {{% return '£' + order.orderLines.map(ol => ol.price * ol.quantity).reduce((sum, cur) => sum + cur).toFixed(2);%}} | ||
|
|
||
| ### Payment Terms | ||
| Payment is due within {{paymentTerms}} days of invoice. | ||
| {{/clause}} | ||
|
|
||
| Thank you. | ||
| --- | ||
|
|
||
| ## 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" : "hello@1.0.0.TemplateData", | ||
| "name": "John Doe", | ||
| "address" : { | ||
| "line1" : "1 Main Street", | ||
| "city" : "Boson", | ||
| "state" : "MA", | ||
| "country" : "USA" | ||
| }, | ||
| "age" : 42, | ||
| "salary": { | ||
| "$class": "org.accordproject.money@0.3.0.MonetaryAmount", | ||
| "doubleValue": 1500, | ||
| "currencyCode": "EUR" | ||
| }, | ||
| "favoriteColors" : ['red', 'green', 'blue'], | ||
| "order" : { | ||
| "createdAt" : "2023-05-01", | ||
| "$class" : "hello@1.0.0.Order", | ||
| "orderLines": | ||
| [ | ||
| { | ||
| "$class" : "hello@1.0.0.OrderLine", | ||
| "sku" : "ABC-123", | ||
| "quantity" : 3, | ||
| "price" : 29.99 | ||
| }, | ||
| { | ||
| "$class" : "hello@1.0.0.OrderLine", | ||
| "sku" : "DEF-456", | ||
| "quantity" : 5, | ||
| "price" : 19.99 | ||
| } | ||
| "$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 = 'Customer Order'; | ||
| export {NAME, MODEL,DATA,TEMPLATE}; | ||
| const NAME = 'Service Agreement'; | ||
|
|
||
| export { NAME, MODEL, DATA, TEMPLATE }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.