revolunet / node-sellsy

Node Sellsy API wrapper
https://github.com/revolunet/node-sellsy
MIT License
17 stars 7 forks source link

Create Document with several row in a raw #9

Closed sashaboulouds closed 5 years ago

sashaboulouds commented 5 years ago

Hello Revolunet,

Thanks for your valuable job, I really appreciated it !

Just a (dumb, I'm afraid..) question. How do you create a Document with several rows ?

I tried several data structure, but did not find the proper way. Find below a missed try.

sellsy.customers.get({ ident: customerIdent }).then(customer => {
  const documentData = {
    document: {
      doctype: "invoice",
      thirdid: customer.id,
      notes: customer.email,
      currency: "1",
      displayedDate: new Date().getTime() / 1000,
      subject: "Sujet de la facture",
      tags: "bookeo,stripe"
    },
    row: {
      "3": [{
        row_type: "item1",
        row_name: "titre item1",
        row_unit: "unité", 
        row_unitAmount: 7.6
        row_notes: "notes ligne facture",
        row_taxid: 2937141,
      }, 
      {
        row_type: "item2",
        row_name: "titre item2",
        row_unit: "unité", 
        row_unitAmount: 8.4
        row_notes: "notes ligne facture",
        row_taxid: 293542,
      }]
    }
  };
sashaboulouds commented 5 years ago

Hello Revolunet,

Finally find the proper structure... :

sellsy.customers.get({ ident: customerIdent }).then(customer => {
  const documentData = {
    document: {
      doctype: "invoice",
      thirdid: customer.id,
      notes: customer.email,
      currency: "1",
      displayedDate: new Date().getTime() / 1000,
      subject: "Sujet de la facture",
      tags: "bookeo,stripe"
    },
    row: {
      "1": {
        row_type: "item1",
        row_name: "titre item1",
        row_unit: "unité", 
        row_unitAmount: 7.6
        row_notes: "notes ligne facture",
        row_taxid: 2937141,
      }, 
      "2": {
        row_type: "item2",
        row_name: "titre item2",
        row_unit: "unité", 
        row_unitAmount: 8.4
        row_notes: "notes ligne facture",
        row_taxid: 293542,
      }
    }
  };

Hope it helps