refs #3963 front and back tests fixed
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2022-11-15 15:30:00 +01:00
parent 09d7c450a2
commit b7c9d6ea50
14 changed files with 250 additions and 60 deletions

View File

@ -55,7 +55,7 @@ BEGIN
sum((s.quantity <= IFNULL(st.amount,0))) hasStock,
count(DISTINCT s.id) saleCount,
st.name tfState,
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) tfIpt,
GROUP_CONCAT(DISTINCT ipt.description ORDER BY ipt.description) tfIpt,
t2.ticketFk id,
t2.state,
t2.ipt,
@ -65,16 +65,17 @@ BEGIN
t2.shipped,
t.shipped tfShipped,
t2.totalWithVat,
t.totalWithVat tfTotalWithVat
t.totalWithVat tfTotalWithVat,
t.landed destETD
FROM vn.ticket t
JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN vn.state st ON st.id = ts.stateFk
JOIN vn.saleVolume sv ON t.id = sv.ticketFk
LEFT JOIN (SELECT
JOIN (SELECT
t2.id ticketFk,
t2.addressFk,
st.name state,
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
GROUP_CONCAT(DISTINCT ipt.description ORDER BY ipt.description) ipt,
t2.shipped,
t2.totalWithVat
FROM vn.ticket t2
@ -82,11 +83,13 @@ BEGIN
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.ticketState ts ON ts.ticketFk = t2.id
JOIN vn.state st ON st.id = ts.stateFk
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
AND t2.warehouseFk = vWarehouseFk
GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
WHERE t.shipped BETWEEN vDated AND util.dayend(vDated)
AND t.warehouseFk = vWarehouseFk

View File

@ -689,7 +689,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
(28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE());
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE());
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
@ -990,7 +991,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()),
(34, 4, 28, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(35, 4, 29, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(36, 4, 30, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE());
(36, 4, 30, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
(37, 4, 31, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE());
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
VALUES
@ -2720,4 +2722,4 @@ UPDATE `account`.`user`
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
VALUES
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');

View File

@ -11,7 +11,7 @@ describe('SalesMonitor salesFilter()', () => {
const filter = {order: 'id DESC'};
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
expect(result.length).toEqual(30);
expect(result.length).toEqual(31);
await tx.rollback();
} catch (e) {
@ -87,7 +87,7 @@ describe('SalesMonitor salesFilter()', () => {
const filter = {};
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
expect(result.length).toEqual(30);
expect(result.length).toEqual(31);
await tx.rollback();
} catch (e) {
@ -130,7 +130,7 @@ describe('SalesMonitor salesFilter()', () => {
const length = result.length;
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
expect(length).toEqual(13);
expect(length).toEqual(14);
expect(anyResult.state).toMatch(/(Libre|Arreglar)/);
await tx.rollback();
@ -171,7 +171,7 @@ describe('SalesMonitor salesFilter()', () => {
const filter = {};
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
expect(result.length).toEqual(26);
expect(result.length).toEqual(27);
await tx.rollback();
} catch (e) {

View File

@ -8,23 +8,17 @@ module.exports = Self => {
description: 'Find all tickets that can be moved to the present',
accessType: 'READ',
accepts: [
{
arg: 'vDated',
type: 'date',
description: 'The date in question',
required: false
},
{
arg: 'warehouseFk',
type: 'number',
description: 'Warehouse identifier',
required: false
required: true
},
{
arg: 'shipped',
type: 'date',
description: 'Origin shipped',
required: false
required: true
},
{
arg: 'tfShipped',
@ -86,7 +80,6 @@ module.exports = Self => {
Self.getTicketsAdvance = async (ctx, options) => {
const args = ctx.args;
console.log(args);
const conn = Self.dataSource.connector;
const myOptions = {};
@ -95,8 +88,8 @@ module.exports = Self => {
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'shipped':
return { 'f.shipped': value };
// case 'shipped':
// return { 'f.shipped': value };
case 'tfShipped':
return { 'f.tfShipped': value };
case 'ipt':
@ -116,7 +109,7 @@ module.exports = Self => {
stmt = new ParameterizedSQL(
`CALL vn.ticket_canAdvance(?,?)`,
[new Date(), args.warehouseFk]);
[args.shipped, args.warehouseFk]);
stmts.push(stmt);

View File

@ -0,0 +1,174 @@
const models = require('vn-loopback/server/server').models;
fdescribe('TicketFuture getTicketsAdvance()', () => {
const today = new Date();
today.setHours(0, 0, 0, 0);
let tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
it('should return the tickets passing the required data', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the origin grouped state', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
state: 'OK'
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the destination grouped state', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
tfState: 'Libre'
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the origin IPT', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
ipt: 'Vertical'
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(0);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the destination IPT', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
tfIpt: 'Vertical'
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(0);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the origin ID', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
id: 31
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets matching the destination ID', async () => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = { transaction: tx };
const args = {
shipped: tomorrow,
warehouseFk: 1,
ticketFuture: 12
};
const ctx = { req: { accessToken: { userId: 9 } }, args };
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -11,7 +11,7 @@ describe('ticket filter()', () => {
const filter = {order: 'id DESC'};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(30);
expect(result.length).toEqual(31);
await tx.rollback();
} catch (e) {
@ -87,7 +87,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(30);
expect(result.length).toEqual(31);
await tx.rollback();
} catch (e) {
@ -130,7 +130,7 @@ describe('ticket filter()', () => {
const length = result.length;
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
expect(length).toEqual(13);
expect(length).toEqual(14);
expect(anyResult.state).toMatch(/(Libre|Arreglar)/);
await tx.rollback();
@ -175,7 +175,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(26);
expect(result.length).toEqual(27);
await tx.rollback();
} catch (e) {
@ -232,7 +232,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(25);
expect(result.length).toEqual(26);
await tx.rollback();
} catch (e) {
@ -270,7 +270,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(30);
expect(result.length).toEqual(31);
await tx.rollback();
} catch (e) {

View File

@ -87,7 +87,7 @@ describe('sale priceDifference()', () => {
const secondtItem = result.items[1];
expect(firstItem.movable).toEqual(410);
expect(secondtItem.movable).toEqual(1810);
expect(secondtItem.movable).toEqual(1790);
await tx.rollback();
} catch (e) {

View File

@ -4,7 +4,8 @@
<vn-date-picker
vn-one
label="Origin date"
ng-model="filter.shipped">
ng-model="filter.shipped"
required="true">
</vn-date-picker>
<vn-date-picker
vn-one
@ -16,7 +17,7 @@
<vn-autocomplete vn-one
data="$ctrl.itemPackingTypes"
label="Origin IPT"
value-field="code"
value-field="name"
show-field="name"
ng-model="filter.ipt"
info="IPT">
@ -27,7 +28,7 @@
<vn-autocomplete vn-one
data="$ctrl.itemPackingTypes"
label="Destination IPT"
value-field="code"
value-field="name"
show-field="name"
ng-model="filter.tfIpt"
info="IPT">

View File

@ -1 +1,5 @@
Advance tickets: Advance tickets
Fruits and vegetables: Fruits and vegetables
Vertical: Vertical
Horizontal: Horizontal
Feed: Feed

View File

@ -1 +1,5 @@
Advance tickets: Adelantar tickets
Fruits and vegetables: Frutas y verduras
Vertical: Vertical
Horizontal: Horizontal
Feed: Pienso

View File

@ -37,9 +37,6 @@
check-field="checked">
</vn-multi-check>
</th>
<th field="totalWithVat">
<span translate>Import</span>
</th>
<th field="ticketFk">
<span translate>Origin ID</span>
</th>
@ -49,9 +46,15 @@
<th field="ipt">
<span>IPT</span>
</th>
<th field="totalWithVat">
<span translate>Import</span>
</th>
<th field="ticketFuture">
<span translate>Destination ID</span>
</th>
<th field="destETD">
<span translate>Destination ETD</span>
</th>
<th field="tfState">
<span translate>Destination State</span>
</th>
@ -61,12 +64,6 @@
<th field="lines">
<span translate>Lines</span>
</th>
<!-- <th field="destETD">
<span translate>Destination ETD</span>
</th>
<th field="stock">
<span translate>Stock</span>
</th> -->
<th field="hasStock">
<span>Stock</span>
</th>
@ -86,11 +83,6 @@
vn-click-stop>
</vn-check>
</td>
<td>
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
{{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
</span>
</td>
<td>
<span
ng-click="ticketDescriptor.show($event, ticket.id)"
@ -98,11 +90,6 @@
{{::ticket.id | dashIfEmpty}}
</span>
</td>
<!-- <td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.originETD)}}">
{{::ticket.originETD | date: 'dd/MM/yyyy'}}
</span>
</td> -->
<td>
<span
class="chip {{$ctrl.stateColor(ticket.state)}}">
@ -110,6 +97,11 @@
</span>
</td>
<td>{{::ticket.ipt | dashIfEmpty}}</td>
<td>
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
{{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
</span>
</td>
<td>
<span
ng-click="ticketDescriptor.show($event, ticket.ticketFuture)"
@ -117,17 +109,17 @@
{{::ticket.ticketFuture | dashIfEmpty}}
</span>
</td>
<td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.destETD)}}">
{{::ticket.destETD | date: 'dd/MM/yyyy'}}
</span>
</td>
<td>
<span
class="chip {{$ctrl.stateColor(ticket.tfState)}}">
{{::ticket.tfState | dashIfEmpty}}
</span>
</td>
<!-- <td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.destETD)}}">
{{::ticket.destETD | date: 'dd/MM/yyyy'}}
</span>
</td> -->
<td>{{::ticket.liters | dashIfEmpty}}</td>
<td>{{::ticket.lines | dashIfEmpty}}</td>
<td>{{::ticket.hasStock | dashIfEmpty}}</td>

View File

@ -19,12 +19,20 @@ export default class Controller extends Section {
field: 'tfState',
searchable: false
},
{
field: 'totalWithVat',
searchable: false
},
{
field: 'tfTotalWithVat',
searchable: false
},
{
field: 'ipt',
autocomplete: {
url: 'ItemPackingTypes',
showField: 'description',
valueField: 'code'
valueField: 'description'
}
},
{
@ -32,7 +40,7 @@ export default class Controller extends Section {
autocomplete: {
url: 'ItemPackingTypes',
showField: 'description',
valueField: 'code'
valueField: 'description'
}
},
]
@ -95,7 +103,8 @@ export default class Controller extends Section {
}
moveTicketsAdvance() {
let params = { tickets: this.checked };
const params = { tickets: this.checked };
console.log(params);
return this.$http.post('Tickets/merge', params)
.then(() => {
this.$.model.refresh();

View File

@ -1,2 +1,6 @@
Advance tickets: Advance tickets
Success: Tickets moved successfully!
Fruits and vegetables: Fruits and vegetables
Vertical: Vertical
Horizontal: Horizontal
Feed: Feed

View File

@ -4,3 +4,7 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets?
Success: Tickets movidos correctamente
Lines: Líneas
Liters: Litros
Fruits and vegetables: Frutas y verduras
Vertical: Vertical
Horizontal: Horizontal
Feed: Pienso