Worker calendar rework #645

Merged
carlosjr merged 15 commits from 2567-calendar_rework into dev 2021-06-14 10:04:45 +00:00
20 changed files with 183 additions and 102 deletions
Showing only changes of commit 1b62233ea7 - Show all commits

View File

@ -474,7 +474,7 @@ export default {
advancedSearchDaysOnward: 'vn-ticket-search-panel vn-input-number[ng-model="filter.scopeDays"]', advancedSearchDaysOnward: 'vn-ticket-search-panel vn-input-number[ng-model="filter.scopeDays"]',
advancedSearchClient: 'vn-ticket-search-panel vn-textfield[ng-model="filter.clientFk"]', advancedSearchClient: 'vn-ticket-search-panel vn-textfield[ng-model="filter.clientFk"]',
advancedSearchButton: 'vn-ticket-search-panel button[type=submit]', advancedSearchButton: 'vn-ticket-search-panel button[type=submit]',
newTicketButton: 'vn-ticket-index a[ui-sref="ticket.create"]', newTicketButton: 'vn-ticket-index vn-button[icon="add"]',
searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
firstTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > vn-check', firstTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > vn-check',
secondTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(2) > vn-td:nth-child(1) > vn-check', secondTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(2) > vn-td:nth-child(1) > vn-check',

View File

@ -26,7 +26,8 @@ describe('Travel create path', () => {
it('should fill the reference, agency and ship date then save the form', async() => { it('should fill the reference, agency and ship date then save the form', async() => {
await page.write(selectors.travelIndex.reference, 'Testing reference'); await page.write(selectors.travelIndex.reference, 'Testing reference');
await page.autocompleteSearch(selectors.travelIndex.agency, 'inhouse pickup'); await page.autocompleteSearch(selectors.travelIndex.agency, 'inhouse pickup');
await page.pickDate(selectors.travelIndex.shipDate, date); await page.pickDate(selectors.travelIndex.shipDate, date); // this line autocompletes another 3 fields
await page.waitForTimeout(1000);
await page.waitToClick(selectors.travelIndex.save); await page.waitToClick(selectors.travelIndex.save);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
@ -35,8 +36,6 @@ describe('Travel create path', () => {
}); });
it('should check the user was redirected to the travel basic data upon creation', async() => { it('should check the user was redirected to the travel basic data upon creation', async() => {
// backup code for further intermitences still on track.
// await page.screenshot({path: 'e2e/paths/10-travel/error.jpeg', type: 'jpeg'});
await page.waitForState('travel.card.basicData'); await page.waitForState('travel.card.basicData');
}); });

View File

@ -93,7 +93,7 @@ module.exports = function(Self) {
clientOriginal.accountingAccount clientOriginal.accountingAccount
], ],
options); options);
} else { } else if (accountingType.isAutoConciliated == true) {
const description = `${clientOriginal.id} : ${clientOriginal.socialName} - ${accountingType.receiptDescription}`; const description = `${clientOriginal.id} : ${clientOriginal.socialName} - ${accountingType.receiptDescription}`;
const [xdiarioNew] = await Self.rawSql( const [xdiarioNew] = await Self.rawSql(
`SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, `SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,

View File

@ -89,7 +89,7 @@ module.exports = Self => {
const newBuy = await models.Buy.create(ctx.args, myOptions); const newBuy = await models.Buy.create(ctx.args, myOptions);
let filter = { const filter = {
fields: [ fields: [
'id', 'id',
'itemFk', 'itemFk',
@ -136,7 +136,7 @@ module.exports = Self => {
} }
}; };
let stmts = []; const stmts = [];
let stmt; let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc'); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');

View File

@ -32,7 +32,7 @@ module.exports = Self => {
} }
try { try {
let promises = []; const promises = [];
for (let buy of ctx.args.buys) { for (let buy of ctx.args.buys) {
const buysToDelete = models.Buy.destroyById(buy.id, myOptions); const buysToDelete = models.Buy.destroyById(buy.id, myOptions);
promises.push(buysToDelete); promises.push(buysToDelete);

View File

@ -30,7 +30,18 @@ module.exports = Self => {
} }
}); });
Self.editLatestBuys = async(field, newValue, lines) => { Self.editLatestBuys = async(field, newValue, lines, options) => {
let tx;
let myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
let modelName; let modelName;
let identifier; let identifier;
@ -60,28 +71,27 @@ module.exports = Self => {
const models = Self.app.models; const models = Self.app.models;
const model = models[modelName]; const model = models[modelName];
let tx = await model.beginTransaction({});
try { try {
let promises = []; let promises = [];
let options = {transaction: tx};
let targets = lines.map(line => { const targets = lines.map(line => {
return line[identifier]; return line[identifier];
}); });
let value = {}; const value = {};
value[field] = newValue; value[field] = newValue;
// intentarlo con updateAll
for (let target of targets) for (let target of targets)
promises.push(model.upsertWithWhere({id: target}, value, options)); promises.push(model.upsertWithWhere({id: target}, value, myOptions));
await Promise.all(promises); const result = await Promise.all(promises, myOptions);
await tx.commit();
} catch (error) { if (tx) await tx.commit();
await tx.rollback();
throw error; return result;
} catch (e) {
if (tx) await tx.rollback();
throw e;
} }
}; };
}; };

View File

@ -13,71 +13,85 @@ module.exports = Self => {
type: 'object', type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'search', arg: 'search',
type: 'string', type: 'string',
description: 'Searchs the entry by id', description: 'Searchs the entry by id',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'id', arg: 'id',
type: 'integer', type: 'integer',
description: 'The entry id', description: 'The entry id',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'created', arg: 'created',
type: 'date', type: 'date',
description: 'The created date to filter', description: 'The created date to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'travelFk', arg: 'travelFk',
type: 'number', type: 'number',
description: 'The travel id to filter', description: 'The travel id to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'companyFk', arg: 'companyFk',
type: 'number', type: 'number',
description: 'The company to filter', description: 'The company to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'isBooked', arg: 'isBooked',
type: 'boolean', type: 'boolean',
description: 'The isBokked filter', description: 'The isBokked filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'isConfirmed', arg: 'isConfirmed',
type: 'boolean', type: 'boolean',
description: 'The isConfirmed filter', description: 'The isConfirmed filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'isOrdered', arg: 'isOrdered',
type: 'boolean', type: 'boolean',
description: 'The isOrdered filter', description: 'The isOrdered filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'ref', arg: 'ref',
type: 'string', type: 'string',
description: 'The ref filter', description: 'The ref filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'supplierFk', arg: 'supplierFk',
type: 'number', type: 'number',
description: 'The supplier id to filter', description: 'The supplier id to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'invoiceInFk', arg: 'invoiceInFk',
type: 'number', type: 'number',
description: 'The invoiceIn id to filter', description: 'The invoiceIn id to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'currencyFk', arg: 'currencyFk',
type: 'number', type: 'number',
description: 'The currency id to filter', description: 'The currency id to filter',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'from', arg: 'from',
type: 'date', type: 'date',
description: `The from date filter` description: `The from date filter`
}, { },
{
arg: 'to', arg: 'to',
type: 'date', type: 'date',
description: `The to date filter` description: `The to date filter`
@ -93,9 +107,14 @@ module.exports = Self => {
} }
}); });
Self.filter = async(ctx, filter) => { Self.filter = async(ctx, filter, options) => {
let conn = Self.dataSource.connector; let myOptions = {};
let where = buildFilter(ctx.args, (param, value) => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const conn = Self.dataSource.connector;
const where = buildFilter(ctx.args, (param, value) => {
switch (param) { switch (param) {
case 'search': case 'search':
return /^\d+$/.test(value) return /^\d+$/.test(value)
@ -128,7 +147,7 @@ module.exports = Self => {
}); });
filter = mergeFilters(ctx.args.filter, {where}); filter = mergeFilters(ctx.args.filter, {where});
let stmts = []; const stmts = [];
let stmt; let stmt;
stmt = new ParameterizedSQL( stmt = new ParameterizedSQL(
`SELECT `SELECT
@ -163,10 +182,10 @@ module.exports = Self => {
); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1; const itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';'); const sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql); const result = await conn.executeStmt(sql, myOptions);
return itemsIndex === 0 ? result : result[itemsIndex]; return itemsIndex === 0 ? result : result[itemsIndex];
}; };
}; };

View File

@ -19,8 +19,14 @@ module.exports = Self => {
} }
}); });
Self.getBuys = async id => { Self.getBuys = async(id, options) => {
let filter = { const models = Self.app.models;
let myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const filter = {
where: {entryFk: id}, where: {entryFk: id},
fields: [ fields: [
'id', 'id',
@ -68,7 +74,6 @@ module.exports = Self => {
} }
}; };
let buys = await Self.app.models.Buy.find(filter); return models.Buy.find(filter, myOptions);
return buys;
}; };
}; };

View File

@ -19,8 +19,14 @@ module.exports = Self => {
} }
}); });
Self.getEntry = async id => { Self.getEntry = async(id, options) => {
let filter = { const models = Self.app.models;
let myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const filter = {
where: {id: id}, where: {id: id},
include: [ include: [
{ {
@ -70,7 +76,6 @@ module.exports = Self => {
], ],
}; };
let entry = await Self.app.models.Entry.findOne(filter); return models.Entry.findOne(filter, myOptions);
return entry;
}; };
}; };

View File

@ -45,8 +45,8 @@ module.exports = Self => {
const conn = Self.dataSource.connector; const conn = Self.dataSource.connector;
const args = ctx.args; const args = ctx.args;
const models = Self.app.models; const models = Self.app.models;
let tx; let tx;
if (!options.transaction) { if (!options.transaction) {
tx = await Self.beginTransaction({}); tx = await Self.beginTransaction({});
options.transaction = tx; options.transaction = tx;
@ -76,7 +76,7 @@ module.exports = Self => {
const createdBuys = await models.Buy.create(buys, options); const createdBuys = await models.Buy.create(buys, options);
const buyIds = createdBuys.map(buy => buy.id); const buyIds = createdBuys.map(buy => buy.id);
let stmts = []; const stmts = [];
let stmt; let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc'); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');

View File

@ -24,14 +24,19 @@ module.exports = Self => {
} }
}); });
Self.importBuysPreview = async(id, buys) => { Self.importBuysPreview = async(id, buys, options) => {
const models = Self.app.models; const models = Self.app.models;
let myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
for (let buy of buys) { for (let buy of buys) {
const packaging = await models.Packaging.findOne({ const packaging = await models.Packaging.findOne({
fields: ['id'], fields: ['id'],
where: {volume: {gte: buy.volume}}, where: {volume: {gte: buy.volume}},
order: 'volume ASC' order: 'volume ASC'
}); }, myOptions);
buy.packageFk = packaging.id; buy.packageFk = packaging.id;
} }

View File

@ -17,36 +17,44 @@ module.exports = Self => {
arg: 'search', arg: 'search',
type: 'String', type: 'String',
description: `If it's and integer searchs by id, otherwise it searchs by name`, description: `If it's and integer searchs by id, otherwise it searchs by name`,
}, { },
{
arg: 'id', arg: 'id',
type: 'Integer', type: 'Integer',
description: 'Item id', description: 'Item id',
}, { },
{
arg: 'tags', arg: 'tags',
type: ['Object'], type: ['Object'],
description: 'List of tags to filter with', description: 'List of tags to filter with',
http: {source: 'query'} http: {source: 'query'}
}, { },
{
arg: 'description', arg: 'description',
type: 'String', type: 'String',
description: 'The item description', description: 'The item description',
}, { },
{
arg: 'salesPersonFk', arg: 'salesPersonFk',
type: 'Integer', type: 'Integer',
description: 'The buyer of the item', description: 'The buyer of the item',
}, { },
{
arg: 'active', arg: 'active',
type: 'Boolean', type: 'Boolean',
description: 'Whether the item is or not active', description: 'Whether the item is or not active',
}, { },
{
arg: 'visible', arg: 'visible',
type: 'Boolean', type: 'Boolean',
description: 'Whether the item is or not visible', description: 'Whether the item is or not visible',
}, { },
{
arg: 'typeFk', arg: 'typeFk',
type: 'Integer', type: 'Integer',
description: 'Type id', description: 'Type id',
}, { },
{
arg: 'categoryFk', arg: 'categoryFk',
type: 'Integer', type: 'Integer',
description: 'Category id', description: 'Category id',
@ -62,9 +70,14 @@ module.exports = Self => {
} }
}); });
Self.latestBuysFilter = async(ctx, filter) => { Self.latestBuysFilter = async(ctx, filter, options) => {
let conn = Self.dataSource.connector; let myOptions = {};
let where = buildFilter(ctx.args, (param, value) => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const conn = Self.dataSource.connector;
const where = buildFilter(ctx.args, (param, value) => {
switch (param) { switch (param) {
case 'search': case 'search':
return /^\d+$/.test(value) return /^\d+$/.test(value)
@ -93,7 +106,7 @@ module.exports = Self => {
}); });
filter = mergeFilters(ctx.args.filter, {where}); filter = mergeFilters(ctx.args.filter, {where});
let stmts = []; const stmts = [];
let stmt; let stmt;
stmts.push('CALL cache.last_buy_refresh(FALSE)'); stmts.push('CALL cache.last_buy_refresh(FALSE)');
@ -179,10 +192,10 @@ module.exports = Self => {
} }
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));
let buysIndex = stmts.push(stmt) - 1; const buysIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';'); const sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql); const result = await conn.executeStmt(sql, myOptions);
return buysIndex === 0 ? result : result[buysIndex]; return buysIndex === 0 ? result : result[buysIndex];
}; };
}; };

View File

@ -3,29 +3,32 @@ const model = app.models.Buy;
describe('Buy editLatestsBuys()', () => { describe('Buy editLatestsBuys()', () => {
it('should change the value of a given column for the selected buys', async() => { it('should change the value of a given column for the selected buys', async() => {
let ctx = { const tx = await app.models.Entry.beginTransaction({});
args: { const options = {transaction: tx};
search: 'Ranged weapon longbow 2m'
}
};
let [original] = await model.latestBuysFilter(ctx); try {
let ctx = {
args: {
search: 'Ranged weapon longbow 2m'
}
};
const field = 'size'; const [original] = await model.latestBuysFilter(ctx, null, options);
let newValue = 99;
const lines = [{itemFk: original.itemFk, id: original.id}];
await model.editLatestBuys(field, newValue, lines); const field = 'size';
const newValue = 99;
const lines = [{itemFk: original.itemFk, id: original.id}];
let [result] = await model.latestBuysFilter(ctx); await model.editLatestBuys(field, newValue, lines, options);
expect(result.size).toEqual(99); const [result] = await model.latestBuysFilter(ctx, null, options);
newValue = original.size; expect(result[field]).toEqual(newValue);
await model.editLatestBuys(field, newValue, lines);
let [restoredFixture] = await model.latestBuysFilter(ctx); await tx.rollback();
} catch (e) {
expect(restoredFixture.size).toEqual(original.size); await tx.rollback();
throw e;
}
}); });
}); });

View File

@ -34,7 +34,7 @@
<vn-thead> <vn-thead>
<vn-tr> <vn-tr>
<vn-th class="icon-field"></vn-th> <vn-th class="icon-field"></vn-th>
<vn-th field="nickname" expand>Client</vn-th> <vn-th field="nickname">Client</vn-th>
<vn-th field="salesPersonFk" class="expendable" shrink>Salesperson</vn-th> <vn-th field="salesPersonFk" class="expendable" shrink>Salesperson</vn-th>
<vn-th field="shipped" shrink-date>Date</vn-th> <vn-th field="shipped" shrink-date>Date</vn-th>
<vn-th>Hour</vn-th> <vn-th>Hour</vn-th>
@ -88,7 +88,7 @@
icon="icon-components"> icon="icon-components">
</vn-icon> </vn-icon>
</vn-td> </vn-td>
<vn-td expand> <vn-td>
<span <span
title="{{::ticket.nickname}}" title="{{::ticket.nickname}}"
vn-click-stop="clientDescriptor.show($event, ticket.clientFk)" vn-click-stop="clientDescriptor.show($event, ticket.clientFk)"
@ -105,7 +105,7 @@
</span> </span>
</vn-td> </vn-td>
<vn-td shrink-date> <vn-td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.shipped)}}"> <span class="chip {{::$ctrl.compareDate(ticket.shipped)}}">
{{::ticket.shipped | date: 'dd/MM/yyyy'}} {{::ticket.shipped | date: 'dd/MM/yyyy'}}
</span> </span>
</vn-td> </vn-td>
@ -122,8 +122,8 @@
</span> </span>
<span <span
ng-show="::!ticket.refFk" ng-show="::!ticket.refFk"
class="chip {{$ctrl.stateColor(ticket)}}"> class="chip {{::$ctrl.stateColor(ticket)}}">
{{ticket.state}} {{::ticket.state}}
</span> </span>
</vn-td> </vn-td>
<vn-td> <vn-td>

View File

@ -12,6 +12,10 @@ vn-monitor-sales-tickets {
padding: 0 padding: 0
} }
vn-th[field="nickname"] {
width: 250px
}
vn-td.icon-field > vn-icon { vn-td.icon-field > vn-icon {
margin-left: 3px; margin-left: 3px;
margin-right: 3px; margin-right: 3px;

View File

@ -101,7 +101,7 @@ class Controller extends Component {
this.$http.get(`Agencies/getAgenciesWithWarehouse`, {params}).then(res => { this.$http.get(`Agencies/getAgenciesWithWarehouse`, {params}).then(res => {
this.agencies = res.data; this.agencies = res.data;
const defaultAgency = this.agencies.find(agency=> { const defaultAgency = this.agencies.find(agency => {
return agency.agencyModeFk == this.defaultAddress.agencyModeFk; return agency.agencyModeFk == this.defaultAddress.agencyModeFk;
}); });
if (defaultAgency) if (defaultAgency)

View File

@ -166,7 +166,7 @@
vn-tooltip="Payment on account..." vn-tooltip="Payment on account..."
tooltip-position="left"> tooltip-position="left">
</vn-button> </vn-button>
<a ui-sref="ticket.create" vn-bind="+"> <a ui-sref="ticket.create($ctrl.clientParams())" vn-bind="+">
<vn-button class="round md vn-mb-sm" <vn-button class="round md vn-mb-sm"
icon="add" icon="add"
vn-tooltip="New ticket" vn-tooltip="New ticket"

View File

@ -151,6 +151,14 @@ export default class Controller extends Section {
return [minHour, maxHour]; return [minHour, maxHour];
} }
clientParams() {
if (this.$params.q) {
const params = JSON.parse(this.$params.q);
if (params.clientFk) return {clientFk: params.clientFk};
}
return {};
}
} }
Controller.$inject = ['$element', '$scope', 'vnReport']; Controller.$inject = ['$element', '$scope', 'vnReport'];

View File

@ -34,35 +34,45 @@ module.exports = Self => {
}); });
Self.getWorkedHours = async(id, started, ended) => { Self.getWorkedHours = async(id, started, ended) => {
const models = Self.app.models;
const conn = Self.dataSource.connector; const conn = Self.dataSource.connector;
const worker = await models.Worker.findById(id);
const userId = worker.userFk;
const stmts = []; const stmts = [];
const startedMinusOne = new Date(started); const startedMinusOne = new Date(started);
startedMinusOne.setDate(started.getDate() - 1);
const endedPlusOne = new Date(ended); const endedPlusOne = new Date(ended);
let worker = await Self.app.models.Worker.findById(id); endedPlusOne.setDate(ended.getDate() + 1);
let userId = worker.userFk;
stmts.push(` stmts.push(`
DROP TEMPORARY TABLE IF EXISTS DROP TEMPORARY TABLE IF EXISTS
tmp.timeControlCalculate, tmp.timeControlCalculate,
tmp.timeBusinessCalculate tmp.timeBusinessCalculate
`); `);
startedMinusOne.setDate(started.getDate() - 1);
endedPlusOne.setDate(ended.getDate() + 1);
stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne]));
stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne]));
let resultIndex = stmts.push(new ParameterizedSQL(`
const resultIndex = stmts.push(new ParameterizedSQL(`
SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours
FROM tmp.timeBusinessCalculate tbc FROM tmp.timeBusinessCalculate tbc
LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated
WHERE tbc.dated BETWEEN ? AND ? WHERE tbc.dated BETWEEN ? AND ?
`, [started, ended])) - 1; `, [started, ended])) - 1;
stmts.push(` stmts.push(`
DROP TEMPORARY TABLE IF EXISTS DROP TEMPORARY TABLE IF EXISTS
tmp.timeControlCalculate, tmp.timeControlCalculate,
tmp.timeBusinessCalculate tmp.timeBusinessCalculate
`); `);
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql); const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql);
return result[resultIndex]; return result[resultIndex];
}; };

View File

@ -3,6 +3,6 @@ FROM (
SELECT @lastWeek := DATE_ADD(CURDATE(), INTERVAL -1 WEEK), SELECT @lastWeek := DATE_ADD(CURDATE(), INTERVAL -1 WEEK),
@lastWeekMonday := DATE_ADD(@lastWeek, INTERVAL (-WEEKDAY(@lastWeek)) DAY), @lastWeekMonday := DATE_ADD(@lastWeek, INTERVAL (-WEEKDAY(@lastWeek)) DAY),
@lastWeekFriday := DATE_ADD(@lastWeekMonday, INTERVAL (+6) DAY), @lastWeekFriday := DATE_ADD(@lastWeekMonday, INTERVAL (+6) DAY),
@lastWeekMondayTime := ADDTIME(DATE(@lastWeekMonday), '00:00:00'), @lastWeekMondayTime := CONCAT(@lastWeekMonday, ' 00:00:00'),
@lastWeekFridayTime := ADDTIME(DATE(@lastWeekFriday), '23:59:59') @lastWeekFridayTime := CONCAT(@lastWeekFriday, ' 23:59:59')
) t ) t