template-archive icon indicating copy to clipboard operation
template-archive copied to clipboard

Allow property references in templates

Open dselman opened this issue 6 years ago • 4 comments

E.g. a template parameter that was something like [{product.name}]

dselman avatar Feb 21 '19 19:02 dselman

Hi, just to give more context. How to reference a graph tree from the template text, and emulate the usual dot notation in OO languages.

HamidMoutawakkil avatar Feb 21 '19 19:02 HamidMoutawakkil

I am curious to know what the natural language contract would look like? (i.e., not the template, but the instantiated/sample contract).

jeromesimeon avatar Feb 21 '19 20:02 jeromesimeon

Here's an example of PO

Trivial Purchase Order


Parties
=======
The parties and their respective roles in this agreement are:
- The "buyer" with the identity "did:dummy:AAAAA"
- The "seller" with the identity "did:dummy:BBBBB"
- The "shipper" with the identity "did:dummy:CCCCC" 

Products
========
The products covered by this purchase order are (all quantities are express in TON(s) or fraction(s) of TON:
30 of "Rice grade A" (product code: "cereals.rices.gradeA") at the unit price of 200 EUR. 
10 of "Weat grade B" (product code: "cereals.weats.gradeC") at the unit price of 100 EUR.

Deliveries
==========
Every 15 days, starting 01/03/2019, the supplier will deliver:
5 of rice
2 of weat
Until the purchase order is completed, or the purchase order is terminated. 
For every delivery, the supplier will have to send the seller the proof of delivery. 
The format of the PoD will have to be signed by both buyer and shipper, under the responsability of the shipper. 
In case of dispute, regarding the delivery, blablabla...

Invoices
========
For each PoD received by the supplier, he'll issue an invoice for the products delivered. 

Payments
========
Payment is due for each invoice, 15 days after invoice date. 
In case of delay of payment, penalty is 5% of the amount of the delayed invoice_

Here's what I' trying to do (I'm new to concerto, but this shows the intent)

Today I do this, to define an agreement:

the CTO
/**
 * A trivial purchase order model 
 */
asset TrivialOrder extends AccordContract {
  o QuantifiableValue totalQty
  o String name
  o String code 
  o MonetaryAmount unitPrice
}

and the template

Products
========
The products covered by this purchase order are (all quantities are express in TON(s) or fraction(s) of TON:
[{p1TotalQty}] of [{p1Name}] (product code: [{p1Code}]) at the unit price of [{p1UnitPrice}]. 

What I'd like to do it this CTO

/**
 * A trivial purchase order model 
 */
asset TrivialOrder extends AccordContract {
	o Product product
}

concept Product identifed by code {
  o QuantifiableValue totalQty
  o String name
  o String code 
  o MonetaryAmount unitPrice
}

and the template

Products
========
The products covered by this purchase order are (all quantities are express in TON(s) or fraction(s) of TON:
[{contract.product.totalQty}] of [{contract.product.name}] (product code: [{contract.product.code}]) at the unit price of [{contract.product.unitPrice}]. 

And of course, in case of multiple products (the case for supply chain), from what I read

HamidMoutawakkil avatar Feb 21 '19 20:02 HamidMoutawakkil

E.g. a template parameter that was something like [{product.name}]

This can actually be handled in Cicero 0.20 in two ways:

  • As an Ergo Expression in CiceroMark: {{% product.name %}}
  • As a With block in CiceroMark: {{#with product}}{{name}}{{/with}}

Those are not entirely equivalent since the latter can also be parsed.

I would love feedback from @dselman or @HamidMoutawakkil about whether this is good enough to support their usecase(s).

jeromesimeon avatar Dec 11 '19 20:12 jeromesimeon