Giter VIP home page Giter VIP logo

Comments (10)

jeromesimeon avatar jeromesimeon commented on July 20, 2024 1

I've been reviewing the volume discount template and I think
supporting an arbitrary number of rows would require a couple of
extensions to the current template format.

One extension is the ability to specify a piece of repeating text
(which would correspond to an array in the corresponding
JSON). Another extension needed is the ability to describe alternative
texts.

One possiblity that addresses both requirements is to rely on a simple
kind of regular expressions. Here is a short proposal which suggests
some new markup to do that:

Markup for optional text with corresponding JSON field:

[?{myOptionalField} some text goes here]

Markup for repeated text with corresponding JSON field:

[+{myArrayField} some text that might be repeated one or more times goes here]

Markup for alternative texts:

[some left text goes here \| some right text goes here]

With those new constructs in mind, the decision table from the
volumediscount template could be written as follows:

Volume-Based Card Acceptance Agreement [Abbreviated]

This Agreement is by and between Card, Inc., a New York corporation, and you, the Merchant. By accepting the Card, you agree to be bound by the Agreement. 
Discount means an amount that we charge you for accepting the Card, which amount is: ...

| Annual Dollar Volume      | Discount             |
[+{discountRates}| [ Less than $[{volumeUpTo}] million \| [{volumeAbove}] million to [{volumeUpTo}] \| Greater than [{volumeAbove}] million] | [{rate}]% |]

_______________________					_____________________
 Card, Inc.								Merchant

Now if you parse the corresponding clause text with this template:

Volume-Based Card Acceptance Agreement [Abbreviated]

This Agreement is by and between Card, Inc., a New York corporation, and you, the Merchant. By accepting the Card, you agree to be bound by the Agreement. 
Discount means an amount that we charge you for accepting the Card, which amount is: ...

| Annual Dollar Volume      | Discount             |
| Less than $1 million      | 3.00%                |
| $1 million to $10 million | 2.90%                |
| Greater than $10 million  | 2.80%                |

It should succeed and return with the following JSON:

{
    'discountRates' : [
	{ 'volumeUpTo' : 1,
	  'rate' : 3.00 },
	{ 'volumeUpTo' : 10,
	  'volumeAbove' : 1,
	  'rate' : 2.90 },
	{ 'volumeAbove' : 10,
	  'rate' : 2.80 }
    ]
}

from cicero.

adrianffletcher avatar adrianffletcher commented on July 20, 2024 1

Attached is another example which is a fuel surcharge clause which is rather cumbersome as we have to define new model variables for each element in the table and we require a fixed number of rows in the table.

Screen Shot 2019-05-16 at 11 44 46

fuel-surchargev0.1.2.zip

from cicero.

dselman avatar dselman commented on July 20, 2024

Another good example of this is in the volume discount template, which includes a decision table like construct.

from cicero.

jeromesimeon avatar jeromesimeon commented on July 20, 2024

Note that something along those lines would also address issue #16 and possibly #17.

from cicero.

dselman avatar dselman commented on July 20, 2024

Like it.

from cicero.

dselman avatar dselman commented on July 20, 2024

An example that uses arrays in the model.

latedeliveryandpenalty.zip

from cicero.

dselman avatar dselman commented on July 20, 2024

Code that prevents using Arrays in the template model:
https://github.com/accordproject/cicero/blob/master/packages/cicero-core/src/template.js#L328

from cicero.

dselman avatar dselman commented on July 20, 2024

Current state is that you CAN use arrays in your models - but not the template model itself.

from cicero.

otawakkil avatar otawakkil commented on July 20, 2024

It would be interesting to support any arbitrary sequence of chars as separator in arrays.
For example, in a table like this one:
| DEAL | 16.00 | 15.90 | 15.65 | 14.75 | 13.20 |
' | ' is the delimiter.
And we can even go a step further by supporting Regex to be used as separators.

from cicero.

jeromesimeon avatar jeromesimeon commented on July 20, 2024

We now have support for lists using blocks (tied to Markdown lists), either as: {{#ulist}} ... {{/ulist}} or {{#olist}} ... {{/olist}} in version 0.20. I'm closing. Reopen if you disagree! (Or open a new issue if new feature needed).

from cicero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.