Convert date to JSON #317. CR Juan

This commit is contained in:
Joan Sanchez 2018-05-24 11:21:44 +02:00
parent 6de70378c8
commit d20faedd64
2 changed files with 22 additions and 2 deletions

View File

@ -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}`;
}

View File

@ -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;