From 6de2dc7bf3ed213d12da3bda0fcbf4c8c9888ce5 Mon Sep 17 00:00:00 2001 From: Yureka Date: Wed, 18 Aug 2021 05:31:50 +0200 Subject: [PATCH] fix db price parsing --- p/db/index.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/p/db/index.js b/p/db/index.js index 59d8b2d6..43459f4c 100644 --- a/p/db/index.js +++ b/p/db/index.js @@ -186,14 +186,26 @@ const parseJourneyWithPrice = ({parsed}, raw) => { parsed.price = null // todo: find cheapest, find discounts // todo: write a parser like vbb-parse-ticket - // [ { - // prc: 15000, - // isFromPrice: true, - // isBookable: true, - // isUpsell: false, - // targetCtx: 'D', - // buttonText: 'To offer selection' - // } ] + // { + // "statusCode": "OK", + // "fareSetL": [ + // { + // "fareL": [ + // { + // "isFromPrice": true, + // "isPartPrice": false, + // "isBookable": true, + // "isUpsell": false, + // "targetCtx": "D", + // "buttonText": "To offer selection", + // "price": { + // "amount": 11400 + // } + // } + // ] + // } + // ] + // } if ( raw.trfRes && Array.isArray(raw.trfRes.fareSetL) && @@ -202,9 +214,9 @@ const parseJourneyWithPrice = ({parsed}, raw) => { raw.trfRes.fareSetL[0].fareL[0] ) { const tariff = raw.trfRes.fareSetL[0].fareL[0] - if (tariff.prc >= 0) { // wat + if (tariff.price && tariff.price.amount >= 0) { // wat parsed.price = { - amount: tariff.prc / 100, + amount: tariff.price.amount / 100, currency: 'EUR', hint: null }