refs #5194 fixed stock, lines

This commit is contained in:
Alexandre Riera 2023-02-10 08:46:54 +01:00
parent 220f7ee0f8
commit 194069c0c2
13 changed files with 165 additions and 130 deletions

View File

@ -691,7 +691,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(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()),
(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());
(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()),
(32, 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
@ -993,7 +994,9 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(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()),
(37, 4, 31, '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()),
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
(39, 1, 32, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
VALUES

View File

@ -12,7 +12,7 @@ describe('item getVisibleAvailable()', () => {
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
expect(result.available).toEqual(187);
expect(result.available).toEqual(185);
expect(result.visible).toEqual(92);
await tx.rollback();

View File

@ -35,8 +35,7 @@
<vn-th field="warehouseFk">Warehouse</vn-th>
<vn-th field="landed">Landed</vn-th>
<vn-th number>Entry</vn-th>
<vn-th number vn-tooltip="Price Per Unit">P.P.U</vn-th>
<vn-th number vn-tooltip="Price Per Package">P.P.P</vn-th>
<vn-th vn-tooltip="Grouping / Packing" expand>PVP</vn-th>
<vn-th number class="expendable">Label</vn-th>
<vn-th number>Packing</vn-th>
<vn-th number>Grouping</vn-th>
@ -65,8 +64,9 @@
{{::entry.entryFk | dashIfEmpty}}
</span>
</vn-td>
<vn-td number>{{::entry.price2 | dashIfEmpty}}</vn-td>
<vn-td number>{{::entry.price3 | dashIfEmpty}}</vn-td>
<vn-td title="Grouping / Packing">
{{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}
</vn-td>
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
<vn-td number>
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">

View File

@ -50,15 +50,9 @@ module.exports = Self => {
required: false
},
{
arg: 'state',
type: 'string',
description: 'Origin state',
required: false
},
{
arg: 'futureState',
type: 'string',
description: 'Destination state',
arg: 'fullMovable',
type: 'boolean',
description: 'True when lines and stock of origin are equal',
required: false
},
{
@ -92,13 +86,21 @@ module.exports = Self => {
case 'futureId':
return {'f.futureId': value};
case 'ipt':
return {'f.ipt': value};
return {or:
[
{'f.ipt': {like: `%${value}%`}},
{'f.ipt': null}
]
};
case 'futureIpt':
return {'f.futureIpt': value};
case 'state':
return {'f.stateCode': {like: `%${value}%`}};
case 'futureState':
return {'f.futureStateCode': {like: `%${value}%`}};
return {or:
[
{'f.futureIpt': {like: `%${value}%`}},
{'f.futureIpt': null}
]
};
case 'fullMovable':
return {'f.fullMovable': value};
}
});

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
describe('TicketFuture getTicketsAdvance()', () => {
const today = new Date();
describe('ticket getTicketsAdvance()', () => {
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
@ -29,7 +29,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
}
});
it('should return the tickets matching the origin grouped state', async() => {
it('should return the tickets matching the fullMovable true', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@ -39,7 +39,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
state: 'OK'
fullMovable: true
};
const ctx = {req: {accessToken: {userId: 9}}, args};
@ -54,7 +54,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
}
});
it('should return the tickets matching the destination grouped state', async() => {
it('should return the tickets matching the fullMovable false', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@ -64,7 +64,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
futureState: 'FREE'
fullMovable: false
};
const ctx = {req: {accessToken: {userId: 9}}, args};
@ -95,7 +95,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toBeLessThan(5);
expect(result.length).toBeGreaterThan(5);
await tx.rollback();
} catch (e) {
@ -120,7 +120,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsAdvance(ctx, options);
expect(result.length).toBeLessThan(5);
expect(result.length).toBeGreaterThan(5);
await tx.rollback();
} catch (e) {

View File

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

View File

@ -39,28 +39,12 @@
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal class="vn-px-lg">
<vn-autocomplete vn-one
data="$ctrl.groupedStates"
label="Origin Grouped State"
value-field="code"
show-field="name"
ng-model="filter.futureState">
<tpl-item>
{{name}}
</tpl-item>
</vn-autocomplete>
<vn-autocomplete vn-one
data="$ctrl.groupedStates"
label="Destination Grouped State"
value-field="code"
show-field="name"
ng-model="filter.state">
<tpl-item>
{{name}}
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal class="vn-px-lg">
<vn-check
vn-one
label="100% movable"
ng-model="filter.fullMovable"
triple-state="true">
</vn-check>
<vn-autocomplete
vn-one
label="Warehouse"

View File

@ -1 +1,2 @@
Advance tickets: Adelantar tickets
100% movable: 100% movible

View File

@ -32,8 +32,8 @@
<thead>
<tr second-header>
<td></td>
<th colspan="5" translate>Origin</th>
<th colspan="8" translate>Destination</th>
<th colspan="7" translate>Destination</th>
<th colspan="9" translate>Origin</th>
</tr>
<tr>
<th shrink>
@ -43,7 +43,30 @@
check-field="checked">
</vn-multi-check>
</th>
<th field="futureId">
<th shrink>
</th>
<th field="id">
<span translate>ID</span>
</th>
<th field="shipped">
<span translate>Date</span>
</th>
<th field="ipt" title="{{'Item Packing Type' | translate}}">
<span>IPT</span>
</th>
<th field="state">
<span translate>State</span>
</th>
<th field="liters">
<span translate>Liters</span>
</th>
<th field="lines">
<span translate>Lines</span>
</th>
<th field="totalWithVat">
<span translate>Import</span>
</th>
<th separator field="futureId">
<span translate>ID</span>
</th>
<th field="futureShipped">
@ -58,30 +81,6 @@
<th field="totalWithVat">
<span translate>Import</span>
</th>
<th separator field="id">
<span translate>ID</span>
</th>
<th field="shipped">
<span translate>Date</span>
</th>
<th field="ipt" title="Item Packing Type">
<span>IPT</span>
</th>
<th field="state">
<span translate>State</span>
</th>
<th field="liters">
<span translate>Liters</span>
</th>
<th field="hasStock">
<span>Stock</span>
</th>
<th field="lines">
<span translate>Lines</span>
</th>
<th field="futureTotalWithVat">
<span translate>Import</span>
</th>
</tr>
</thead>
<tbody>
@ -93,28 +92,11 @@
</vn-check>
</td>
<td>
<span
ng-click="ticketDescriptor.show($event, ticket.futureId)"
class="link">
{{::ticket.futureId | dashIfEmpty}}
</span>
</td>
<td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.futureShipped)}}">
{{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
</span>
</td>
<td>{{::ticket.futureIpt | dashIfEmpty}}</td>
<td>
<span
class="chip {{$ctrl.stateColor(ticket.futureState)}}">
{{::ticket.futureState | dashIfEmpty}}
</span>
</td>
<td>
<span class="chip {{$ctrl.totalPriceColor(ticket.futureTotalWithVat)}}">
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
</span>
<vn-icon
ng-show="ticket.futureAgency !== ticket.agency"
icon="icon-agency-term"
title="{{$ctrl.agencies(ticket.futureAgency, ticket.agency)}}">
</vn-icon>
</td>
<td>
<span
@ -136,13 +118,41 @@
</span>
</td>
<td>{{::ticket.liters | dashIfEmpty}}</td>
<td>{{::ticket.hasStock | dashIfEmpty}}</td>
<td>{{::ticket.lines | dashIfEmpty}}</td>
<td>
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
<span
class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}"
title="{{$ctrl.totalPriceTitle(ticket.totalWithVat) | translate}}">
{{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
</span>
</td>
<td separator>
<span
ng-click="ticketDescriptor.show($event, ticket.futureId)"
class="link">
{{::ticket.futureId | dashIfEmpty}}
</span>
</td>
<td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.futureShipped)}}">
{{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
</span>
</td>
<td>{{::ticket.futureIpt | dashIfEmpty}}</td>
<td>
<span
class="chip {{$ctrl.stateColor(ticket.futureState)}}">
{{::ticket.futureState | dashIfEmpty}}
</span>
</td>
<td>
<span
class="chip {{$ctrl.totalPriceColor(ticket.futureTotalWithVat)}}"
title="{{$ctrl.totalPriceTitle(ticket.futureTotalWithVat) | translate}}">
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
</span>
</td>
</tr>
</tbody>
</table>

View File

@ -115,9 +115,15 @@ export default class Controller extends Section {
}
totalPriceColor(totalWithVat) {
const total = parseInt(totalWithVat);
if (total > 0 && total < 50)
return 'warning';
return this.isLessThan50(totalWithVat) ? 'warning' : '';
}
totalPriceTitle(totalWithVat) {
return this.isLessThan50(totalWithVat) ? 'Less than 50€' : '';
}
isLessThan50(totalWithVat) {
return (parseInt(totalWithVat) > 0 && parseInt(totalWithVat) < 50);
}
get confirmationMessage() {
@ -128,6 +134,11 @@ export default class Controller extends Section {
});
}
agencies(futureAgency, agency) {
return this.$t(`Origin agency`, {agency: futureAgency}) +
'\n' + this.$t(`Destination agency`, {agency: agency});
}
moveTicketsAdvance() {
let ticketsToMove = [];
this.checked.forEach(ticket => {
@ -158,9 +169,19 @@ export default class Controller extends Section {
case 'lines':
return {'lines': value};
case 'ipt':
return {'ipt': value};
return {or:
[
{'ipt': {like: `%${value}%`}},
{'ipt': null}
]
};
case 'futureIpt':
return {'futureIpt': value};
return {or:
[
{'futureIpt': {like: `%${value}%`}},
{'futureIpt': null}
]
};
case 'totalWithVat':
return {'totalWithVat': value};
case 'futureTotalWithVat':

View File

@ -4,3 +4,7 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets?
Success: Tickets movidos correctamente
Lines: Líneas
Liters: Litros
Item Packing Type: Encajado
Origin agency: "Agencia origen: {{agency}}"
Destination agency: "Agencia destino: {{agency}}"
Less than 50€: Menor a 50€

View File

@ -143,7 +143,7 @@
</td>
<td>{{::ticket.liters}}</td>
<td>{{::ticket.lines}}</td>
<td>
<td separator>
<span
ng-click="ticketDescriptor.show($event, ticket.futureId)"
class="link">

View File

@ -146,9 +146,19 @@ export default class Controller extends Section {
case 'lines':
return {'lines': value};
case 'ipt':
return {'ipt': value};
return {or:
[
{'ipt': {like: `%${value}%`}},
{'ipt': null}
]
};
case 'futureIpt':
return {'futureIpt': value};
return {or:
[
{'futureIpt': {like: `%${value}%`}},
{'futureIpt': null}
]
};
}
}
}