Skip to content
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

generateText does not handle nested clauses #390

Closed
jeromesimeon opened this issue Jul 12, 2019 · 2 comments
Closed

generateText does not handle nested clauses #390

jeromesimeon opened this issue Jul 12, 2019 · 2 comments
Assignees
Labels
Type: Bug 🐛 Something isn't working

Comments

@jeromesimeon
Copy link
Member

jeromesimeon commented Jul 12, 2019

Describe the bug

Generate Text method in Cicero core does not support {[#clause}] ... [{/clause}] markup.

To Reproduce
Steps to reproduce the behavior:

For instance on the following template: https://templates.accordproject.org/car-rental-tr@0.8.1.html


```bash-3.2$ cicero --version
0.13.2
bash-3.2$ cicero parse --out data.json 
13:27:27 - info: Using current directory as template folder
13:27:27 - info: Loading a default sample.txt file.
13:27:29 - info: Creating file: data.json
13:27:29 - info:
{
  "$class": "org.accordtr.carrental.CarRentalContract",
  "contractId": "34a959d2-f915-4c32-a224-c65e8da40e0e",
  "lessorName": "Acme Car Rental",
  "lessorAddress": "Dikmen Caddesi No:48/15 Dikmen Ankara",
  "lessorPhone": "+901231231234",
  "lesseeName": "Can Doğan",
  "lesseeAddress": "John F. Kennedy Sokak No:23/12 Kavaklıdere Ankara",
  "lesseePhone": "+901234567890",
  "authorizedCourt": "Ankara",
  "plateID": "06 MX 7817",
  "carBrand": "Volkswagen",
  "model": "Golf 1.6 TDI Comfortline",
  "modelYear": "2017",
  "color": "Kırmızı",
  "vechileID": "WVWZZZ3CZXW000001",
  "startDate": "13.07.2018",
  "endDate": "17.07.2018",
  "deliveryStation": "Acme Car Rental Merkez Ofis",
  "paymentClause": {
    "$class": "org.accordtr.carrental.PaymentClause",
    "clauseId": "736f15a4-312b-4b26-947f-8790c3849691",
    "amountText": "İki Yüz On Yedi Amerikan Doları",
    "amount": {
      "$class": "org.accordproject.money.MonetaryAmount",
      "doubleValue": 217.99,
      "currencyCode": "USD"
    },
    "paymentProcedure": "bank transfer"
  }
}
bash-3.2$ cicero generateText --data data.json 
13:33:21 - info: Using current directory as template folder
13:33:23 - error: Unrecognized item: ClauseBinding

Expected behavior

generateText should generate the text for the contract from the data.json instance.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser N/A
  • Version 0.13 (but must be affecting all versions)
@jeromesimeon jeromesimeon added the Type: Bug 🐛 Something isn't working label Jul 12, 2019
@jeromesimeon jeromesimeon self-assigned this Jul 12, 2019
jeromesimeon added a commit to jeromesimeon/cicero that referenced this issue Jul 12, 2019
@jeromesimeon
Copy link
Member Author

Tested with PR #391:

bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse --out data.json 
14:39:04 - info: Using current directory as template folder
14:39:04 - info: Loading a default sample.txt file.
14:39:06 - info: Creating file: data.json
14:39:06 - info:
{
  "$class": "org.accordtr.carrental.CarRentalContract",
  "contractId": "c256f035-d2b5-4846-b2c2-dd15e25aa638",
  "lessorName": "Acme Car Rental",
  "lessorAddress": "Dikmen Caddesi No:48/15 Dikmen Ankara",
  "lessorPhone": "+901231231234",
  "lesseeName": "Can Doğan",
  "lesseeAddress": "John F. Kennedy Sokak No:23/12 Kavaklıdere Ankara",
  "lesseePhone": "+901234567890",
  "authorizedCourt": "Ankara",
  "plateID": "06 MX 7817",
  "carBrand": "Volkswagen",
  "model": "Golf 1.6 TDI Comfortline",
  "modelYear": "2017",
  "color": "Kırmızı",
  "vechileID": "WVWZZZ3CZXW000001",
  "startDate": "13.07.2018",
  "endDate": "17.07.2018",
  "deliveryStation": "Acme Car Rental Merkez Ofis",
  "paymentClause": {
    "$class": "org.accordtr.carrental.PaymentClause",
    "clauseId": "9f37fdb7-33b1-4c68-ba7e-7ac4bc744405",
    "amountText": "İki Yüz On Yedi Amerikan Doları",
    "amount": {
      "$class": "org.accordproject.money.MonetaryAmount",
      "doubleValue": 217.99,
      "currencyCode": "USD"
    },
    "paymentProcedure": "bank transfer"
  }
}
bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js generateText --out sample2.txt 
14:39:11 - info: Using current directory as template folder
14:39:11 - info: Loading a default data.json file.
14:39:13 - info: Creating file: sample2.txt
14:39:13 - info:
"OTO KİRALAMA SÖZLEŞMESİ
1. TARAFLAR

    1.1 Kiraya Veren Şirket, Şahıs, Kurum "Acme Car Rental"
    1.2 Adresi "Dikmen Caddesi No:48/15 Dikmen Ankara"
    1.3 Telefon "+901231231234"

Bundan böyle KİRAYA VEREN olarak anılacaktır.

    1.4 Kiralayanın Adı Soyadı "Can Doğan"
    1.5 Adresi "John F. Kennedy Sokak No:23/12 Kavaklıdere Ankara"
    1.6 Telefon "+901234567890"

Bundan böyle KİRALAYAN olarak anılacaktır.

2. ARAÇ DETAYLARI

    2.1 Plaka No "06 MX 7817"
    2.2 Marka "Volkswagen"
    2.3 Model "Golf 1.6 TDI Comfortline"
    2.4 Trafiğe Çıkış Yılı "2017"
    2.5 Renk "Kırmızı"
    2.6 Şase No "WVWZZZ3CZXW000001"

3. KİRALAMA DETAYLARI

    3.1 "İki Yüz On Yedi Amerikan Doları" (217.99 USD) "bank transfer".
    3.2 Kiralama Başlangıç Tarihi "13.07.2018"
    3.3 Kiralama Bitiş Tarihi "17.07.2018"
    3.4 Teslimat Noktası "Acme Car Rental Merkez Ofis"

1. SÖZLEŞMENİN KONUSU "06 MX 7817" Plaka numaralı "Volkswagen" marka otomobilin KİRALAYAN'a kiraya verilmesi.

2. SÖZLEŞMENİN İÇERİĞİ : Bu sözleşme tarafların taahhütlerine ve aracın kiralanması şartlarını kapsar.

3. TAAHHÜTNAME : Sözleşmenin akidi olarak hareket eden KİRAYA VEREN ve KİRALAYAN aşağıda belirtiliği üzere yükümlülüklerini karşılıklı birbirlerine taahhüt edip kabul ile imzalamışlardır.

4. SÖZLEŞME ŞARTLARI :

    a) KİRAYA VEREN, aracı tüm fonksiyonları çalışır vaziyette KİRALAYAN'a teslim etmiştir. 
    b) Sözleşme tarihinden itibaren araçta meydana gelebilecek her türlü arıza, bakım, onarım ve yakıt giderleri KİRALAYAN'a aittir. Hiç bir surette giderlerle ilgili olarak KİRAYA VEREN'den ücret talebinde bulunulmayacaktır. KİRALAYAN aracın en iyi şekilde korunması için gereken önlemleri alacak ve her türlü bakımını süresi içerisinde yaptıracaktır.

İş bu sözleşmeden doğacak herhangi bir anlaşmazlık durumunda "Ankara" mahkemelerinin yetkili olduğunu taraflar kabul etmişlerdir."
bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse --sample sample2.txt 
14:39:25 - info: Using current directory as template folder
14:39:27 - info:
{
  "$class": "org.accordtr.carrental.CarRentalContract",
  "contractId": "4897578e-b612-4366-a2c3-fc7e6accab54",
  "lessorName": "Acme Car Rental",
  "lessorAddress": "Dikmen Caddesi No:48/15 Dikmen Ankara",
  "lessorPhone": "+901231231234",
  "lesseeName": "Can Doğan",
  "lesseeAddress": "John F. Kennedy Sokak No:23/12 Kavaklıdere Ankara",
  "lesseePhone": "+901234567890",
  "authorizedCourt": "Ankara",
  "plateID": "06 MX 7817",
  "carBrand": "Volkswagen",
  "model": "Golf 1.6 TDI Comfortline",
  "modelYear": "2017",
  "color": "Kırmızı",
  "vechileID": "WVWZZZ3CZXW000001",
  "startDate": "13.07.2018",
  "endDate": "17.07.2018",
  "deliveryStation": "Acme Car Rental Merkez Ofis",
  "paymentClause": {
    "$class": "org.accordtr.carrental.PaymentClause",
    "clauseId": "cbb73cb7-b4d1-415c-92f1-e83993c9b4ea",
    "amountText": "İki Yüz On Yedi Amerikan Doları",
    "amount": {
      "$class": "org.accordproject.money.MonetaryAmount",
      "doubleValue": 217.99,
      "currencyCode": "USD"
    },
    "paymentProcedure": "bank transfer"
  }
}
bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse --sample sample2.txt --out data2.json
14:39:35 - info: Using current directory as template folder
14:39:38 - info: Creating file: data2.json
14:39:38 - info:
{
  "$class": "org.accordtr.carrental.CarRentalContract",
  "contractId": "15b8ab32-3ec9-4798-b020-98fea3e70154",
  "lessorName": "Acme Car Rental",
  "lessorAddress": "Dikmen Caddesi No:48/15 Dikmen Ankara",
  "lessorPhone": "+901231231234",
  "lesseeName": "Can Doğan",
  "lesseeAddress": "John F. Kennedy Sokak No:23/12 Kavaklıdere Ankara",
  "lesseePhone": "+901234567890",
  "authorizedCourt": "Ankara",
  "plateID": "06 MX 7817",
  "carBrand": "Volkswagen",
  "model": "Golf 1.6 TDI Comfortline",
  "modelYear": "2017",
  "color": "Kırmızı",
  "vechileID": "WVWZZZ3CZXW000001",
  "startDate": "13.07.2018",
  "endDate": "17.07.2018",
  "deliveryStation": "Acme Car Rental Merkez Ofis",
  "paymentClause": {
    "$class": "org.accordtr.carrental.PaymentClause",
    "clauseId": "afe56192-1e4c-4c30-a9bd-c83ea8b2d205",
    "amountText": "İki Yüz On Yedi Amerikan Doları",
    "amount": {
      "$class": "org.accordproject.money.MonetaryAmount",
      "doubleValue": 217.99,
      "currencyCode": "USD"
    },
    "paymentProcedure": "bank transfer"
  }
}
bash-3.2$ diff data.json data2.json 
3c3
<   "contractId": "c256f035-d2b5-4846-b2c2-dd15e25aa638",
---
>   "contractId": "15b8ab32-3ec9-4798-b020-98fea3e70154",
22c22
<     "clauseId": "9f37fdb7-33b1-4c68-ba7e-7ac4bc744405",
---
>     "clauseId": "afe56192-1e4c-4c30-a9bd-c83ea8b2d205",

jeromesimeon added a commit that referenced this issue Jul 12, 2019
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
@jeromesimeon
Copy link
Member Author

Fixed in PR #391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant