Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5475-email_2fa
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2023-06-16 13:42:13 +02:00
commit dd157d59d9
59 changed files with 485 additions and 305 deletions

View File

@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- -
## [2324.01] - 2023-06-08 ## [2324.01] - 2023-06-15
### Added ### Added
- (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén - (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén

View File

@ -8,7 +8,7 @@ Salix is also the scientific name of a beautifull tree! :)
Required applications. Required applications.
* Node.js = 14.x LTS * Node.js >= 16.x LTS
* Docker * Docker
* Git * Git

View File

@ -2,8 +2,9 @@ const models = require('vn-loopback/server/server').models;
describe('docuware upload()', () => { describe('docuware upload()', () => {
const userId = 9; const userId = 9;
const ticketId = 10; const ticketIds = [10];
const ctx = { const ctx = {
args: {ticketIds},
req: { req: {
getLocale: () => { getLocale: () => {
return 'en'; return 'en';
@ -27,7 +28,7 @@ describe('docuware upload()', () => {
let error; let error;
try { try {
await models.Docuware.upload(ctx, ticketId, fileCabinetName); await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
} catch (e) { } catch (e) {
error = e.message; error = e.message;
} }

View File

@ -3,34 +3,34 @@ const axios = require('axios');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('upload', { Self.remoteMethodCtx('upload', {
description: 'Upload an docuware PDF', description: 'Upload docuware PDFs',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'ticketIds',
type: 'number', type: ['number'],
description: 'The ticket id', description: 'The ticket ids',
http: {source: 'path'} required: true
}, },
{ {
arg: 'fileCabinet', arg: 'fileCabinet',
type: 'string', type: 'string',
description: 'The file cabinet' description: 'The file cabinet',
}, required: true
{
arg: 'dialog',
type: 'string',
description: 'The dialog'
} }
], ],
returns: [], returns: {
type: 'object',
root: true
},
http: { http: {
path: `/:id/upload`, path: `/upload`,
verb: 'POST' verb: 'POST'
} }
}); });
Self.upload = async function(ctx, id, fileCabinet) { Self.upload = async function(ctx, ticketIds, fileCabinet) {
delete ctx.args.ticketIds;
const models = Self.app.models; const models = Self.app.models;
const action = 'store'; const action = 'store';
@ -38,104 +38,114 @@ module.exports = Self => {
const fileCabinetId = await Self.getFileCabinet(fileCabinet); const fileCabinetId = await Self.getFileCabinet(fileCabinet);
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
// get delivery note const uploaded = [];
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, { for (id of ticketIds) {
id, // get delivery note
type: 'deliveryNote' ctx.args.id = id;
}); const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
id,
// get ticket data type: 'deliveryNote'
const ticket = await models.Ticket.findById(id, {
include: [{
relation: 'client',
scope: {
fields: ['id', 'socialName', 'fi']
}
}]
});
// upload file
const templateJson = {
'Fields': [
{
'FieldName': 'N__ALBAR_N',
'ItemElementName': 'string',
'Item': id,
},
{
'FieldName': 'CIF_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().fi,
},
{
'FieldName': 'CODIGO_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().id,
},
{
'FieldName': 'NOMBRE_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().socialName,
},
{
'FieldName': 'FECHA_FACTURA',
'ItemElementName': 'date',
'Item': ticket.shipped,
},
{
'FieldName': 'TOTAL_FACTURA',
'ItemElementName': 'Decimal',
'Item': ticket.totalWithVat,
},
{
'FieldName': 'ESTADO',
'ItemElementName': 'string',
'Item': 'Pendiente procesar',
},
{
'FieldName': 'FIRMA_',
'ItemElementName': 'string',
'Item': 'Si',
},
{
'FieldName': 'FILTRO_TABLET',
'ItemElementName': 'string',
'Item': 'Tablet1',
}
]
};
if (process.env.NODE_ENV != 'production')
throw new UserError('Action not allowed on the test environment');
// delete old
const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
if (docuwareFile) {
const deleteJson = {
'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
};
const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
await axios.put(deleteUri, deleteJson, options.headers);
}
const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
const FormData = require('form-data');
const data = new FormData();
data.append('document', JSON.stringify(templateJson), 'schema.json');
data.append('file[]', deliveryNote[0], 'file.pdf');
const uploadOptions = {
headers: {
'Content-Type': 'multipart/form-data',
'X-File-ModifiedDate': Date.vnNew(),
'Cookie': options.headers.headers.Cookie,
...data.getHeaders()
},
};
return await axios.post(uploadUri, data, uploadOptions)
.catch(() => {
throw new UserError('Failed to upload file');
}); });
// get ticket data
const ticket = await models.Ticket.findById(id, {
include: [{
relation: 'client',
scope: {
fields: ['id', 'name', 'fi']
}
}]
});
// upload file
const templateJson = {
'Fields': [
{
'FieldName': 'N__ALBAR_N',
'ItemElementName': 'string',
'Item': id,
},
{
'FieldName': 'CIF_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().fi,
},
{
'FieldName': 'CODIGO_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().id,
},
{
'FieldName': 'NOMBRE_PROVEEDOR',
'ItemElementName': 'string',
'Item': ticket.client().name + ' - ' + id,
},
{
'FieldName': 'FECHA_FACTURA',
'ItemElementName': 'date',
'Item': ticket.shipped,
},
{
'FieldName': 'TOTAL_FACTURA',
'ItemElementName': 'Decimal',
'Item': ticket.totalWithVat,
},
{
'FieldName': 'ESTADO',
'ItemElementName': 'string',
'Item': 'Pendiente procesar',
},
{
'FieldName': 'FIRMA_',
'ItemElementName': 'string',
'Item': 'Si',
},
{
'FieldName': 'FILTRO_TABLET',
'ItemElementName': 'string',
'Item': 'Tablet1',
}
]
};
if (process.env.NODE_ENV != 'production')
throw new UserError('Action not allowed on the test environment');
// delete old
const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
if (docuwareFile) {
const deleteJson = {
'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
};
const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
await axios.put(deleteUri, deleteJson, options.headers);
}
const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
const FormData = require('form-data');
const data = new FormData();
data.append('document', JSON.stringify(templateJson), 'schema.json');
data.append('file[]', deliveryNote[0], 'file.pdf');
const uploadOptions = {
headers: {
'Content-Type': 'multipart/form-data',
'X-File-ModifiedDate': Date.vnNew(),
'Cookie': options.headers.headers.Cookie,
...data.getHeaders()
},
};
try {
await axios.post(uploadUri, data, uploadOptions);
} catch (err) {
const $t = ctx.req.__;
const message = $t('Failed to upload delivery note', {id});
if (uploaded.length)
await models.TicketTracking.setDelivered(ctx, uploaded);
throw new UserError(message);
}
uploaded.push(id);
}
return models.TicketTracking.setDelivered(ctx, ticketIds);
}; };
}; };

View File

@ -64,11 +64,9 @@ module.exports = Self => {
scopes: ['change-password'], scopes: ['change-password'],
userId: vnUser.id userId: vnUser.id
}); });
throw new UserError('Pass expired', 'passExpired', { const err = new UserError('Pass expired', 'passExpired');
id: vnUser.id, err.details = {token: changePasswordToken, twoFactor: vnUser.twoFactor ? true : false};
token: changePasswordToken.id, throw err;
twoFactor: vnUser.twoFactor ? true : false
});
} }
}; };

View File

@ -0,0 +1,71 @@
CREATE TABLE `vn`.`packingSiteAdvanced` (
`ticketFk` int(11),
`workerFk` int(10) unsigned,
PRIMARY KEY (`ticketFk`),
KEY `packingSiteAdvanced_FK_1` (`workerFk`),
CONSTRAINT `packingSiteAdvanced_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `packingSiteAdvanced_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('PackingSiteAdvanced', '*', '*', 'ALLOW', 'ROLE', 'production');
DROP PROCEDURE IF EXISTS `vn`.`packingSite_startCollection`;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT)
proc: BEGIN
/**
* @param vSelf packingSite id
* @param vTicketFk A ticket id from the collection to start
*/
DECLARE vExists BOOL;
DECLARE vIsAdvanced BOOL;
DECLARE vNewCollectionFk INT;
DECLARE vOldCollectionFk INT;
DECLARE vIsPackingByOther BOOL;
SELECT id, collectionFk
INTO vExists, vOldCollectionFk
FROM packingSite
WHERE id = vSelf;
IF NOT vExists THEN
CALL util.throw('packingSiteNotExists');
END IF;
SELECT COUNT(*) > 0
INTO vIsAdvanced
FROM packingSiteAdvanced
WHERE ticketFk = vTicketFk;
IF vIsAdvanced THEN
LEAVE proc;
END IF;
SELECT collectionFk INTO vNewCollectionFk
FROM ticketCollection WHERE ticketFk = vTicketFk;
IF vOldCollectionFk IS NOT NULL
AND vOldCollectionFk <> vNewCollectionFk THEN
SELECT COUNT(*) > 0
INTO vIsPackingByOther
FROM packingSite
WHERE id <> vSelf
AND collectionFk = vOldCollectionFk;
IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) THEN
CALL util.throw('cannotChangeCollection');
END IF;
END IF;
UPDATE packingSite SET collectionFk = vNewCollectionFk
WHERE id = vSelf;
END$$
DELIMITER ;

View File

@ -2736,7 +2736,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(1, 'print-email', 'notification fixture one'), (1, 'print-email', 'notification fixture one'),
(2, 'invoice-electronic', 'A electronic invoice has been generated'), (2, 'invoice-electronic', 'A electronic invoice has been generated'),
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'); (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
(5, 'modified-entry', 'An entry has been modified');
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES VALUES

View File

@ -311,9 +311,9 @@ export default {
}, },
clientDefaulter: { clientDefaulter: {
anyClient: 'vn-client-defaulter tbody > tr', anyClient: 'vn-client-defaulter tbody > tr',
firstClientName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(2) > span', firstClientName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(2) > span',
firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(3) > span', firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(3) > span',
firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]', firstObservation: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]',
allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check', allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check',
addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]', addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]',
observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]', observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]',
@ -334,15 +334,15 @@ export default {
}, },
itemsIndex: { itemsIndex: {
createItemButton: `vn-float-button`, createItemButton: `vn-float-button`,
firstSearchResult: 'vn-item-index tbody tr:nth-child(1)', firstSearchResult: 'vn-item-index tbody tr:nth-child(2)',
searchResult: 'vn-item-index tbody tr:not(.empty-rows)', searchResult: 'vn-item-index tbody tr:not(.empty-rows)',
firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]', firstResultPreviewButton: 'vn-item-index tbody > :nth-child(2) .buttons > [icon="preview"]',
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]', searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]', acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
closeItemSummaryPreview: '.vn-popup.shown', closeItemSummaryPreview: '.vn-popup.shown',
shownColumns: 'vn-item-index vn-button[id="shownColumns"]', shownColumns: 'vn-item-index vn-button[id="shownColumns"]',
shownColumnsList: '.vn-popover.shown .content', shownColumnsList: '.vn-popover.shown .content',
firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img', firstItemImage: 'vn-item-index tbody > tr:nth-child(2) > td:nth-child(1) > img',
firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)', firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)',
firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)', firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)',
idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]', idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]',
@ -523,11 +523,11 @@ export default {
searchResultDate: 'vn-ticket-summary [label=Landed] span', searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar', topbarSearch: 'vn-searchbar',
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]', moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)', fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)', fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(6)',
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]', firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) vn-icon-button[icon="delete"]',
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) [ng-model="weekly.agencyModeFk"]',
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]' acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
}, },
createTicketView: { createTicketView: {
@ -572,8 +572,8 @@ export default {
submitNotesButton: 'button[type=submit]' submitNotesButton: 'button[type=submit]'
}, },
ticketExpedition: { ticketExpedition: {
firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(1) vn-check[ng-model="expedition.checked"]', firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(2) vn-check[ng-model="expedition.checked"]',
thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(3) vn-check[ng-model="expedition.checked"]', thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(4) vn-check[ng-model="expedition.checked"]',
deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]', deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]',
moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]', moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]',
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]', moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
@ -712,7 +712,7 @@ export default {
problems: 'vn-check[label="With problems"]', problems: 'vn-check[label="With problems"]',
tableButtonSearch: 'vn-button[vn-tooltip="Search"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
moveButton: 'vn-button[vn-tooltip="Future tickets"]', moveButton: 'vn-button[vn-tooltip="Future tickets"]',
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
multiCheck: 'vn-multi-check', multiCheck: 'vn-multi-check',
tableId: 'vn-textfield[name="id"]', tableId: 'vn-textfield[name="id"]',
tableFutureId: 'vn-textfield[name="futureId"]', tableFutureId: 'vn-textfield[name="futureId"]',
@ -736,7 +736,7 @@ export default {
tableButtonSearch: 'vn-button[vn-tooltip="Search"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
moveButton: 'vn-button[vn-tooltip="Advance tickets"]', moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
acceptButton: '.vn-confirm.shown button[response="accept"]', acceptButton: '.vn-confirm.shown button[response="accept"]',
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
tableId: 'vn-textfield[name="id"]', tableId: 'vn-textfield[name="id"]',
tableFutureId: 'vn-textfield[name="futureId"]', tableFutureId: 'vn-textfield[name="futureId"]',
tableLiters: 'vn-textfield[name="liters"]', tableLiters: 'vn-textfield[name="liters"]',
@ -810,7 +810,7 @@ export default {
claimAction: { claimAction: {
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
anyLine: 'vn-claim-action vn-tbody > vn-tr', anyLine: 'vn-claim-action vn-tbody > vn-tr',
firstDeleteLine: 'vn-claim-action tr:nth-child(1) vn-icon-button[icon="delete"]', firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
}, },
ordersIndex: { ordersIndex: {
@ -1216,7 +1216,7 @@ export default {
addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]', addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]',
itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]', itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]',
itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]', itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]',
firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)', firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(2)',
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check', allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]', secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]', editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',

View File

@ -19,15 +19,14 @@ describe('SmartTable SearchBar integration', () => {
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton); await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium'); await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
await page.waitToClick(selectors.itemsIndex.advancedSearchButton); await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
await page.reload({ await page.reload({
waitUntil: 'networkidle2' waitUntil: 'networkidle2'
}); });
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
await page.waitToClick(selectors.itemsIndex.advancedSmartTableButton);
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1'); await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
@ -36,7 +35,7 @@ describe('SmartTable SearchBar integration', () => {
waitUntil: 'networkidle2' waitUntil: 'networkidle2'
}); });
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
}); });
it('should filter in section without smart-table and search in searchBar go to zone section', async() => { it('should filter in section without smart-table and search in searchBar go to zone section', async() => {

View File

@ -19,7 +19,7 @@ describe('Client defaulter path', () => {
it('should count the amount of clients in the turns section', async() => { it('should count the amount of clients in the turns section', async() => {
const result = await page.countElement(selectors.clientDefaulter.anyClient); const result = await page.countElement(selectors.clientDefaulter.anyClient);
expect(result).toEqual(5); expect(result).toEqual(6);
}); });
it('should check contain expected client', async() => { it('should check contain expected client', async() => {

View File

@ -18,11 +18,11 @@ describe('Item summary path', () => {
await page.doSearch('Ranged weapon'); await page.doSearch('Ranged weapon');
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon');
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
const isVisible = await page.isVisible(selectors.itemSummary.basicData); const isVisible = await page.isVisible(selectors.itemSummary.basicData);
expect(resultsCount).toBe(3); expect(resultsCount).toBe(4);
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
}); });
@ -66,7 +66,7 @@ describe('Item summary path', () => {
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
expect(resultsCount).toBe(2); expect(resultsCount).toBe(3);
}); });
it(`should now check the item summary preview shows fields from basic data`, async() => { it(`should now check the item summary preview shows fields from basic data`, async() => {

View File

@ -18,7 +18,7 @@ describe('Item log path', () => {
await page.doSearch('Knowledge artifact'); await page.doSearch('Knowledge artifact');
const nResults = await page.countElement(selectors.itemsIndex.searchResult); const nResults = await page.countElement(selectors.itemsIndex.searchResult);
expect(nResults).toEqual(0); expect(nResults).toEqual(1);
}); });
it('should access to the create item view by clicking the create floating button', async() => { it('should access to the create item view by clicking the create floating button', async() => {

View File

@ -27,6 +27,6 @@ describe('Ticket expeditions and log path', () => {
const result = await page const result = await page
.countElement(selectors.ticketExpedition.expeditionRow); .countElement(selectors.ticketExpedition.expeditionRow);
expect(result).toEqual(3); expect(result).toEqual(4);
}); });
}); });

View File

@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => {
it('should count the amount of tickets in the turns section', async() => { it('should count the amount of tickets in the turns section', async() => {
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(6); expect(result).toEqual(7);
}); });
it('should go back to the ticket index then search and access a ticket summary', async() => { it('should go back to the ticket index then search and access a ticket summary', async() => {
@ -89,7 +89,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch('11'); await page.doSearch('11');
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(nResults).toEqual(1); expect(nResults).toEqual(2);
}); });
it('should delete the weekly ticket 11', async() => { it('should delete the weekly ticket 11', async() => {
@ -104,7 +104,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch(); await page.doSearch();
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(nResults).toEqual(6); expect(nResults).toEqual(7);
}); });
it('should update the agency then remove it afterwards', async() => { it('should update the agency then remove it afterwards', async() => {

View File

@ -29,7 +29,7 @@ describe('Ticket expeditions', () => {
const result = await page const result = await page
.countElement(selectors.ticketExpedition.expeditionRow); .countElement(selectors.ticketExpedition.expeditionRow);
expect(result).toEqual(1); expect(result).toEqual(2);
}); });
it(`should move one expedition to new ticket with route`, async() => { it(`should move one expedition to new ticket with route`, async() => {
@ -45,6 +45,6 @@ describe('Ticket expeditions', () => {
const result = await page const result = await page
.countElement(selectors.ticketExpedition.expeditionRow); .countElement(selectors.ticketExpedition.expeditionRow);
expect(result).toEqual(1); expect(result).toEqual(2);
}); });
}); });

View File

@ -87,7 +87,7 @@ describe('Ticket Future path', () => {
await page.clearInput(selectors.ticketFuture.futureState); await page.clearInput(selectors.ticketFuture.futureState);
await page.waitToClick(selectors.ticketFuture.submit); await page.waitToClick(selectors.ticketFuture.submit);
await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4); await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 5);
await page.waitToClick(selectors.ticketFuture.multiCheck); await page.waitToClick(selectors.ticketFuture.multiCheck);
await page.waitToClick(selectors.ticketFuture.firstCheck); await page.waitToClick(selectors.ticketFuture.firstCheck);
await page.waitToClick(selectors.ticketFuture.moveButton); await page.waitToClick(selectors.ticketFuture.moveButton);

View File

@ -40,6 +40,8 @@ export default class SmartTable extends Component {
this._options = options; this._options = options;
if (!options) return; if (!options) return;
options.defaultSearch = true;
if (options.defaultSearch) if (options.defaultSearch)
this.displaySearch(); this.displaySearch();

View File

@ -19,8 +19,7 @@ export default class Controller {
this.repeatPassword = 'test.1234'; this.repeatPassword = 'test.1234';
this.newPassword = 'test.1234'; this.newPassword = 'test.1234';
this.verificationCode = '1234'; this.verificationCode = '1234';
if (!this.$state.params.id)
if (!this.$state.params || !this.$state.params.id || !this.$state.params.token)
this.$state.go('login'); this.$state.go('login');
this.$http.get('UserPasswords/findOne') this.$http.get('UserPasswords/findOne')
@ -30,7 +29,7 @@ export default class Controller {
} }
submit() { submit() {
const id = this.$state.params.id; const userId = this.$state.params.userId;
const oldPassword = this.oldPassword; const oldPassword = this.oldPassword;
const newPassword = this.newPassword; const newPassword = this.newPassword;
const repeatPassword = this.repeatPassword; const repeatPassword = this.repeatPassword;
@ -44,7 +43,7 @@ export default class Controller {
throw new UserError(`You can't use the same password`); throw new UserError(`You can't use the same password`);
const headers = { const headers = {
Authorization: this.$state.params.token Authorization: this.$state.params.id
}; };
console.log({ console.log({
id, id,
@ -54,6 +53,7 @@ export default class Controller {
}); });
this.$http.patch('Accounts/change-password', this.$http.patch('Accounts/change-password',
{ {
id: userId,
oldPassword, oldPassword,
newPassword, newPassword,
verificationCode verificationCode

View File

@ -34,11 +34,9 @@ export default class Controller {
return; return;
} }
if (req?.data?.error?.code == 'passExpired') { const err = req.data?.error;
const [args] = req.data.error.translateArgs; if (err?.code == 'passExpired')
this.$state.go('change-password', args); this.$state.go('change-password', err.details.token);
return;
}
this.loading = false; this.loading = false;
this.password = ''; this.password = '';

View File

@ -44,7 +44,7 @@ function config($stateProvider, $urlRouterProvider) {
}) })
.state('change-password', { .state('change-password', {
parent: 'outLayout', parent: 'outLayout',
url: '/change-password?id&token&twoFactor', url: '/change-password?id&userId&twoFactor',
description: 'Change password', description: 'Change password',
template: '<vn-change-password></vn-change-password>' template: '<vn-change-password></vn-change-password>'
}) })

View File

@ -174,5 +174,6 @@
"A claim with that sale already exists": "A claim with that sale already exists", "A claim with that sale already exists": "A claim with that sale already exists",
"Pass expired": "The password has expired, change it from Salix", "Pass expired": "The password has expired, change it from Salix",
"Can't transfer claimed sales": "Can't transfer claimed sales", "Can't transfer claimed sales": "Can't transfer claimed sales",
"Invalid quantity": "Invalid quantity" "Invalid quantity": "Invalid quantity",
"Failed to upload delivery note": "Error to upload delivery note {{id}}"
} }

View File

@ -258,7 +258,7 @@
"App name does not exist": "El nombre de aplicación no es válido", "App name does not exist": "El nombre de aplicación no es válido",
"Try again": "Vuelve a intentarlo", "Try again": "Vuelve a intentarlo",
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
"Failed to upload file": "Error al subir archivo", "Failed to upload delivery note": "Error al subir albarán {{id}}",
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",

View File

@ -0,0 +1,3 @@
name: account
columns:
id: id

View File

@ -0,0 +1,3 @@
name: cuenta
columns:
id: id

View File

@ -0,0 +1,5 @@
name: mail alias
columns:
id: id
mailAlias: alias
account: account

View File

@ -0,0 +1,5 @@
name: alias de correo
columns:
id: id
mailAlias: alias
account: cuenta

View File

@ -5,8 +5,7 @@ import UserError from 'core/lib/user-error';
export default class Controller extends Section { export default class Controller extends Section {
onSynchronizeAll() { onSynchronizeAll() {
this.vnApp.showSuccess(this.$t('Synchronizing in the background')); this.vnApp.showSuccess(this.$t('Synchronizing in the background'));
this.$http.patch(`Accounts/syncAll`) this.$http.patch(`Accounts/syncAll`);
.then(() => this.vnApp.showSuccess(this.$t('Users synchronized!')));
} }
onUserSync() { onUserSync() {

View File

@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
const base64url = require('base64url'); const base64url = require('base64url');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('confirm', { Self.remoteMethod('confirm', {
description: 'Confirms electronic payment transaction', description: 'Confirms electronic payment transaction',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [ accepts: [
@ -30,7 +30,7 @@ module.exports = Self => {
} }
}); });
Self.confirm = async(ctx, signatureVersion, merchantParameters, signature) => { Self.confirm = async(signatureVersion, merchantParameters, signature) => {
const $ = Self.app.models; const $ = Self.app.models;
let transaction; let transaction;
@ -83,7 +83,7 @@ module.exports = Self => {
params['Ds_Currency'], params['Ds_Currency'],
params['Ds_Response'], params['Ds_Response'],
params['Ds_ErrorCode'] params['Ds_ErrorCode']
], {userId: ctx.req.accessToken.userId}); ]);
return true; return true;
} catch (err) { } catch (err) {

View File

@ -46,7 +46,7 @@ module.exports = Self => {
} }
try { try {
let buy = await models.Buy.findOne({where: {entryFk: args.id}}, myOptions); let buy = await models.Buy.findOne({where: {entryFk: args.id, itemFk: args.item}}, myOptions);
if (buy) if (buy)
await buy.updateAttribute('printedStickers', args.printedStickers, myOptions); await buy.updateAttribute('printedStickers', args.printedStickers, myOptions);
else { else {

View File

@ -118,7 +118,8 @@
label="Company" label="Company"
show-field="code" show-field="code"
value-field="id" value-field="id"
ng-model="$ctrl.companyFk"> ng-model="$ctrl.companyFk"
on-change="$ctrl.getInvoiceDate(value)">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete <vn-autocomplete
url="Printers" url="Printers"

View File

@ -7,23 +7,29 @@ class Controller extends Section {
$onInit() { $onInit() {
const date = Date.vnNew(); const date = Date.vnNew();
Object.assign(this, { Object.assign(this, {
maxShipped: new Date(date.getFullYear(), date.getMonth(), 0), maxShipped: new Date(date.getFullYear(), date.getMonth(), 0),
clientsToInvoice: 'all', clientsToInvoice: 'all',
}); });
this.$http.get('UserConfigs/getUserConfig') this.$http.get('UserConfigs/getUserConfig')
.then(res => { .then(res => {
this.companyFk = res.data.companyFk; this.companyFk = res.data.companyFk;
const params = { this.getInvoiceDate(this.companyFk);
companyFk: this.companyFk });
}; }
return this.$http.get('InvoiceOuts/getInvoiceDate', {params});
}) getInvoiceDate(companyFk) {
.then(res => { const params = { companyFk: companyFk };
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; this.fetchInvoiceDate(params);
this.invoiceDate = this.minInvoicingDate; }
});
} fetchInvoiceDate(params) {
this.$http.get('InvoiceOuts/getInvoiceDate', { params })
.then(res => {
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
this.invoiceDate = this.minInvoicingDate;
});
}
stopInvoicing() { stopInvoicing() {
this.status = 'stopping'; this.status = 'stopping';
@ -42,7 +48,7 @@ class Controller extends Section {
throw new UserError('Invoice date and the max date should be filled'); throw new UserError('Invoice date and the max date should be filled');
if (this.invoiceDate < this.maxShipped) if (this.invoiceDate < this.maxShipped)
throw new UserError('Invoice date can\'t be less than max date'); throw new UserError('Invoice date can\'t be less than max date');
if (this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
throw new UserError('Exists an invoice with a previous date'); throw new UserError('Exists an invoice with a previous date');
if (!this.companyFk) if (!this.companyFk)
throw new UserError('Choose a valid company'); throw new UserError('Choose a valid company');

View File

@ -19,7 +19,8 @@ export default class Controller extends Section {
this.smartTableOptions = { this.smartTableOptions = {
activeButtons: { activeButtons: {
search: true, search: true,
}, columns: [ },
columns: [
{ {
field: 'isActive', field: 'isActive',
searchable: false searchable: false

View File

@ -13,7 +13,6 @@ export default class Controller extends Section {
activeButtons: { activeButtons: {
search: true search: true
}, },
defaultSearch: true,
columns: [ columns: [
{ {
field: 'warehouseFk', field: 'warehouseFk',

View File

@ -1,6 +1,21 @@
<vn-auto-search <vn-auto-search
model="model"> model="model">
</vn-auto-search> </vn-auto-search>
<vn-crud-model
auto-load="true"
url="AgencyModes"
data="agencyModes">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="Vehicles"
data="vehicles">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="Workers/activeWithInheritedRole"
data="activeWithInheritedRole">
</vn-crud-model>
<div class="vn-w-xl"> <div class="vn-w-xl">
<vn-card> <vn-card>
<smart-table <smart-table
@ -83,7 +98,7 @@
<td> <td>
<vn-autocomplete <vn-autocomplete
ng-model="route.workerFk" ng-model="route.workerFk"
url="Workers/activeWithInheritedRole" data="activeWithInheritedRole"
show-field="nickname" show-field="nickname"
search-function="{firstName: $search}" search-function="{firstName: $search}"
value-field="id" value-field="id"
@ -98,7 +113,7 @@
<td expand> <td expand>
<vn-autocomplete <vn-autocomplete
ng-model="route.agencyModeFk" ng-model="route.agencyModeFk"
url="AgencyModes" data="agencyModes"
show-field="name" show-field="name"
value-field="id" value-field="id"
on-change="$ctrl.updateAttributes(route)" on-change="$ctrl.updateAttributes(route)"
@ -108,7 +123,7 @@
<td expand> <td expand>
<vn-autocomplete <vn-autocomplete
ng-model="route.vehicleFk" ng-model="route.vehicleFk"
url="Vehicles" data="vehicles"
show-field="numberPlate" show-field="numberPlate"
value-field="id" value-field="id"
on-change="$ctrl.updateAttributes(route)" on-change="$ctrl.updateAttributes(route)"

View File

@ -26,14 +26,14 @@ module.exports = Self => {
Self.getItemsPackaging = async(id, entry) => { Self.getItemsPackaging = async(id, entry) => {
return Self.rawSql(` return Self.rawSql(`
WITH entryTmp AS ( WITH entryTmp AS (
SELECT i.id, SUM(b.quantity) quantity SELECT i.id, SUM(b.quantity) quantity, SUM(b.printedStickers) printedStickers
FROM vn.entry e FROM vn.entry e
JOIN vn.buy b ON b.entryFk = e.id JOIN vn.buy b ON b.entryFk = e.id
JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.supplier s ON s.id = e.supplierFk
JOIN vn.item i ON i.id = b.itemFk JOIN vn.item i ON i.id = b.itemFk
WHERE e.id = ? AND e.supplierFk = ? WHERE e.id = ? AND e.supplierFk = ?
GROUP BY i.id GROUP BY i.id
) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers
FROM vn.buy b FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk JOIN vn.item i ON i.id = b.itemFk
JOIN vn.entry e ON e.id = b.entryFk JOIN vn.entry e ON e.id = b.entryFk

View File

@ -2,14 +2,17 @@ name: request
columns: columns:
id: id id: id
description: description description: description
created: created buyerCode: buyer
quantity: quantity quantity: quantity
price: price price: price
isOk: ok
response: response
saleFk: sale
ticketFk: ticket
attenderFk: attender
requesterFk: requester
itemFk: item itemFk: item
clientFk: client
response: response
total: total
buyed: buyed
saleFk: sale
created: created
isOk: ok
requesterFk: requester
attenderFk: attender
ticketFk: ticket

View File

@ -1,15 +1,18 @@
name: peticion name: petición
columns: columns:
id: id id: id
description: descripción description: descripción
created: creado buyerCode: comprador
quantity: cantidad quantity: cantidad
price: precio price: precio
isOk: ok
response: respuesta
saleFk: línea
ticketFk: ticket
attenderFk: asistente
requesterFk: solicitante
itemFk: artículo itemFk: artículo
clientFk: cliente
response: respuesta
total: total
buyed: comprado
saleFk: línea
created: creado
isOk: ok
requesterFk: solicitante
attenderFk: asistente
ticketFk: ticket

View File

@ -100,5 +100,8 @@
}, },
"TicketConfig": { "TicketConfig": {
"dataSource": "vn" "dataSource": "vn"
},
"PackingSiteAdvanced": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,18 @@
{
"name": "PackingSiteAdvanced",
"base": "VnModel",
"options": {
"mysql": {
"table": "packingSiteAdvanced"
}
},
"properties": {
"ticketFk": {
"id": true,
"type": "number"
},
"workerFk": {
"type": "number"
}
}
}

View File

@ -326,14 +326,8 @@ class Controller extends Section {
if (!force) if (!force)
return this.$.pdfToTablet.show(); return this.$.pdfToTablet.show();
return this.$http.post(`Docuwares/${this.id}/upload`, {fileCabinet: 'deliveryNote'}) return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds: [this.id]})
.then(() => { .then(() => {
this.$.balanceCreate.amountPaid = this.ticket.totalWithVat;
this.$.balanceCreate.clientFk = this.ticket.clientFk;
this.$.balanceCreate.description = 'Albaran: ';
this.$.balanceCreate.description += this.ticket.id;
this.$.balanceCreate.show();
this.vnApp.showSuccess(this.$t('PDF sent!')); this.vnApp.showSuccess(this.$t('PDF sent!'));
}); });
} }

View File

@ -304,17 +304,15 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
expect(controller.$.pdfToTablet.show).toHaveBeenCalled(); expect(controller.$.pdfToTablet.show).toHaveBeenCalled();
}); });
it('should make a query and show balance create', () => { it('should make a query', () => {
controller.$.balanceCreate = {show: () => {}}; controller.$.balanceCreate = {show: () => {}};
jest.spyOn(controller.$.balanceCreate, 'show');
jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.whenPOST(`Docuwares/${ticket.id}/upload`).respond(true); $httpBackend.whenPOST(`Docuwares/upload`).respond(true);
controller.uploadDocuware(true); controller.uploadDocuware(true);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.balanceCreate.show).toHaveBeenCalled();
}); });
}); });

View File

@ -152,21 +152,21 @@
</vn-data-viewer> </vn-data-viewer>
<div fixed-bottom-right> <div fixed-bottom-right>
<vn-vertical style="align-items: center;"> <vn-vertical style="align-items: center;">
<vn-button class="round sm vn-mb-sm" <vn-button class="round vn-mb-sm"
icon="print" icon="install_mobile"
ng-show="$ctrl.totalChecked > 0" ng-show="$ctrl.totalChecked > 0"
ng-click="$ctrl.setDelivered()" ng-click="$ctrl.sendDocuware()"
vn-tooltip="Set as delivered and open delivery note(s)" vn-tooltip="Set as delivered and open delivery note(s)"
tooltip-position="left"> tooltip-position="left">
</vn-button> </vn-button>
<vn-button class="round sm vn-mb-sm" <vn-button class="round vn-mb-sm"
icon="icon-recovery" icon="icon-recovery"
ng-show="$ctrl.totalChecked > 0" ng-show="$ctrl.totalChecked > 0"
ng-click="$ctrl.openBalanceDialog()" ng-click="$ctrl.openBalanceDialog()"
vn-tooltip="Payment on account..." vn-tooltip="Payment on account..."
tooltip-position="left"> tooltip-position="left">
</vn-button> </vn-button>
<vn-button class="round sm vn-mb-sm" <vn-button class="round vn-mb-sm"
icon="icon-invoice" icon="icon-invoice"
ng-click="makeInvoiceConfirmation.show()" ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.totalChecked > 0" ng-show="$ctrl.totalChecked > 0"

View File

@ -9,28 +9,23 @@ export default class Controller extends Section {
this.vnReport = vnReport; this.vnReport = vnReport;
} }
setDelivered() { sendDocuware() {
const checkedTickets = this.checked; const checkedTickets = this.checked;
let ids = []; let ticketIds = [];
for (let ticket of checkedTickets) for (let ticket of checkedTickets)
ids.push(ticket.id); ticketIds.push(ticket.id);
this.$http.post('TicketTrackings/setDelivered', ids).then(res => { return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds})
let state = res.data; .then(res => {
for (let ticket of checkedTickets) { let state = res.data;
ticket.stateFk = state.id; for (let ticket of checkedTickets) {
ticket.state = state.name; ticket.stateFk = state.id;
ticket.alertLevel = state.alertLevel; ticket.state = state.name;
ticket.alertLevelCode = state.code; ticket.alertLevel = state.alertLevel;
} ticket.alertLevelCode = state.code;
this.openDeliveryNotes(ids); }
}); });
}
openDeliveryNotes(ids) {
for (let id of ids)
this.vnReport.show(`Tickets/${id}/delivery-note-pdf`);
} }
openBalanceDialog() { openBalanceDialog() {

View File

@ -12,12 +12,14 @@ describe('Component vnTicketIndex', () => {
id: 2, id: 2,
clientFk: 1, clientFk: 1,
checked: true, checked: true,
totalWithVat: 20.5 totalWithVat: 20.5,
stateFk: 1
}, { }, {
id: 3, id: 3,
clientFk: 1, clientFk: 1,
checked: true, checked: true,
totalWithVat: 30 totalWithVat: 30,
stateFk: 1
}]; }];
beforeEach(ngModule('ticket')); beforeEach(ngModule('ticket'));
@ -86,18 +88,16 @@ describe('Component vnTicketIndex', () => {
}); });
}); });
describe('setDelivered()/openDeliveryNotes()', () => { describe('sendDocuware()', () => {
it('should perform a post to setDelivered and open tabs with the delivery notes', () => { it('should perform a post to sendDocuware and change tickets state', () => {
controller.$.model = {data: tickets, refresh: () => {}}; controller.$.model = {data: tickets, refresh: () => {}};
const newState = {id: 2};
$window.open = jest.fn(); $httpBackend.expect('POST', 'Docuwares/upload').respond({id: newState.id});
controller.sendDocuware();
$httpBackend.expect('POST', 'TicketTrackings/setDelivered').respond('ok');
controller.setDelivered();
$httpBackend.flush(); $httpBackend.flush();
expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[1].id}/delivery-note-pdf`); expect(controller.$.model.data[1].stateFk).toEqual(newState.id);
expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[2].id}/delivery-note-pdf`);
}); });
}); });

View File

@ -1,14 +1,14 @@
name: zone event name: event
columns: columns:
id: id id: id
zoneFk: zone zoneFk: zone
type: type type: type
dated: dated dated: dated
started: started started: starts
ended: ended ended: ends
weekDays: week days weekDays: week days
hour: hour hour: hour
travelingDays: traveling days travelingDays: traveling days
price: price price: price
bonus: bonus bonus: bonus
m3Max: max m3 m3Max: max. m3

View File

@ -1,11 +1,11 @@
name: evento zona name: evento
columns: columns:
id: id id: id
zoneFk: zona zoneFk: zona
type: tipo type: tipo
dated: fecha dated: fecha
started: comenzado started: empieza
ended: terminado ended: termina
weekDays: días semana weekDays: días semana
hour: hora hour: hora
travelingDays: días de viaje travelingDays: días de viaje

View File

@ -1,5 +1,5 @@
name: zone exclusion name: exclusion
columns: columns:
id: id id: id
dated: dated dated: date
zoneFk: zone zoneFk: zone

View File

@ -1,4 +1,4 @@
name: zone exclusion name: exclusión
columns: columns:
id: id id: id
dated: fecha dated: fecha

View File

@ -1,5 +1,7 @@
name: zone included name: inclusion
columns: columns:
id: id id: id
dated: dated dated: dated
zoneFk: zone zoneFk: zone
isIncluded: incluida
geoFk: localización

View File

@ -1,5 +1,7 @@
name: zona incluida name: inclusión
columns: columns:
id: id id: id
dated: fecha dated: fecha
zoneFk: zona zoneFk: zona
isIncluded: incluida
geoFk: localización

View File

@ -1,4 +1,4 @@
name: zone warehouse name: warehouse
columns: columns:
id: id id: id
warehouseFk: warehouse warehouseFk: warehouse

View File

@ -1,4 +1,4 @@
name: almacén zona name: almacén
columns: columns:
id: id id: id
warehouseFk: almacén warehouseFk: almacén

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "23.24.01", "version": "23.26.01",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -0,0 +1,11 @@
const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/email.css`])
.mergeStyles();

View File

@ -0,0 +1,3 @@
subject: Modified entry
title: Modified entry
description: From Warehouse the following packaging entry has been created/modified

View File

@ -0,0 +1,3 @@
subject: Entrada modificada
title: Entrada modificada
description: Desde Almacén se ha creado/modificado la siguiente entrada de embalajes

View File

@ -0,0 +1,11 @@
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
<p>
{{ $t('description') }}:
<a :href="url">{{ url }}</a>
</p>
</div>
</div>
</email-body>

View File

@ -0,0 +1,16 @@
const Component = require(`vn-print/core/component`);
const emailBody = new Component('email-body');
module.exports = {
name: 'modified-entry',
components: {
'email-body': emailBody.build(),
},
props: {
url: {
type: String,
required: true
}
}
};