refactor: replace all Date
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6b1a6fe44b
commit
e27a559416
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
|
||||
Self.latest = async filter => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setFullYear(minDate.getFullYear() - 1);
|
||||
|
||||
const where = {dated: {gte: minDate}};
|
||||
|
|
|
@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
|
||||
describe('campaign latest()', () => {
|
||||
it('should return the campaigns from the last year', async() => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
const result = await app.models.Campaign.latest();
|
||||
const randomIndex = Math.floor(Math.random() * result.length);
|
||||
const campaignDated = result[randomIndex].dated;
|
||||
|
@ -12,7 +12,7 @@ describe('campaign latest()', () => {
|
|||
});
|
||||
|
||||
it('should return the campaigns from the current year', async() => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
const currentYear = now.getFullYear();
|
||||
const result = await app.models.Campaign.latest({
|
||||
where: {dated: {like: `%${currentYear}%`}}
|
||||
|
|
|
@ -4,7 +4,7 @@ describe('campaign upcoming()', () => {
|
|||
it('should return the upcoming campaign but from the last year', async() => {
|
||||
const response = await app.models.Campaign.upcoming();
|
||||
const campaignDated = response.dated;
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
|
||||
expect(campaignDated).toEqual(jasmine.any(Date));
|
||||
expect(campaignDated).toBeLessThanOrEqual(now);
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.upcoming = async() => {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setFullYear(minDate.getFullYear() - 1);
|
||||
|
||||
return Self.findOne({
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = Self => {
|
|||
|
||||
if (!this.login) return;
|
||||
|
||||
if (Date.now() > this.login.expires)
|
||||
if (Date.vnNow() > this.login.expires)
|
||||
this.login = await requestToken();
|
||||
|
||||
return this.login;
|
||||
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
|||
userId: requestData.userId,
|
||||
token: requestData.authToken
|
||||
},
|
||||
expires: Date.now() + (1000 * 60 * tokenLifespan)
|
||||
expires: Date.vnNow() + (1000 * 60 * tokenLifespan)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
|||
await models.Chat.create({
|
||||
senderFk: sender.id,
|
||||
recipient: to,
|
||||
dated: new Date(),
|
||||
dated: Date.vnNew(),
|
||||
checkUserStatus: 0,
|
||||
message: message,
|
||||
status: 0,
|
||||
|
|
|
@ -49,7 +49,7 @@ module.exports = Self => {
|
|||
await models.Chat.create({
|
||||
senderFk: sender.id,
|
||||
recipient: `@${recipient.name}`,
|
||||
dated: new Date(),
|
||||
dated: Date.vnNew(),
|
||||
checkUserStatus: 1,
|
||||
message: message,
|
||||
status: 0,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Chat sendCheckingPresence()', () => {
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
today.setHours(6, 0);
|
||||
const chatModel = models.Chat;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
where: {code: 'trash'}
|
||||
}, myOptions);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setMonth(date.getMonth() - 4);
|
||||
|
||||
const dmsToDelete = await models.Dms.find({
|
||||
|
|
|
@ -163,7 +163,7 @@ module.exports = Self => {
|
|||
fields: ['alertLevel']
|
||||
});
|
||||
|
||||
signedTime ? signedTime != undefined : signedTime = new Date();
|
||||
signedTime ? signedTime != undefined : signedTime = Date.vnNew();
|
||||
|
||||
if (alertLevel >= 2) {
|
||||
let dir;
|
||||
|
|
|
@ -127,7 +127,7 @@ module.exports = Self => {
|
|||
const uploadOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'X-File-ModifiedDate': new Date(),
|
||||
'X-File-ModifiedDate': Date.vnNew(),
|
||||
'Cookie': options.headers.headers.Cookie,
|
||||
...data.getHeaders()
|
||||
},
|
||||
|
|
|
@ -230,7 +230,7 @@ module.exports = Self => {
|
|||
UPDATE edi.tableConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [new Date(), baseName], options);
|
||||
`, [Date.vnNew(), baseName], options);
|
||||
}
|
||||
|
||||
console.log(`Updated table ${toTable}\n`);
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
|
||||
if (!config.cleanDays) return;
|
||||
|
||||
const cleanDate = new Date();
|
||||
const cleanDate = Date.vnNew();
|
||||
cleanDate.setDate(cleanDate.getDate() - config.cleanDays);
|
||||
|
||||
await models.NotificationQueue.destroyAll({
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('Notification Clean()', () => {
|
|||
const notification = await models.Notification.findOne({}, options);
|
||||
const notificationConfig = await models.NotificationConfig.findOne({});
|
||||
|
||||
const cleanDate = new Date();
|
||||
const cleanDate = Date.vnNew();
|
||||
cleanDate.setDate(cleanDate.getDate() - (notificationConfig.cleanDays + 1));
|
||||
|
||||
let before;
|
||||
|
|
|
@ -77,7 +77,7 @@ module.exports = Self => {
|
|||
const newImage = await Self.upsertWithWhere(data, {
|
||||
name: fileName,
|
||||
collectionFk: collectionName,
|
||||
updated: (new Date).getTime()
|
||||
updated: Date.vnNow()
|
||||
}, myOptions);
|
||||
|
||||
// Resizes and saves the image
|
||||
|
|
|
@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
describe('buyUltimate()', () => {
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
it(`should create buyUltimate temporal table and update it's values`, async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('buyUltimateFromInterval()', () => {
|
|||
let today;
|
||||
let future;
|
||||
beforeAll(() => {
|
||||
let now = new Date();
|
||||
let now = Date.vnNew();
|
||||
now.setHours(0, 0, 0, 0);
|
||||
today = now;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
describe('ticket ticketCalculateClon()', () => {
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
it('should add the ticket to the order containing the original ticket', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
|
|
@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
describe('ticket ticketCreateWithUser()', () => {
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
it('should confirm the procedure creates the expected ticket', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
|
|
@ -3,9 +3,9 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|||
|
||||
describe('timeBusiness_calculateByUser()', () => {
|
||||
it('should return the expected hours for today', async() => {
|
||||
let start = new Date();
|
||||
let start = Date.vnNew();
|
||||
start.setHours(0, 0, 0, 0);
|
||||
let end = new Date();
|
||||
let end = Date.vnNew();
|
||||
end.setHours(0, 0, 0, 0);
|
||||
|
||||
let stmts = [];
|
||||
|
|
|
@ -3,11 +3,11 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|||
|
||||
describe('timeControl_calculateByUser()', () => {
|
||||
it(`should return today's worked hours`, async() => {
|
||||
let start = new Date();
|
||||
let start = Date.vnNew();
|
||||
start.setHours(0, 0, 0, 0);
|
||||
start.setDate(start.getDate() - 1);
|
||||
|
||||
let end = new Date();
|
||||
let end = Date.vnNew();
|
||||
end.setHours(0, 0, 0, 0);
|
||||
end.setDate(end.getDate() + 1);
|
||||
|
||||
|
@ -17,7 +17,7 @@ describe('timeControl_calculateByUser()', () => {
|
|||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmts.push(`
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.timeControlCalculate,
|
||||
tmp.timeBusinessCalculate
|
||||
`);
|
||||
|
@ -48,14 +48,14 @@ describe('timeControl_calculateByUser()', () => {
|
|||
});
|
||||
|
||||
it(`should return the worked hours between last sunday and monday`, async() => {
|
||||
let lastSunday = new Date();
|
||||
let lastSunday = Date.vnNew();
|
||||
let daysSinceSunday = lastSunday.getDay();
|
||||
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
|
||||
daysSinceSunday = 7;
|
||||
lastSunday.setHours(23, 0, 0, 0);
|
||||
lastSunday.setDate(lastSunday.getDate() - daysSinceSunday);
|
||||
|
||||
let monday = new Date();
|
||||
let monday = Date.vnNew();
|
||||
let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday)
|
||||
monday.setHours(7, 0, 0, 0);
|
||||
monday.setDate(monday.getDate() - daysSinceMonday);
|
||||
|
@ -66,7 +66,7 @@ describe('timeControl_calculateByUser()', () => {
|
|||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmts.push(`
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.timeControlCalculate,
|
||||
tmp.timeBusinessCalculate
|
||||
`);
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('zone zone_getLanded()', () => {
|
|||
let stmts = [];
|
||||
let stmt;
|
||||
stmts.push('START TRANSACTION');
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
|
||||
let params = {
|
||||
|
@ -40,7 +40,7 @@ describe('zone zone_getLanded()', () => {
|
|||
it(`should return data for a shipped tomorrow`, async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
|
|
@ -436,7 +436,7 @@ let actions = {
|
|||
},
|
||||
|
||||
pickDate: async function(selector, date) {
|
||||
date = date || new Date();
|
||||
date = date || Date.vnNew();
|
||||
|
||||
const timeZoneOffset = date.getTimezoneOffset() * 60000;
|
||||
const localDate = (new Date(date.getTime() - timeZoneOffset))
|
||||
|
|
|
@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
|
|||
describe('Client credit insurance path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
let previousMonth = new Date();
|
||||
let previousMonth = Date.vnNew();
|
||||
previousMonth.setMonth(previousMonth.getMonth() - 1);
|
||||
|
||||
beforeAll(async() => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('Worker time control path', () => {
|
|||
const hankPymId = 1107;
|
||||
|
||||
it('should go to the next month, go to current month and go 1 month in the past', async() => {
|
||||
let date = new Date();
|
||||
let date = Date.vnNew();
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let month = date.toLocaleString('default', {month: 'long'});
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe('Worker time control path', () => {
|
|||
|
||||
expect(result).toContain(month);
|
||||
|
||||
date = new Date();
|
||||
date = Date.vnNew();
|
||||
month = date.toLocaleString('default', {month: 'long'});
|
||||
|
||||
await page.click(selectors.workerTimeControl.previousMonthButton);
|
||||
|
@ -39,7 +39,7 @@ describe('Worker time control path', () => {
|
|||
|
||||
expect(result).toContain(month);
|
||||
|
||||
date = new Date();
|
||||
date = Date.vnNew();
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
const timestamp = Math.round(date.getTime() / 1000);
|
||||
month = date.toLocaleString('default', {month: 'long'});
|
||||
|
|
|
@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
|
|||
|
||||
describe('Worker calendar path', () => {
|
||||
const reasonableTimeBetweenClicks = 300;
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
const lastYear = (date.getFullYear() - 1).toString();
|
||||
|
||||
let browser;
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('Item fixed prices path', () => {
|
|||
});
|
||||
|
||||
it('should fill the fixed price data', async() => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
||||
await page.write(selectors.itemFixedPrice.fourthPPU, '1');
|
||||
await page.write(selectors.itemFixedPrice.fourthPPP, '1');
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('Ticket Edit basic data path', () => {
|
|||
|
||||
it(`should split ticket without negatives`, async() => {
|
||||
const newAgency = 'Gotham247';
|
||||
const newDate = new Date();
|
||||
const newDate = Date.vnNew();
|
||||
newDate.setDate(newDate.getDate() - 1);
|
||||
|
||||
await page.accessToSearchResult('14');
|
||||
|
@ -127,7 +127,7 @@ describe('Ticket Edit basic data path', () => {
|
|||
});
|
||||
|
||||
it(`should old ticket have old date and agency`, async() => {
|
||||
const oldDate = new Date();
|
||||
const oldDate = Date.vnNew();
|
||||
const oldAgency = 'Super-Man delivery';
|
||||
|
||||
await page.accessToSearchResult('14');
|
||||
|
|
|
@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
|
|||
describe('Ticket create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
let nextMonth = new Date();
|
||||
let nextMonth = Date.vnNew();
|
||||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
||||
|
||||
beforeAll(async() => {
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('Route basic Data path', () => {
|
|||
});
|
||||
|
||||
it('should edit the route basic data', async() => {
|
||||
const nextMonth = new Date();
|
||||
const nextMonth = Date.vnNew();
|
||||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
||||
|
||||
await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick');
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('InvoiceIn basic data path', () => {
|
|||
});
|
||||
|
||||
it(`should edit the invoiceIn basic data`, async() => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
await page.pickDate(selectors.invoiceInBasicData.issued, now);
|
||||
await page.pickDate(selectors.invoiceInBasicData.operated, now);
|
||||
await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura');
|
||||
|
|
|
@ -100,7 +100,7 @@ describe('InvoiceOut descriptor path', () => {
|
|||
});
|
||||
|
||||
it(`should check the invoiceOut booked in the summary data`, async() => {
|
||||
let today = new Date();
|
||||
let today = Date.vnNew();
|
||||
|
||||
let day = today.getDate();
|
||||
if (day < 10) day = `0${day}`;
|
||||
|
|
|
@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
|
|||
describe('Travel create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
const day = 15;
|
||||
date.setDate(day);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('Travel basic data path', () => {
|
|||
});
|
||||
|
||||
it('should set a wrong delivery date then receive an error on submit', async() => {
|
||||
const lastMonth = new Date();
|
||||
const lastMonth = Date.vnNew();
|
||||
lastMonth.setMonth(lastMonth.getMonth() - 1);
|
||||
|
||||
await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth);
|
||||
|
|
|
@ -123,7 +123,7 @@ describe('Travel descriptor path', () => {
|
|||
});
|
||||
|
||||
it('should update the landed date to a future date to enable cloneWithEntries', async() => {
|
||||
const nextMonth = new Date();
|
||||
const nextMonth = Date.vnNew();
|
||||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
||||
await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth);
|
||||
await page.waitToClick(selectors.travelBasicData.save);
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class Calendar extends FormInput {
|
|||
constructor($element, $scope, vnWeekDays, moment) {
|
||||
super($element, $scope);
|
||||
this.weekDays = vnWeekDays.locales;
|
||||
this.defaultDate = new Date();
|
||||
this.defaultDate = Date.vnNew();
|
||||
this.displayControls = true;
|
||||
this.moment = moment;
|
||||
}
|
||||
|
@ -115,8 +115,8 @@ export default class Calendar extends FormInput {
|
|||
let wday = date.getDay();
|
||||
let month = date.getMonth();
|
||||
|
||||
const currentDay = new Date().getDate();
|
||||
const currentMonth = new Date().getMonth();
|
||||
const currentDay = Date.vnNew().getDate();
|
||||
const currentMonth = Date.vnNew().getMonth();
|
||||
|
||||
let classes = {
|
||||
today: day === currentDay && month === currentMonth,
|
||||
|
|
|
@ -2,7 +2,7 @@ describe('Component vnCalendar', () => {
|
|||
let controller;
|
||||
let $element;
|
||||
|
||||
let date = new Date();
|
||||
let date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setDate(1);
|
||||
|
||||
|
@ -48,7 +48,7 @@ describe('Component vnCalendar', () => {
|
|||
it(`should return the selected element, then emit a 'selection' event`, () => {
|
||||
jest.spyOn(controller, 'emit');
|
||||
|
||||
const day = new Date();
|
||||
const day = Date.vnNew();
|
||||
day.setHours(0, 0, 0, 0);
|
||||
|
||||
const clickEvent = new Event('click');
|
||||
|
|
|
@ -4,7 +4,7 @@ describe('Component vnDatePicker', () => {
|
|||
let $ctrl;
|
||||
|
||||
let today;
|
||||
today = new Date();
|
||||
today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
beforeEach(ngModule('vnCore'));
|
||||
|
|
|
@ -31,7 +31,7 @@ export default class InputTime extends Field {
|
|||
|
||||
date = this.modelDate
|
||||
? new Date(this.modelDate)
|
||||
: new Date();
|
||||
: Date.vnNew();
|
||||
date.setHours(split[0], split[1], 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('Component vnInputTime', () => {
|
|||
|
||||
describe('field() setter', () => {
|
||||
it(`should display the formated the date`, () => {
|
||||
let date = new Date();
|
||||
let date = Date.vnNew();
|
||||
$ctrl.field = date;
|
||||
let displayed = $filter('date')(date, 'HH:mm');
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ export default class UploadPhoto extends Component {
|
|||
timeout: this.canceler.promise,
|
||||
transformRequest: ([file]) => {
|
||||
const formData = new FormData();
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
const timestamp = now.getTime();
|
||||
const fileName = `${file.name}_${timestamp}`;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ module.exports = Self => {
|
|||
}, myOptions);
|
||||
|
||||
const claim = await models.Claim.findOne(filter, myOptions);
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
|
||||
const newRefundTicket = await models.Ticket.create({
|
||||
clientFk: claim.ticket().clientFk,
|
||||
|
@ -172,7 +172,7 @@ module.exports = Self => {
|
|||
|
||||
async function saveObservation(observation, options) {
|
||||
const query = `INSERT INTO vn.ticketObservation (ticketFk, observationTypeFk, description) VALUES(?, ?, ?)
|
||||
ON DUPLICATE KEY
|
||||
ON DUPLICATE KEY
|
||||
UPDATE description = CONCAT(vn.ticketObservation.description, VALUES(description),' ')`;
|
||||
await Self.rawSql(query, [
|
||||
observation.ticketFk,
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
|||
const landedPlusWeek = new Date(ticket.landed);
|
||||
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
|
||||
const hasClaimManagerRole = await models.Account.hasRole(userId, 'claimManager', myOptions);
|
||||
const isClaimable = landedPlusWeek >= new Date();
|
||||
const isClaimable = landedPlusWeek >= Date.vnNew();
|
||||
|
||||
if (ticket.isDeleted)
|
||||
throw new UserError(`You can't create a claim for a removed ticket`);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('regularizeClaim', {
|
||||
description: `Imports lines from claimBeginning to a new ticket
|
||||
description: `Imports lines from claimBeginning to a new ticket
|
||||
with specific shipped, landed dates, agency and company`,
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -135,10 +135,10 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
async function getTicketId(params, options) {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const maxDate = new Date();
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
let ticket = await Self.app.models.Ticket.findOne({
|
||||
|
@ -155,8 +155,8 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
async function createTicket(ctx, options) {
|
||||
ctx.args.shipped = new Date();
|
||||
ctx.args.landed = new Date();
|
||||
ctx.args.shipped = Date.vnNew();
|
||||
ctx.args.landed = Date.vnNew();
|
||||
ctx.args.agencyModeId = null;
|
||||
ctx.args.routeId = null;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ describe('Claim createFromSales()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayMinusEightDays = new Date();
|
||||
const todayMinusEightDays = Date.vnNew();
|
||||
todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8);
|
||||
|
||||
const ticket = await models.Ticket.findById(ticketId, null, options);
|
||||
|
@ -85,7 +85,7 @@ describe('Claim createFromSales()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayMinusEightDays = new Date();
|
||||
const todayMinusEightDays = Date.vnNew();
|
||||
todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8);
|
||||
|
||||
const ticket = await models.Ticket.findById(ticketId, null, options);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Update Claim', () => {
|
||||
const newDate = new Date();
|
||||
const newDate = Date.vnNew();
|
||||
const originalData = {
|
||||
ticketFk: 3,
|
||||
clientFk: 1101,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Update Claim', () => {
|
||||
const newDate = new Date();
|
||||
const newDate = Date.vnNew();
|
||||
const original = {
|
||||
ticketFk: 3,
|
||||
clientFk: 1101,
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
c.id AS clientFk,
|
||||
c.email AS clientEmail,
|
||||
eu.email salesPersonEmail
|
||||
FROM client c
|
||||
FROM client c
|
||||
JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
JOIN ticket t ON t.clientFk = c.id
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
|
@ -61,10 +61,10 @@ module.exports = Self => {
|
|||
SET status = 'printed',
|
||||
printed = ?
|
||||
WHERE id = ?`,
|
||||
[new Date(), queue.id]);
|
||||
[Date.vnNew(), queue.id]);
|
||||
} catch (error) {
|
||||
await Self.rawSql(`
|
||||
UPDATE clientConsumptionQueue
|
||||
UPDATE clientConsumptionQueue
|
||||
SET status = ?
|
||||
WHERE id = ?`,
|
||||
[error.message, queue.id]);
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = function(Self) {
|
|||
Self.createReceipt = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
|
||||
let tx;
|
||||
|
|
|
@ -74,7 +74,7 @@ module.exports = function(Self) {
|
|||
]
|
||||
}, myOptions);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const query = `SELECT vn.clientGetDebt(?, ?) AS debt`;
|
||||
const data = await Self.rawSql(query, [id, date], myOptions);
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const query = `SELECT vn.clientGetDebt(?, ?) AS debt`;
|
||||
const [debt] = await Self.rawSql(query, [clientFk, date], myOptions);
|
||||
|
|
|
@ -32,14 +32,14 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const ticket = await Self.app.models.Ticket.findById(ticketId, null, myOptions);
|
||||
const query = `
|
||||
SELECT
|
||||
SELECT
|
||||
t.id,
|
||||
t.shipped,
|
||||
a.name AS agencyName,
|
||||
a.name AS agencyName,
|
||||
w.name AS warehouseName,
|
||||
ad.nickname AS nickname,
|
||||
ad.city AS city,
|
||||
|
@ -52,7 +52,7 @@ module.exports = Self => {
|
|||
JOIN vn.warehouse w ON t.warehouseFk = w.id
|
||||
JOIN vn.address ad ON t.addressFk = ad.id
|
||||
JOIN vn.province pr ON ad.provinceFk = pr.id
|
||||
WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0
|
||||
WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0
|
||||
AND t.id <> ? AND t.warehouseFk = ?
|
||||
ORDER BY t.shipped
|
||||
LIMIT 10`;
|
||||
|
|
|
@ -125,7 +125,7 @@ module.exports = Self => {
|
|||
async function getRecoveries(recoveryModel, clientId, options) {
|
||||
const filter = {
|
||||
where: {
|
||||
and: [{clientFk: clientId}, {or: [{finished: null}, {finished: {gt: Date.now()}}]}]
|
||||
and: [{clientFk: clientId}, {or: [{finished: null}, {finished: {gt: Date.vnNow()}}]}]
|
||||
},
|
||||
limit: 1
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('Client createWithInsurance', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const data = {clientFk: 1101, started: Date.now(), credit: 999, grade: 255};
|
||||
const data = {clientFk: 1101, started: Date.vnNow(), credit: 999, grade: 255};
|
||||
|
||||
const result = await models.CreditClassification.createWithInsurance(data, options);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = Self => {
|
|||
|
||||
const stmts = [];
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT *
|
||||
|
@ -65,14 +65,14 @@ module.exports = Self => {
|
|||
co.created,
|
||||
co.text observation,
|
||||
uw.id workerFk,
|
||||
uw.name workerName,
|
||||
uw.name workerName,
|
||||
c.creditInsurance,
|
||||
d.defaulterSinced
|
||||
FROM vn.defaulter d
|
||||
JOIN vn.client c ON c.id = d.clientFk
|
||||
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
|
||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||
WHERE
|
||||
d.created = ?
|
||||
AND d.amount > 0
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const query = `
|
||||
SELECT count(*) AS hasActiveRecovery
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = Self => {
|
|||
|
||||
// Disable old mandate
|
||||
if (oldMandate)
|
||||
oldMandate.updateAttribute('finished', new Date());
|
||||
oldMandate.updateAttribute('finished', Date.vnNew());
|
||||
|
||||
// Create a new mandate
|
||||
await models.Mandate.create({
|
||||
|
|
|
@ -68,7 +68,7 @@ class Controller extends Dialog {
|
|||
}
|
||||
this.maxAmount = accountingType && accountingType.maxAmount;
|
||||
|
||||
this.receipt.payed = new Date();
|
||||
this.receipt.payed = Date.vnNew();
|
||||
if (accountingType.daysInFuture)
|
||||
this.receipt.payed.setDate(this.receipt.payed.getDate() + accountingType.daysInFuture);
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
setDefaultFilter() {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2);
|
||||
|
||||
const maxDate = new Date();
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
this.filterParams = {
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('Client', () => {
|
|||
it('should call the window.open function', () => {
|
||||
jest.spyOn(window, 'open').mockReturnThis();
|
||||
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
controller.$.model.userParams = {
|
||||
from: now,
|
||||
to: now
|
||||
|
@ -49,7 +49,7 @@ describe('Client', () => {
|
|||
|
||||
describe('sendEmail()', () => {
|
||||
it('should make a GET query sending the report', () => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
controller.$.model.userParams = {
|
||||
from: now,
|
||||
to: now
|
||||
|
|
|
@ -5,7 +5,7 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.creditClassification = {
|
||||
started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
|
||||
started: this.$filter('date')(Date.vnNew(), 'yyyy-MM-dd HH:mm')
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('Client', () => {
|
|||
|
||||
describe('onSubmit()', () => {
|
||||
it('should perform a POST query', () => {
|
||||
let started = new Date();
|
||||
let started = Date.vnNew();
|
||||
controller.creditClassification = {
|
||||
started: started,
|
||||
credit: 300,
|
||||
|
|
|
@ -52,7 +52,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
returnDialog() {
|
||||
let params = {finished: Date.now()};
|
||||
let params = {finished: Date.vnNow()};
|
||||
this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => {
|
||||
this._getClassifications(this.client.id);
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('Client', () => {
|
|||
|
||||
it(`should return false if finds a classification without due date`, () => {
|
||||
controller.classifications = [
|
||||
{finished: Date.now()},
|
||||
{finished: Date.vnNow()},
|
||||
{finished: null}
|
||||
];
|
||||
|
||||
|
@ -50,8 +50,8 @@ describe('Client', () => {
|
|||
|
||||
it(`should return true if all classifications are defined with due date`, () => {
|
||||
controller.classifications = [
|
||||
{finished: Date.now()},
|
||||
{finished: Date.now()}
|
||||
{finished: Date.vnNow()},
|
||||
{finished: Date.vnNow()}
|
||||
];
|
||||
|
||||
let result = controller.canCreateNew();
|
||||
|
|
|
@ -5,7 +5,7 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.insurance = {
|
||||
created: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss')
|
||||
created: this.$filter('date')(Date.vnNew(), 'yyyy-MM-dd HH:mm:ss')
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export default class Controller extends Section {
|
|||
|
||||
chipColor(date) {
|
||||
const day = 24 * 60 * 60 * 1000;
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const observationShipped = new Date(date);
|
||||
|
|
|
@ -38,14 +38,14 @@ describe('client defaulter', () => {
|
|||
|
||||
describe('chipColor()', () => {
|
||||
it('should return undefined when the date is the present', () => {
|
||||
let today = new Date();
|
||||
let today = Date.vnNew();
|
||||
let result = controller.chipColor(today);
|
||||
|
||||
expect(result).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('should return warning when the date is 10 days in the past', () => {
|
||||
let pastDate = new Date();
|
||||
let pastDate = Date.vnNew();
|
||||
pastDate = pastDate.setDate(pastDate.getDate() - 11);
|
||||
let result = controller.chipColor(pastDate);
|
||||
|
||||
|
@ -53,7 +53,7 @@ describe('client defaulter', () => {
|
|||
});
|
||||
|
||||
it('should return alert when the date is 20 days in the past', () => {
|
||||
let pastDate = new Date();
|
||||
let pastDate = Date.vnNew();
|
||||
pastDate = pastDate.setDate(pastDate.getDate() - 21);
|
||||
let result = controller.chipColor(pastDate);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Controller extends Section {
|
|||
constructor(...args) {
|
||||
super(...args);
|
||||
this.greuge = {
|
||||
shipped: new Date(),
|
||||
shipped: Date.vnNew(),
|
||||
clientFk: this.$params.id
|
||||
};
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('Client notification', () => {
|
|||
|
||||
describe('campaignSelection() setter', () => {
|
||||
it('should set the campaign from and to properties', () => {
|
||||
const dated = new Date();
|
||||
const dated = Date.vnNew();
|
||||
controller.campaignSelection = {
|
||||
dated: dated,
|
||||
scopeDays: 14
|
||||
|
@ -61,8 +61,8 @@ describe('Client notification', () => {
|
|||
|
||||
controller.$.filters = {hide: () => {}};
|
||||
controller.campaign = {
|
||||
from: new Date(),
|
||||
to: new Date()
|
||||
from: Date.vnNew(),
|
||||
to: Date.vnNew()
|
||||
};
|
||||
|
||||
const data = controller.$.model.data;
|
||||
|
|
|
@ -5,7 +5,7 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.recovery = {
|
||||
started: new Date()
|
||||
started: Date.vnNew()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import Section from 'salix/components/section';
|
|||
class Controller extends Section {
|
||||
setFinished(recovery) {
|
||||
if (!recovery.finished) {
|
||||
let params = {finished: Date.now()};
|
||||
let params = {finished: Date.vnNow()};
|
||||
this.$http.patch(`Recoveries/${recovery.id}`, params).then(
|
||||
() => this.$.model.refresh()
|
||||
);
|
||||
|
|
|
@ -100,7 +100,7 @@ class Controller extends Summary {
|
|||
}
|
||||
|
||||
chipColor(date) {
|
||||
const today = new Date();
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const ticketShipped = new Date(date);
|
||||
|
|
|
@ -76,14 +76,14 @@ describe('Client', () => {
|
|||
|
||||
describe('chipColor()', () => {
|
||||
it('should return warning when the date is the present', () => {
|
||||
let today = new Date();
|
||||
let today = Date.vnNew();
|
||||
let result = controller.chipColor(today);
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
|
||||
it('should return success when the date is in the future', () => {
|
||||
let futureDate = new Date();
|
||||
let futureDate = Date.vnNew();
|
||||
futureDate = futureDate.setDate(futureDate.getDate() + 10);
|
||||
let result = controller.chipColor(futureDate);
|
||||
|
||||
|
@ -91,7 +91,7 @@ describe('Client', () => {
|
|||
});
|
||||
|
||||
it('should return undefined when the date is in the past', () => {
|
||||
let pastDate = new Date();
|
||||
let pastDate = Date.vnNew();
|
||||
pastDate = pastDate.setDate(pastDate.getDate() - 10);
|
||||
let result = controller.chipColor(pastDate);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import Section from 'salix/components/section';
|
|||
export default class Controller extends Section {
|
||||
setDefaultDate(hasData) {
|
||||
if (hasData && !this.clientUnpaid.dated)
|
||||
this.clientUnpaid.dated = new Date();
|
||||
this.clientUnpaid.dated = Date.vnNew();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('client unpaid', () => {
|
|||
describe('setDefaultDate()', () => {
|
||||
it(`should not set today date if has dated`, () => {
|
||||
const hasData = true;
|
||||
const yesterday = new Date();
|
||||
const yesterday = Date.vnNew();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
controller.clientUnpaid = {
|
||||
|
|
|
@ -150,10 +150,10 @@ module.exports = Self => {
|
|||
|
||||
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
stmt = new ParameterizedSQL(`
|
||||
SELECT
|
||||
SELECT
|
||||
i.image,
|
||||
i.id AS itemFk,
|
||||
i.size,
|
||||
|
@ -209,7 +209,7 @@ module.exports = Self => {
|
|||
LEFT JOIN itemType t ON t.id = i.typeFk
|
||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
|
||||
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||
, [userConfig.warehouseFk, date]);
|
||||
|
||||
|
|
|
@ -332,10 +332,10 @@ describe('Entry latests buys filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const from = new Date();
|
||||
const from = Date.vnNew();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = new Date();
|
||||
const to = Date.vnNew();
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
const ctx = {
|
||||
|
|
|
@ -146,8 +146,8 @@ describe('InvoiceIn filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const from = new Date();
|
||||
const to = new Date();
|
||||
const from = Date.vnNew();
|
||||
const to = Date.vnNew();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
to.setDate(to.getDate() + 1);
|
||||
|
|
|
@ -78,7 +78,7 @@ describe('InvoiceIn', () => {
|
|||
description: 'This is a description',
|
||||
files: [{
|
||||
lastModified: 1668673957761,
|
||||
lastModifiedDate: new Date(),
|
||||
lastModifiedDate: Date.vnNew(),
|
||||
name: 'file-example.png',
|
||||
size: 19653,
|
||||
type: 'image/png',
|
||||
|
|
|
@ -75,7 +75,7 @@ class Controller extends Descriptor {
|
|||
filter: {
|
||||
where: {
|
||||
invoiceInFk: id,
|
||||
dueDated: {gte: new Date()}
|
||||
dueDated: {gte: Date.vnNew()}
|
||||
}
|
||||
}})
|
||||
.then(res => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import Section from 'salix/components/section';
|
|||
class Controller extends Section {
|
||||
add() {
|
||||
this.$.model.insert({
|
||||
dueDated: new Date(),
|
||||
dueDated: Date.vnNew(),
|
||||
bankFk: this.vnConfig.local.bankFk
|
||||
});
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ module.exports = Self => {
|
|||
try {
|
||||
query = `
|
||||
SELECT MAX(issued) issued
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.time t ON t.dated = io.issued
|
||||
WHERE io.serial = 'A'
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.time t ON t.dated = io.issued
|
||||
WHERE io.serial = 'A'
|
||||
AND t.year = YEAR(?)
|
||||
AND io.companyFk = ?`;
|
||||
const [maxIssued] = await Self.rawSql(query, [
|
||||
|
@ -77,7 +77,7 @@ module.exports = Self => {
|
|||
if (args.invoiceDate < args.maxShipped)
|
||||
args.maxShipped = args.invoiceDate;
|
||||
|
||||
const minShipped = new Date();
|
||||
const minShipped = Date.vnNew();
|
||||
minShipped.setFullYear(minShipped.getFullYear() - 1);
|
||||
minShipped.setMonth(1);
|
||||
minShipped.setDate(1);
|
||||
|
@ -131,11 +131,11 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const query = `SELECT DISTINCT clientFk AS id
|
||||
FROM ticket t
|
||||
FROM ticket t
|
||||
JOIN ticketPackaging tp ON t.id = tp.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped BETWEEN '2017-11-21' AND ?
|
||||
AND t.clientFk >= ?
|
||||
AND t.clientFk >= ?
|
||||
AND (t.clientFk <= ? OR ? IS NULL)
|
||||
AND c.isActive`;
|
||||
return models.InvoiceOut.rawSql(query, [
|
||||
|
@ -149,16 +149,16 @@ module.exports = Self => {
|
|||
async function getInvoiceableClients(ctx, options) {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const minShipped = new Date();
|
||||
const minShipped = Date.vnNew();
|
||||
minShipped.setFullYear(minShipped.getFullYear() - 1);
|
||||
|
||||
const query = `SELECT
|
||||
c.id,
|
||||
SUM(IFNULL
|
||||
(
|
||||
s.quantity *
|
||||
s.quantity *
|
||||
s.price * (100-s.discount)/100,
|
||||
0)
|
||||
0)
|
||||
+ IFNULL(ts.quantity * ts.price,0)
|
||||
) AS sumAmount,
|
||||
c.hasToInvoiceByAddress,
|
||||
|
@ -170,7 +170,7 @@ module.exports = Self => {
|
|||
LEFT JOIN ticketService ts ON ts.ticketFk = t.id
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE ISNULL(t.refFk) AND c.id >= ?
|
||||
WHERE ISNULL(t.refFk) AND c.id >= ?
|
||||
AND (t.clientFk <= ? OR ? IS NULL)
|
||||
AND t.shipped BETWEEN ? AND util.dayEnd(?)
|
||||
AND t.companyFk = ? AND c.hasToInvoice
|
||||
|
|
|
@ -108,14 +108,14 @@ module.exports = Self => {
|
|||
throw new UserError(`This client is not invoiceable`);
|
||||
|
||||
// Can't invoice tickets into future
|
||||
const tomorrow = new Date();
|
||||
const tomorrow = Date.vnNew();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
if (maxShipped >= tomorrow)
|
||||
throw new UserError(`Can't invoice to future`);
|
||||
|
||||
const maxInvoiceDate = await getMaxIssued(args.serial, companyId, myOptions);
|
||||
if (new Date() < maxInvoiceDate)
|
||||
if (Date.vnNew() < maxInvoiceDate)
|
||||
throw new UserError(`Can't invoice to past`);
|
||||
|
||||
if (ticketId) {
|
||||
|
@ -155,7 +155,7 @@ module.exports = Self => {
|
|||
async function isInvoiceable(clientId, options) {
|
||||
const models = Self.app.models;
|
||||
const query = `SELECT (hasToInvoice AND isTaxDataChecked) AS invoiceable
|
||||
FROM client
|
||||
FROM client
|
||||
WHERE id = ?`;
|
||||
const [result] = await models.InvoiceOut.rawSql(query, [clientId], options);
|
||||
|
||||
|
@ -172,12 +172,12 @@ module.exports = Self => {
|
|||
|
||||
async function getMaxIssued(serial, companyId, options) {
|
||||
const models = Self.app.models;
|
||||
const query = `SELECT MAX(issued) AS issued
|
||||
FROM invoiceOut
|
||||
const query = `SELECT MAX(issued) AS issued
|
||||
FROM invoiceOut
|
||||
WHERE serial = ? AND companyFk = ?`;
|
||||
const [maxIssued] = await models.InvoiceOut.rawSql(query,
|
||||
[serial, companyId], options);
|
||||
const maxInvoiceDate = maxIssued && maxIssued.issued || new Date();
|
||||
const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew();
|
||||
|
||||
return maxInvoiceDate;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('InvoiceOut filter()', () => {
|
||||
let today = new Date();
|
||||
let today = Date.vnNew();
|
||||
today.setHours(2, 0, 0, 0);
|
||||
|
||||
it('should return the invoice out matching ref', async() => {
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('InvoiceOut invoiceClient()', () => {
|
|||
const clientId = 1101;
|
||||
const addressId = 121;
|
||||
const companyFk = 442;
|
||||
const minShipped = new Date();
|
||||
const minShipped = Date.vnNew();
|
||||
minShipped.setFullYear(minShipped.getFullYear() - 1);
|
||||
minShipped.setMonth(1);
|
||||
minShipped.setDate(1);
|
||||
|
@ -33,8 +33,8 @@ describe('InvoiceOut invoiceClient()', () => {
|
|||
ctx.args = {
|
||||
clientId: clientId,
|
||||
addressId: addressId,
|
||||
invoiceDate: new Date(),
|
||||
maxShipped: new Date(),
|
||||
invoiceDate: Date.vnNew(),
|
||||
maxShipped: Date.vnNew(),
|
||||
companyFk: companyFk,
|
||||
minShipped: minShipped
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ class Controller extends Dialog {
|
|||
constructor($element, $, $transclude) {
|
||||
super($element, $, $transclude);
|
||||
this.invoice = {
|
||||
maxShipped: new Date()
|
||||
maxShipped: Date.vnNew()
|
||||
};
|
||||
this.clientsNumber = 'allClients';
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ describe('InvoiceOut', () => {
|
|||
jest.spyOn(controller.vnApp, 'showError');
|
||||
|
||||
controller.invoice = {
|
||||
invoiceDate: new Date(),
|
||||
maxShipped: new Date()
|
||||
invoiceDate: Date.vnNew(),
|
||||
maxShipped: Date.vnNew()
|
||||
};
|
||||
|
||||
controller.responseHandler('accept');
|
||||
|
@ -88,14 +88,14 @@ describe('InvoiceOut', () => {
|
|||
it('should make an http POST query and then call to the showSuccess() method', () => {
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
const minShipped = new Date();
|
||||
const minShipped = Date.vnNew();
|
||||
minShipped.setFullYear(minShipped.getFullYear() - 1);
|
||||
minShipped.setMonth(1);
|
||||
minShipped.setDate(1);
|
||||
minShipped.setHours(0, 0, 0, 0);
|
||||
controller.invoice = {
|
||||
invoiceDate: new Date(),
|
||||
maxShipped: new Date(),
|
||||
invoiceDate: Date.vnNew(),
|
||||
maxShipped: Date.vnNew(),
|
||||
fromClientId: 1101,
|
||||
toClientId: 1101,
|
||||
companyFk: 442,
|
||||
|
|
|
@ -8,7 +8,7 @@ class Controller extends Dialog {
|
|||
|
||||
this.isInvoicing = false;
|
||||
this.invoice = {
|
||||
maxShipped: new Date()
|
||||
maxShipped: Date.vnNew()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('upsertFixedPrice()', () => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
const fixedPriceId = 1;
|
||||
let originalFixedPrice;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
for (let image of images) {
|
||||
const currentStamp = new Date().getTime();
|
||||
const currentStamp = Date.vnNew().getTime();
|
||||
const updatedStamp = image.updated.getTime();
|
||||
const graceTime = Math.abs(currentStamp - updatedStamp);
|
||||
const maxTTL = 3600 * 48 * 1000; // 48 hours in ms;
|
||||
|
@ -97,7 +97,7 @@ module.exports = Self => {
|
|||
await row.updateAttributes({
|
||||
error: error,
|
||||
attempts: row.attempts + 1,
|
||||
updated: new Date()
|
||||
updated: Date.vnNew()
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getVisibleAvailable = async(id, warehouseFk, dated = new Date(), options) => {
|
||||
Self.getVisibleAvailable = async(id, warehouseFk, dated = Date.vnNew(), options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const wastes = await Self.rawSql(`
|
||||
SELECT *, 100 * dwindle / total AS percentage
|
||||
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
sum(ws.saleTotal) AS total,
|
||||
sum(ws.saleWaste) AS dwindle
|
||||
FROM bs.waste ws
|
||||
WHERE buyer = ? AND family = ?
|
||||
WHERE buyer = ? AND family = ?
|
||||
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||
GROUP BY buyer, itemFk
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const date = new Date();
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const wastes = await Self.rawSql(`
|
||||
SELECT *, 100 * dwindle / total AS percentage
|
||||
|
|
|
@ -94,8 +94,8 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
async function createTicket(ctx, options) {
|
||||
ctx.args.shipped = new Date();
|
||||
ctx.args.landed = new Date();
|
||||
ctx.args.shipped = Date.vnNew();
|
||||
ctx.args.landed = Date.vnNew();
|
||||
ctx.args.companyId = null;
|
||||
ctx.args.agencyModeId = null;
|
||||
ctx.args.routeId = null;
|
||||
|
@ -106,10 +106,10 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
async function getTicketId(params, options) {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const maxDate = new Date();
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
let ticket = await Self.app.models.Ticket.findOne({
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('item getVisibleAvailable()', () => {
|
|||
try {
|
||||
const itemFk = 1;
|
||||
const warehouseFk = 1;
|
||||
const dated = new Date();
|
||||
const dated = Date.vnNew();
|
||||
|
||||
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
||||
|
||||
|
@ -29,7 +29,7 @@ describe('item getVisibleAvailable()', () => {
|
|||
try {
|
||||
const itemFk = 1;
|
||||
const warehouseFk = 1;
|
||||
const dated = new Date();
|
||||
const dated = Date.vnNew();
|
||||
dated.setDate(dated.getDate() - 1);
|
||||
|
||||
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
describe('item lastEntriesFilter()', () => {
|
||||
it('should return one entry for the given item', async() => {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
const maxDate = new Date();
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
@ -23,11 +23,11 @@ describe('item lastEntriesFilter()', () => {
|
|||
});
|
||||
|
||||
it('should return five entries for the given item', async() => {
|
||||
const minDate = new Date();
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2, 1);
|
||||
|
||||
const maxDate = new Date();
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -80,7 +80,7 @@ class Controller extends Descriptor {
|
|||
}
|
||||
|
||||
onUploadResponse() {
|
||||
const timestamp = new Date().getTime();
|
||||
const timestamp = Date.vnNew().getTime();
|
||||
const src = this.$rootScope.imagePath('catalog', '200x200', this.item.id);
|
||||
const zoomSrc = this.$rootScope.imagePath('catalog', '1600x900', this.item.id);
|
||||
const newSrc = `${src}&t=${timestamp}`;
|
||||
|
|
|
@ -7,7 +7,7 @@ class Controller extends Section {
|
|||
super($element, $scope);
|
||||
this.$anchorScroll = $anchorScroll;
|
||||
this.$location = $location;
|
||||
let today = new Date();
|
||||
let today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
this.today = today.toJSON();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('fixed price', () => {
|
|||
});
|
||||
|
||||
it('should perform an http request to update the price', () => {
|
||||
const now = new Date();
|
||||
const now = Date.vnNew();
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
$httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond();
|
||||
|
|
|
@ -5,11 +5,11 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
const from = new Date();
|
||||
const from = Date.vnNew();
|
||||
from.setDate(from.getDate() - 75);
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = new Date();
|
||||
const to = Date.vnNew();
|
||||
to.setDate(to.getDate() + 10);
|
||||
to.setHours(23, 59, 59, 59);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue