shippify-data-parsers
Advanced tools
Comparing version
11
index.js
@@ -7,2 +7,3 @@ const fs = require('fs'); | ||
const xls = require('xls-to-json'); | ||
const moment = require('moment-timezone'); | ||
@@ -61,3 +62,6 @@ /* | ||
//The template is configurated by each company. It use the JSONPath Syntax. | ||
const documentProcessed = tots.transform(template.template)(jsonObject); | ||
const customFns = { | ||
functions: { pickupDateFn } | ||
} | ||
const documentProcessed = tots.transform(template.template, customFns)(jsonObject); | ||
console.log('DELIVERIES PROCESSED : ',JSON.stringify(documentProcessed, null, 2)); | ||
@@ -74,4 +78,9 @@ return cb(null, documentProcessed); | ||
/* Helper methods */ | ||
const pickupDateFn = (zone, city, days, hour) => { | ||
return moment.tz(`${zone}/${city}`).add(days, 'days').hour(hour).minute(0).second(0).millisecond(0).valueOf(); | ||
} | ||
module.exports = parser; | ||
{ | ||
"name": "shippify-data-parsers", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "An library to extract information from integration files to create deliveries, the files can be *.xml, *.csv, *.xls, *.edi ", | ||
@@ -36,2 +36,3 @@ "main": "index.js", | ||
"moment": "2.22.2", | ||
"moment-timezone": "^0.5.23", | ||
"schema-inspector": "1.6.8", | ||
@@ -38,0 +39,0 @@ "xls-to-json": "0.5.1", |
@@ -14,3 +14,4 @@ { | ||
"address": "{{$.nfeProc.NFe.infNFe.transp.transporta.xEnder._text}}, {{$.nfeProc.NFe.infNFe.transp.transporta.xMun._text}}, {{$.nfeProc.NFe.infNFe.transp.transporta.UF._text}}" | ||
} | ||
}, | ||
"date": "{{referenceId} | pickupDateFn:America:Sao_Paulo:1:6:__}" | ||
}, | ||
@@ -17,0 +18,0 @@ "dropoff": { |
49426
0.92%10
11.11%975
0.93%8
14.29%+ Added
+ Added
+ Added