Compare commits

...

5 Commits

Author SHA1 Message Date
Vicent Llopis 87311261ca refs #5669 refactor: simplificado front
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2023-08-25 10:45:01 +02:00
Vicent Llopis f388415ba3 Merge branch 'dev' into 5669-ticket.volume_fix
gitea/salix/pipeline/head There was a failure building this commit Details
2023-08-24 10:15:29 +00:00
Vicent Llopis eb442c98e8 refs #5669 move chages sql
gitea/salix/pipeline/head There was a failure building this commit Details
2023-08-24 12:15:58 +02:00
Vicent Llopis 8d2da96ff7 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5669-ticket.volume_fix
gitea/salix/pipeline/head There was a failure building this commit Details
2023-08-24 09:59:17 +02:00
Vicent Llopis 87351a9f5b refs #5669 fix: permite ordenar por 'Encajado'
gitea/salix/pipeline/head There was a failure building this commit Details
2023-07-31 11:59:17 +02:00
7 changed files with 95 additions and 45 deletions

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
VALUES
('Ticket','volume','READ','ALLOW','employee');

View File

@ -9,31 +9,17 @@ module.exports = Self => {
description: 'ticket id', description: 'ticket id',
http: {source: 'path'} http: {source: 'path'}
}], }],
returns: [{ returns: {
arg: 'saleVolume', type: 'object',
type: ['object'] root: true
}, },
{
arg: 'packingTypeVolume',
type: ['object']
}],
http: { http: {
path: `/:id/getVolume`, path: `/:id/getVolume`,
verb: 'GET' verb: 'GET'
} }
}); });
Self.getVolume = async(ticketFk, options) => { Self.getVolume = async ticketFk => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const saleVolume = await Self.rawSql(`
SELECT saleFk, volume
FROM vn.saleVolume
WHERE ticketFk = ?`, [ticketFk], myOptions);
const packingTypeVolume = await Self.rawSql(` const packingTypeVolume = await Self.rawSql(`
SELECT s.itemPackingTypeFk code, SELECT s.itemPackingTypeFk code,
i.description, i.description,
@ -42,8 +28,8 @@ module.exports = Self => {
LEFT JOIN vn.itemPackingType i LEFT JOIN vn.itemPackingType i
ON i.code = s.itemPackingTypeFk ON i.code = s.itemPackingTypeFk
WHERE s.ticketFk = ? WHERE s.ticketFk = ?
GROUP BY s.itemPackingTypeFk`, [ticketFk], myOptions); GROUP BY s.itemPackingTypeFk`, [ticketFk]);
return [saleVolume, packingTypeVolume]; return packingTypeVolume;
}; };
}; };

View File

@ -0,0 +1,11 @@
const models = require('vn-loopback/server/server').models;
fdescribe('ticket volume()', () => {
it('should return the tickets matching the filter', async() => {
const ticketId = 1;
const filter = {order: ['concept']};
const result = await models.Ticket.volume(ticketId, filter);
expect(result.length).toBe(4);
});
});

View File

@ -0,0 +1,65 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('volume', {
description: 'Return the volume of a ticket',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The ticket id',
http: {source: 'path'}
},
{
arg: 'filter',
type: 'object'
}],
returns: {
type: 'object',
root: true
},
http: {
path: '/:id/volume',
verb: 'GET'
}
});
Self.volume = async(id, filter) => {
const conn = Self.dataSource.connector;
const stmt = new ParameterizedSQL(
`SELECT
s.id,
s.itemFk,
s.quantity,
i.name,
i.subName,
i.itemPackingTypeFk,
i.value5,
i.value6,
i.value7,
i.value8,
i.value9,
i.value10,
sv.volume
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = ?`
, [id]
);
stmt.merge(conn.makeSuffix(filter));
const result = await conn.executeStmt(stmt);
const outputArray = result.map(({name, subName, itemPackingTypeFk, ...rest}) => ({
...rest,
item: {name, subName, itemPackingTypeFk},
}));
return outputArray;
};
};

View File

@ -42,5 +42,6 @@ module.exports = function(Self) {
require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/expeditionPalletLabel')(Self);
require('../methods/ticket/saveSign')(Self); require('../methods/ticket/saveSign')(Self);
require('../methods/ticket/invoiceTickets')(Self); require('../methods/ticket/invoiceTickets')(Self);
require('../methods/ticket/volume')(Self);
require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/docuwareDownload')(Self);
}; };

View File

@ -1,10 +1,9 @@
<vn-crud-model <vn-crud-model
auto-load="true" auto-load="true"
vn-id="model" vn-id="model"
url="sales" url="Tickets/{{$ctrl.$params.id}}/volume"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$params.id}"
data="$ctrl.sales" data="$ctrl.sales"
order="concept"
limit="20"> limit="20">
</vn-crud-model> </vn-crud-model>
<vn-vertical> <vn-vertical>
@ -54,7 +53,7 @@
</vn-td> </vn-td>
<vn-td number>{{::sale.item.itemPackingTypeFk}}</vn-td> <vn-td number>{{::sale.item.itemPackingTypeFk}}</vn-td>
<vn-td number>{{::sale.quantity}}</vn-td> <vn-td number>{{::sale.quantity}}</vn-td>
<vn-td number>{{::sale.saleVolume.volume | number:3}}</vn-td> <vn-td number>{{::sale.volume | number:3}}</vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>
</vn-table> </vn-table>

View File

@ -4,12 +4,6 @@ import Section from 'salix/components/section';
class Controller extends Section { class Controller extends Section {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.filter = {
include: {
relation: 'item'
},
order: 'concept'
};
this.ticketVolumes = []; this.ticketVolumes = [];
} }
@ -25,18 +19,9 @@ class Controller extends Section {
} }
applyVolumes() { applyVolumes() {
const ticket = this.sales[0].ticketFk; this.$http.get(`Tickets/${this.$params.id}/getVolume`)
this.$http.get(`Tickets/${ticket}/getVolume`).then(res => { .then(res => {
const saleVolume = res.data.saleVolume; this.packingTypeVolume = res.data;
const volumes = new Map();
for (const volume of saleVolume)
volumes.set(volume.saleFk, volume);
for (const sale of this.sales)
sale.saleVolume = volumes.get(sale.id);
this.packingTypeVolume = res.data.packingTypeVolume;
}); });
} }
} }