Convert date to JSON #317. CR Juan
This commit is contained in:
parent
6de70378c8
commit
d20faedd64
|
@ -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}`;
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue