diff --git a/client/core/src/lib/date.js b/client/core/src/lib/date.js new file mode 100644 index 000000000..ad3d1d308 --- /dev/null +++ b/client/core/src/lib/date.js @@ -0,0 +1,19 @@ +/** + * Transforms a UTC date to JSON date without datetime. + * + * @param {date} date Date to format + * @return {String} Formatted date string + */ +export function toJsonDate(date) { + let day = date.getDate(); + let month = date.getMonth() + 1; + let year = date.getFullYear(); + + if (day < 10) + day = `0${day}` + + if (month < 10) + month = `0${month}` + + return `${year}-${month}-${day}`; +} \ No newline at end of file diff --git a/client/ticket/src/data/step-one/step-one.js b/client/ticket/src/data/step-one/step-one.js index fdfacaed6..56bd74db6 100644 --- a/client/ticket/src/data/step-one/step-one.js +++ b/client/ticket/src/data/step-one/step-one.js @@ -1,4 +1,5 @@ import ngModule from '../../module'; +import {toJsonDate} from 'core/src/lib/date'; class Controller { constructor($scope, $http, $translate, vnApp) { @@ -30,11 +31,11 @@ class Controller { let query = `/ticket/api/sales/${this.ticket.id}/priceDifference`; let data = { - landed: this.ticket.landed, + landed: toJsonDate(this.ticket.landed), addressFk: this.ticket.addressFk, agencyModeFk: this.ticket.agencyModeFk }; - + return this.$http.post(query, data).then(res => { if (res.data) this.ticket.sale = res.data;