Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Joan Sanchez 2022-05-24 14:54:06 +02:00
commit f9b9dfaf4b
16 changed files with 147 additions and 79 deletions

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethodCtx('setSaleQuantity', {
Self.remoteMethod('setSaleQuantity', {
description: 'Update sale quantity',
accessType: 'WRITE',
accepts: [{
@ -24,11 +24,13 @@ module.exports = Self => {
}
});
Self.setSaleQuantity = async ctx => {
const args = ctx.args;
Self.setSaleQuantity = async(saleId, quantity) => {
const models = Self.app.models;
const sale = await models.Sale.findById(args.saleId);
return await sale.updateAttribute('quantity', args.quantity);
const sale = await models.Sale.findById(saleId);
return await sale.updateAttributes({
originalQuantity: sale.quantity,
quantity: quantity
});
};
};

View File

@ -5,19 +5,12 @@ describe('setSaleQuantity()', () => {
const saleId = 30;
const newQuantity = 10;
const ctx = {
args: {
saleId: saleId,
quantity: newQuantity
}
};
const originalSale = await models.Sale.findById(saleId);
await models.Collection.setSaleQuantity(ctx);
await models.Collection.setSaleQuantity(saleId, newQuantity);
const updateSale = await models.Sale.findById(saleId);
expect(updateSale.quantity).toBeLessThan(originalSale.quantity);
expect(updateSale.originalQuantity).toEqual(originalSale.quantity);
expect(updateSale.quantity).toEqual(newQuantity);
});
});

View File

@ -1633,51 +1633,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`)
VALUES
(1, NULL),
(2, NULL),
(3, NULL),
(4, NULL),
(5, NULL),
(6, NULL),
(7, NULL),
(8, NULL),
(9, NULL);
(1, NULL),
(2, NULL),
(3, NULL),
(4, NULL),
(5, NULL),
(6, NULL),
(7, NULL),
(8, NULL),
(9, NULL),
(10, NULL),
(11, NULL);
INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`)
VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(8, 8),
(9, 9);
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(8, 8),
(9, 9),
(10, 10),
(11, 11);
INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`)
VALUES
(1, 1, CURDATE()),
(2, 2, CURDATE()),
(3, 3, CURDATE()),
(4, 4, CURDATE()),
(5, 5, CURDATE()),
(6, 6, CURDATE()),
(7, 7, CURDATE()),
(8, 8, CURDATE()),
(9, 9, CURDATE());
(1, 1, CURDATE()),
(2, 2, CURDATE()),
(3, 3, CURDATE()),
(4, 4, CURDATE()),
(5, 5, CURDATE()),
(6, 6, CURDATE()),
(7, 7, CURDATE()),
(8, 8, CURDATE()),
(9, 9, CURDATE()),
(10, 10, CURDATE()),
(11, 11, CURDATE());
INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`)
VALUES
(1, 1, 1101, CURDATE()),
(2, 2, 1101, CURDATE()),
(3, 3, 1101, CURDATE()),
(4, 4, 1102, CURDATE()),
(5, 5, 1102, CURDATE()),
(6, 6, 1102, CURDATE()),
(7, 7, 1103, CURDATE()),
(8, 8, 1103, CURDATE()),
(9, 9, 1103, CURDATE());
(1, 1, 1101, CURDATE()),
(2, 2, 1101, CURDATE()),
(3, 3, 1101, CURDATE()),
(4, 4, 1102, CURDATE()),
(5, 5, 1102, CURDATE()),
(6, 6, 1102, CURDATE()),
(7, 7, 1103, CURDATE()),
(8, 8, 1103, CURDATE()),
(9, 9, 1103, CURDATE()),
(10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)),
(11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY));
INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`)
VALUES

View File

@ -146,16 +146,17 @@ export default class MultiCheck extends FormInput {
if (!this.model || !this.model.data) return;
const data = this.model.data;
const modelParams = this.model.userParams;
const params = {
filter: {
modelParams: modelParams,
limit: null
}
};
if (this.model.userFilter)
Object.assign(params.filter, this.model.userFilter);
if (this.model.userParams)
Object.assign(params, this.model.userParams);
this.rows = data.length;
this.$http.get(this.model.url, {params})
.then(res => {
this.allRowsCount = res.data.length;

View File

@ -46,11 +46,13 @@
</div>
</vn-horizontal>
<div id="table"></div>
<vn-pagination
ng-if="$ctrl.model"
model="$ctrl.model"
class="vn-pt-md">
</vn-pagination>
<div ng-transclude="pagination">
<vn-pagination
ng-if="$ctrl.model"
model="$ctrl.model"
class="vn-pt-md">
</vn-pagination>
</div>
</div>
<vn-confirm

View File

@ -497,7 +497,8 @@ ngModule.vnComponent('smartTable', {
controller: SmartTable,
transclude: {
table: '?slotTable',
actions: '?slotActions'
actions: '?slotActions',
pagination: '?slotPagination'
},
bindings: {
model: '<?',

View File

@ -98,9 +98,6 @@ module.exports = Self => {
Self.latestBuysFilter = async(ctx, filter, options) => {
const myOptions = {};
if (filter && filter.modelParams)
ctx.args = filter.modelParams;
if (typeof options == 'object')
Object.assign(myOptions, options);

View File

@ -148,12 +148,12 @@
</td>
<td number>
<vn-chip class="transparent" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}">
<span translate>{{::buy.packing | dashIfEmpty}}</span>
<span>{{::buy.packing | dashIfEmpty}}</span>
</vn-chip>
</td>
<td number>
<vn-chip class="transparent" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}">
<span translate>{{::buy.grouping | dashIfEmpty}}</span>
<span>{{::buy.grouping | dashIfEmpty}}</span>
</vn-chip>
</td>
<td number>{{::buy.quantity}}</td>

View File

@ -159,8 +159,22 @@ export default class Controller extends Section {
lines: rowsToEdit
};
if (this.checkedDummyCount && this.checkedDummyCount > 0)
data.filter = this.$.model.userParams;
if (this.checkedDummyCount && this.checkedDummyCount > 0) {
const params = {};
if (this.$.model.userParams) {
const userParams = this.$.model.userParams;
for (let param in userParams) {
let newParam = this.exprBuilder(param, userParams[param]);
if (!newParam)
newParam = {[param]: userParams[param]};
Object.assign(params, newParam);
}
}
if (this.$.model.userFilter)
Object.assign(params, this.$.model.userFilter.where);
data.filter = params;
}
return this.$http.post('Buys/editLatestBuys', data)
.then(() => {

View File

@ -43,11 +43,9 @@ module.exports = Self => {
TIME(v.stamp) AS hour,
DATE(v.stamp) AS dated,
wtc.workerFk
FROM hedera.userSession s
JOIN hedera.visitUser v ON v.id = s.userVisitFk
FROM hedera.visitUser v
JOIN client c ON c.id = v.userFk
LEFT JOIN account.user u ON c.salesPersonFk = u.id
LEFT JOIN worker w ON c.salesPersonFk = w.id
JOIN account.user u ON c.salesPersonFk = u.id
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
AND CURDATE() BETWEEN sc.started AND sc.ended
LEFT JOIN workerTeamCollegues wtc
@ -58,7 +56,9 @@ module.exports = Self => {
const where = filter.where;
where['wtc.workerFk'] = userId;
stmt.merge(conn.makeSuffix(filter));
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(`GROUP BY clientFk, v.stamp`);
stmt.merge(conn.makePagination(filter));
return conn.executeStmt(stmt, myOptions);
};

View File

@ -6,12 +6,49 @@ describe('SalesMonitor clientsFilter()', () => {
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
const filter = {order: 'dated DESC'};
const from = new Date();
const to = new Date();
from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 59);
const filter = {
where: {
'v.stamp': {between: [from, to]}
}
};
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
expect(result.length).toEqual(9);
expect(result.length).toEqual(3);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the clients web activity filtered', async() => {
const tx = await models.SalesMonitor.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const today = new Date();
yesterday.setHours(0, 0, 0, 0);
today.setHours(23, 59, 59, 59);
const filter = {
where: {
'v.stamp': {between: [yesterday, today]}
}
};
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
expect(result.length).toEqual(5);
await tx.rollback();
} catch (e) {

View File

@ -88,8 +88,16 @@
</td>
</tr>
</tbody>
<table>
<slot-table>
</table>
</slot-table>
<slot-pagination>
<vn-pagination
model="model"
class="vn-pt-xs"
scroll-selector="vn-monitor-sales-clients smart-table"
scroll-offset="100">
</vn-pagination>
</slot-pagination>
</smart-table>
</vn-card>
<vn-worker-descriptor-popover

View File

@ -38,6 +38,9 @@
},
"created": {
"type": "date"
},
"originalQuantity":{
"type": "number"
}
},
"relations": {

View File

@ -135,7 +135,8 @@ module.exports = Self => {
function formatDate(date) {
let day = date.getDate();
if (day < 10) day = `0${day}`;
let month = date.getMonth();
let month = date.getMonth() + 1;
if (month < 10) month = `0${month}`;
let year = date.getFullYear();

View File

@ -87,7 +87,7 @@ module.exports = Self => {
function formatDate(date) {
let day = date.getDate();
if (day < 10) day = `0${day}`;
let month = date.getMonth();
let month = date.getMonth() + 1;
if (month < 10) month = `0${month}`;
let year = date.getFullYear();

View File

@ -14,5 +14,6 @@ FROM route r
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN supplier s ON s.id = a.supplierFk
LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id
LEFT JOIN supplier s ON s.id = sa.supplierFk
WHERE r.id IN(?)