7199-devToTest_2316 #2287

Merged
alexm merged 169 commits from 7199-devToTest_2316 into test 2024-04-11 06:25:23 +00:00
16 changed files with 300 additions and 228 deletions
Showing only changes of commit 0f57931b3a - Show all commits

View File

@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2414.01] - 2024-04-04
### Added
### Changed
### Fixed
## [2408.01] - 2024-02-22 ## [2408.01] - 2024-02-22
### Added ### Added

View File

@ -3068,8 +3068,6 @@ INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentIns
UPDATE vn.department UPDATE vn.department
SET workerFk = null; SET workerFk = null;
-- NEW WAREHOUSE
INSERT INTO vn.packaging INSERT INTO vn.packaging
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0); VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);
@ -3733,3 +3731,6 @@ INSERT INTO vn.report (name) VALUES ('LabelCollection');
INSERT INTO vn.parkingLog(originFk, userFk, `action`, creationDate, description, changedModel,oldInstance, newInstance, changedModelId, changedModelValue) INSERT INTO vn.parkingLog(originFk, userFk, `action`, creationDate, description, changedModel,oldInstance, newInstance, changedModelId, changedModelValue)
VALUES(1, 18, 'update', util.VN_CURDATE(), NULL, 'SaleGroup', '{"parkingFk":null}', '{"parkingFk":1}', 1, NULL); VALUES(1, 18, 'update', util.VN_CURDATE(), NULL, 'SaleGroup', '{"parkingFk":null}', '{"parkingFk":1}', 1, NULL);
INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,newInstance,changedModelId,changedModelValue)
VALUES (18,9,'insert','2001-01-01 11:01:00.000','Ticket','{"isDeleted":true}',45,'Super Man');

View File

@ -37,7 +37,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk ) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO'; WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk; DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk CREATE TEMPORARY TABLE tmp.lastEntryOk
@ -94,11 +94,6 @@ BEGIN
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ; SET b.price2 = eo.price2 WHERE b.price2 = 0 ;
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.packing = eo.packing WHERE b.packing = 0;
UPDATE buy b UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk

View File

@ -0,0 +1,19 @@
SET @isTriggerDisabled := TRUE;
UPDATE vn.buy
SET packing = 1
WHERE packing IS NULL
OR packing <= 0;
UPDATE vn.itemShelving
SET packing = 1
WHERE packing IS NULL
OR NOT packing;
SET @isTriggerDisabled := FALSE;
ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0);
ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0);
-- Antes tenia '0=sin obligar 1=groping 2=packing' (groping → grouping)
ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing';

View File

@ -102,7 +102,7 @@
</vn-item> </vn-item>
<vn-item class="dropdown" <vn-item class="dropdown"
vn-click-stop="refundMenu.show($event, 'left')" vn-click-stop="refundMenu.show($event, 'left')"
vn-tooltip="Create a single ticket with all the content of the current invoice" vn-tooltip="Create a refund ticket for each ticket on the current invoice"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>

View File

@ -118,11 +118,14 @@ class Controller extends Section {
const query = 'InvoiceOuts/refund'; const query = 'InvoiceOuts/refund';
const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse}; const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse};
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
const refundTicket = res.data; const tickets = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { const refundTickets = tickets.map(ticket => ticket.id);
ticketId: refundTicket.id
this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {
ticketId: refundTickets.join(',')
})); }));
this.$state.go('ticket.card.sale', {id: refundTicket.id}); if (refundTickets.length == 1)
this.$state.go('ticket.card.sale', {id: refundTickets[0]});
}); });
} }

View File

@ -15,7 +15,7 @@ Are you sure you want to clone this invoice?: Estas seguro de clonar esta factur
InvoiceOut booked: Factura asentada InvoiceOut booked: Factura asentada
Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura?
Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Create a refund ticket for each ticket on the current invoice: Crear un ticket abono por cada ticket de la factura actual
Regenerate PDF invoice: Regenerar PDF factura Regenerate PDF invoice: Regenerar PDF factura
The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
The email can't be empty: El correo no puede estar vacío The email can't be empty: El correo no puede estar vacío

View File

@ -30,9 +30,11 @@ module.exports = Self => {
}); });
function validateDistance(err) { function validateDistance(err) {
if (this.kmEnd) {
const routeTotalKm = this.kmEnd - this.kmStart; const routeTotalKm = this.kmEnd - this.kmStart;
const routeMaxKm = 4000; const routeMaxKm = 4000;
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
err(); err();
} }
}
}; };

View File

@ -9,8 +9,8 @@ describe('ticketLog getChanges()', () => {
it('should return the changes in the sales of a ticket', async() => { it('should return the changes in the sales of a ticket', async() => {
const ticketId = 16; const ticketId = 16;
const changues = await models.TicketLog.getChanges(ctx, ticketId); const changes = await models.TicketLog.getChanges(ctx, ticketId);
expect(changues).toContain(`Change quantity`); expect(changes).toContain(`Change quantity`);
}); });
}); });

View File

@ -29,6 +29,15 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const ticketLog = await models.TicketLog.findOne({
fields: ['originFk', 'creationDate', 'newInstance'],
where: {
originFk: id,
newInstance: {like: '%"isDeleted":true%'}
},
order: 'creationDate DESC'
}, myOptions);
const ticket = await models.Ticket.findById(id, { const ticket = await models.Ticket.findById(id, {
include: [{ include: [{
relation: 'client', relation: 'client',
@ -39,10 +48,9 @@ module.exports = Self => {
}, myOptions); }, myOptions);
const now = Date.vnNew(); const now = Date.vnNew();
const maxDate = new Date(ticket.updated); const maxDate = new Date(ticketLog?.creationDate);
maxDate.setHours(maxDate.getHours() + 1); maxDate.setHours(maxDate.getHours() + 1);
if (!ticketLog || now > maxDate)
if (now > maxDate)
throw new UserError(`You can only restore a ticket within the first hour after deletion`); throw new UserError(`You can only restore a ticket within the first hour after deletion`);
// Send notification to salesPerson // Send notification to salesPerson

View File

@ -4,7 +4,7 @@ const models = app.models;
describe('ticket restore()', () => { describe('ticket restore()', () => {
const employeeUser = 1110; const employeeUser = 1110;
const ticketId = 18; const ticketId = 9;
const activeCtx = { const activeCtx = {
accessToken: {userId: employeeUser}, accessToken: {userId: employeeUser},
headers: { headers: {
@ -30,10 +30,21 @@ describe('ticket restore()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const ticket = await models.Ticket.findById(ticketId, null, options); const ticket = await models.Ticket.findById(ticketId, null, options);
await ticket.updateAttributes({ await ticket.updateAttributes({
isDeleted: true, isDeleted: true,
updated: now updated: now
}, options); }, options);
await models.TicketLog.create({
originFk: ticketId,
userFk: employeeUser,
action: 'update',
changedModel: 'Ticket',
creationDate: new Date('2001-01-01 10:59:00'),
newInstance: '{"isDeleted":true}'
}, options);
await app.models.Ticket.restore(ctx, ticketId, options); await app.models.Ticket.restore(ctx, ticketId, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -52,11 +63,21 @@ describe('ticket restore()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options); const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options);
await ticketBeforeUpdate.updateAttributes({ await ticketBeforeUpdate.updateAttributes({
isDeleted: true, isDeleted: true,
updated: now updated: now
}, options); }, options);
await models.TicketLog.create({
originFk: ticketId,
userFk: employeeUser,
action: 'update',
changedModel: 'Ticket',
creationDate: new Date('2001-01-01 11:01:00'),
newInstance: '{"isDeleted":true}'
}, options);
const ticketAfterUpdate = await models.Ticket.findById(ticketId, null, options); const ticketAfterUpdate = await models.Ticket.findById(ticketId, null, options);
expect(ticketAfterUpdate.isDeleted).toBeTruthy(); expect(ticketAfterUpdate.isDeleted).toBeTruthy();
@ -65,7 +86,9 @@ describe('ticket restore()', () => {
const ticketAfterRestore = await models.Ticket.findById(ticketId, null, options); const ticketAfterRestore = await models.Ticket.findById(ticketId, null, options);
const fullYear = now.getFullYear(); const fullYear = now.getFullYear();
const shippedFullYear = ticketAfterRestore.shipped.getFullYear(); const shippedFullYear = ticketAfterRestore.shipped.getFullYear();
const landedFullYear = ticketAfterRestore.landed.getFullYear(); const landedFullYear = ticketAfterRestore.landed.getFullYear();
expect(ticketAfterRestore.isDeleted).toBeFalsy(); expect(ticketAfterRestore.isDeleted).toBeFalsy();

View File

@ -5,5 +5,40 @@
"mysql": { "mysql": {
"table": "ticketLog" "table": "ticketLog"
} }
},
"properties": {
"id": {
"type": "string"
},
"originFk": {
"type": "number"
},
"userFk": {
"type":"number"
},
"action": {
"type": "string"
},
"creationDate": {
"type": "date"
},
"description": {
"type": "string"
},
"changedModel": {
"type": "string"
},
"oldInstance": {
"type": "any"
},
"newInstance": {
"type": "any"
},
"changedModelId": {
"type": "string"
},
"changedModelValue": {
"type": "string"
}
} }
} }

View File

@ -35,6 +35,29 @@ class Controller extends Section {
}); });
} }
}); });
const filter = {
fields: ['originFk', 'creationDate', 'newInstance'],
where: {
originFk: value,
newInstance: {like: '%"isDeleted":true%'}
},
order: 'creationDate DESC'
};
this.$http.get(`TicketLogs/findOne`, {filter})
.then(res => {
if (res && res.data) {
const now = Date.vnNew();
const maxDate = new Date(res.data.creationDate);
maxDate.setHours(maxDate.getHours() + 1);
if (now <= maxDate)
return this.canRestoreTicket = true;
}
this.canRestoreTicket = false;
})
.catch(() => {
this.canRestoreTicket = false;
});
} }
get isInvoiced() { get isInvoiced() {
@ -171,15 +194,6 @@ class Controller extends Section {
}); });
} }
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
const now = Date.vnNew();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate);
}
restoreTicket() { restoreTicket() {
return this.$http.post(`Tickets/${this.id}/restore`) return this.$http.post(`Tickets/${this.id}/restore`)
.then(() => this.reload()) .then(() => this.reload())

View File

@ -40,29 +40,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
controller.ticket = ticket; controller.ticket = ticket;
})); }));
describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true;
controller.ticket.updated = Date.vnNew();
const result = controller.canRestoreTicket;
expect(result).toBeTruthy();
});
it('should return false for a ticket deleted more than one hour ago', () => {
const pastHour = Date.vnNew();
pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true;
controller.ticket.updated = pastHour;
const result = controller.canRestoreTicket;
expect(result).toBeFalsy();
});
});
describe('addTurn()', () => { describe('addTurn()', () => {
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => { it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
controller.$.addTurn = {hide: () => {}}; controller.$.addTurn = {hide: () => {}};
@ -105,20 +82,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
}); });
}); });
describe('restoreTicket()', () => {
it('should make a query to restore the ticket and call vnApp.showSuccess()', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/restore`).respond();
controller.restoreTicket();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalled();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('showPdfDeliveryNote()', () => { describe('showPdfDeliveryNote()', () => {
it('should open a new window showing a delivery note PDF document', () => { it('should open a new window showing a delivery note PDF document', () => {
jest.spyOn(window, 'open').mockReturnThis(); jest.spyOn(window, 'open').mockReturnThis();

View File

@ -14,7 +14,8 @@ Refund all...: Abonar todo...
with warehouse: con almacén with warehouse: con almacén
without warehouse: sin almacén without warehouse: sin almacén
Invoice sent: Factura enviada Invoice sent: Factura enviada
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" The following refund ticket have been created: "Se ha creado el siguiente ticket de abono: {{ticketId}}"
The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketId}}"
Transfer client: Transferir cliente Transfer client: Transferir cliente
Send SMS...: Enviar SMS... Send SMS...: Enviar SMS...
Notify changes: Notificar cambios Notify changes: Notificar cambios

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "24.12.0", "version": "24.14.0",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",