Merge branch 'dev' into 5635-contadotTicketExpedition
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
c9bf74dcc4
|
@ -1,6 +1,6 @@
|
|||
extends: [eslint:recommended, google, plugin:jasmine/recommended]
|
||||
parserOptions:
|
||||
ecmaVersion: 2018
|
||||
ecmaVersion: 2020
|
||||
sourceType: "module"
|
||||
plugins:
|
||||
- jasmine
|
||||
|
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -5,14 +5,27 @@ 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/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2326.01] - 2023-06-29
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
-
|
||||
|
||||
## [2324.01] - 2023-06-08
|
||||
|
||||
### Added
|
||||
-
|
||||
|
||||
- (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén
|
||||
- (General -> Desplegables) Mejorada eficiencia de carga de datos
|
||||
- (General -> Históricos) Ahora, ademas de los ids, se muestra la descripión de los atributos
|
||||
- (General -> Históricos) Botón para hacer más ágil mostrar sólo los cambios en un registro
|
||||
- (General -> Históricos) Filtro por cambios
|
||||
|
||||
### Changed
|
||||
-
|
||||
- (General -> Permisos) Mejorada seguridad
|
||||
- (General -> Históricos) Elementos de la interfaz reorganizados para hacerla más ágil e intuitiva
|
||||
|
||||
### Fixed
|
||||
-
|
||||
|
|
|
@ -11,9 +11,9 @@ RUN apt-get update \
|
|||
ca-certificates \
|
||||
gnupg2 \
|
||||
graphicsmagick \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& npm install -g npm@8.19.2
|
||||
&& npm install -g npm@9.6.6
|
||||
|
||||
# Puppeteer
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ pipeline {
|
|||
NODE_ENV = ""
|
||||
}
|
||||
steps {
|
||||
nodejs('node-v14') {
|
||||
nodejs('node-v20') {
|
||||
sh 'npm install --no-audit --prefer-offline'
|
||||
sh 'gulp install --ci'
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ pipeline {
|
|||
parallel {
|
||||
stage('Frontend') {
|
||||
steps {
|
||||
nodejs('node-v14') {
|
||||
nodejs('node-v20') {
|
||||
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Backend') {
|
||||
steps {
|
||||
nodejs('node-v14') {
|
||||
nodejs('node-v20') {
|
||||
sh 'npm run test:back:ci'
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ pipeline {
|
|||
CREDENTIALS = credentials('docker-registry')
|
||||
}
|
||||
steps {
|
||||
nodejs('node-v14') {
|
||||
nodejs('node-v20') {
|
||||
sh 'gulp build'
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ module.exports = Self => {
|
|||
|
||||
Self.newCollection = async(ctx, collectionFk, sectorFk, vWagons) => {
|
||||
let query = '';
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
if (!collectionFk) {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
query = `CALL vn.collectionTrain_newBeta(?,?,?)`;
|
||||
const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId]);
|
||||
const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId], {userId});
|
||||
if (result.length == 0)
|
||||
throw new Error(`No collections for today`);
|
||||
|
||||
|
@ -42,16 +42,16 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
query = `CALL vn.collectionTicket_get(?)`;
|
||||
const [tickets] = await Self.rawSql(query, [collectionFk]);
|
||||
const [tickets] = await Self.rawSql(query, [collectionFk], {userId});
|
||||
|
||||
query = `CALL vn.collectionSale_get(?)`;
|
||||
const [sales] = await Self.rawSql(query, [collectionFk]);
|
||||
const [sales] = await Self.rawSql(query, [collectionFk], {userId});
|
||||
|
||||
query = `CALL vn.collectionPlacement_get(?)`;
|
||||
const [placements] = await Self.rawSql(query, [collectionFk]);
|
||||
const [placements] = await Self.rawSql(query, [collectionFk], {userId});
|
||||
|
||||
query = `CALL vn.collectionSticker_print(?,?)`;
|
||||
await Self.rawSql(query, [collectionFk, sectorFk]);
|
||||
await Self.rawSql(query, [collectionFk, sectorFk], {userId});
|
||||
|
||||
return makeCollection(tickets, sales, placements, collectionFk);
|
||||
};
|
||||
|
|
|
@ -16,14 +16,14 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.updateData = async() => {
|
||||
Self.updateData = async ctx => {
|
||||
const models = Self.app.models;
|
||||
|
||||
// Get files checksum
|
||||
const tx = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
||||
|
||||
const updatableFiles = [];
|
||||
|
|
|
@ -1,26 +1,18 @@
|
|||
FROM mariadb:10.7.5
|
||||
FROM mariadb:10.7.7
|
||||
|
||||
ENV MYSQL_ROOT_PASSWORD root
|
||||
ENV TZ Europe/Madrid
|
||||
ARG MOCKDATE=2001-01-01 11:00:00
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
||||
&& curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
|
||||
&& echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y vn-mariadb \
|
||||
&& apt-get purge -y --auto-remove curl ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY docker/docker.cnf /etc/mysql/conf.d/
|
||||
COPY \
|
||||
docker/docker-start.sh \
|
||||
docker/docker-init.sh \
|
||||
docker/docker-temp-start.sh \
|
||||
docker/docker-temp-stop.sh \
|
||||
docker/docker-dump.sh \
|
||||
docker/docker-start.sh \
|
||||
docker/docker-structure.sh \
|
||||
docker/docker-fixtures.sh \
|
||||
/usr/local/bin/
|
||||
|
||||
RUN mkdir /mysql-data \
|
||||
|
@ -31,26 +23,16 @@ WORKDIR /docker-boot
|
|||
COPY \
|
||||
import-changes.sh \
|
||||
config.ini \
|
||||
dump/mysqlPlugins.sql \
|
||||
dump/structure.sql \
|
||||
dump/mockDate.sql \
|
||||
dump/dumpedFixtures.sql \
|
||||
./
|
||||
RUN gosu mysql docker-init.sh \
|
||||
&& docker-dump.sh mysqlPlugins \
|
||||
&& docker-dump.sh structure \
|
||||
&& sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \
|
||||
&& docker-dump.sh mockDate \
|
||||
&& docker-dump.sh dumpedFixtures \
|
||||
&& gosu mysql docker-temp-stop.sh
|
||||
|
||||
RUN sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \
|
||||
&& gosu mysql docker-structure.sh
|
||||
COPY changes ./changes
|
||||
COPY dump/fixtures.sql ./
|
||||
ARG STAMP=unknown
|
||||
RUN gosu mysql docker-temp-start.sh \
|
||||
&& ./import-changes.sh \
|
||||
&& docker-dump.sh fixtures \
|
||||
&& gosu mysql docker-temp-stop.sh
|
||||
RUN gosu mysql docker-fixtures.sh
|
||||
|
||||
RUN echo "[INFO] -> Import finished" \
|
||||
&& rm -rf /docker-boot
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||
*
|
||||
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||
CREATE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed < vDateFuture
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT
|
||||
origin.ticketFk futureId,
|
||||
dest.ticketFk id,
|
||||
dest.state,
|
||||
origin.futureState,
|
||||
origin.futureIpt,
|
||||
dest.ipt,
|
||||
origin.workerFk,
|
||||
origin.futureLiters,
|
||||
origin.futureLines,
|
||||
dest.shipped,
|
||||
origin.shipped futureShipped,
|
||||
dest.totalWithVat,
|
||||
origin.totalWithVat futureTotalWithVat,
|
||||
dest.agency,
|
||||
origin.futureAgency,
|
||||
dest.lines,
|
||||
dest.liters,
|
||||
origin.futureLines - origin.hasStock AS notMovableLines,
|
||||
(origin.futureLines = origin.hasStock) AS isFullMovable,
|
||||
origin.classColor futureClassColor,
|
||||
dest.classColor
|
||||
FROM (
|
||||
SELECT
|
||||
s.ticketFk,
|
||||
t.workerFk,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
st.name futureState,
|
||||
t.addressFk,
|
||||
am.name futureAgency,
|
||||
count(s.id) futureLines,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock,
|
||||
st.classColor
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = i.id
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) origin
|
||||
JOIN (
|
||||
SELECT
|
||||
t.id ticketFk,
|
||||
t.addressFk,
|
||||
st.name state,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
am.name agency,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(COUNT(*) AS DECIMAL(10,0)) `lines`,
|
||||
st.classColor
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND st.order <= 5
|
||||
GROUP BY t.id
|
||||
) dest ON dest.addressFk = origin.addressFk
|
||||
WHERE origin.hasStock != 0;
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,74 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
|
||||
*
|
||||
* @param vOriginDated Fecha en cuestión
|
||||
* @param vFutureDated Fecha en el futuro a sondear
|
||||
* @param vWarehouseFk Identificador de vn.warehouse
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT sv.ticketFk id,
|
||||
sub2.id futureId,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||
st.name state,
|
||||
sub2.iptd futureIpt,
|
||||
sub2.state futureState,
|
||||
t.clientFk,
|
||||
t.warehouseFk,
|
||||
ts.alertLevel,
|
||||
t.shipped,
|
||||
sub2.shipped futureShipped,
|
||||
t.workerFk,
|
||||
st.code stateCode,
|
||||
sub2.code futureStateCode,
|
||||
st.classColor,
|
||||
sub2.classColor futureClassColor
|
||||
FROM vn.saleVolume sv
|
||||
JOIN vn.sale s ON s.id = sv.saleFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p.countryFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.alertLevel al ON al.id = ts.alertLevel
|
||||
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
t.addressFk,
|
||||
t.id,
|
||||
t.shipped,
|
||||
st.name state,
|
||||
st.code,
|
||||
st.classColor,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE t.shipped BETWEEN vFutureDated
|
||||
AND util.dayend(vFutureDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) sub
|
||||
GROUP BY sub.addressFk
|
||||
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||
WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND al.code = 'FREE'
|
||||
AND tp.ticketFk IS NULL
|
||||
GROUP BY sv.ticketFk
|
||||
HAVING futureId;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`ticket` MODIFY COLUMN warehouseFk smallint(6) unsigned DEFAULT NULL NULL;
|
|
@ -5,3 +5,6 @@ CMD=mysqld
|
|||
|
||||
docker_setup_env "$CMD"
|
||||
docker_temp_server_start "$CMD"
|
||||
bash import-changes.sh
|
||||
docker-dump.sh fixtures
|
||||
docker_temp_server_stop
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
. docker-init.sh
|
||||
docker-dump.sh structure
|
||||
docker-dump.sh mockDate
|
||||
docker-dump.sh dumpedFixtures
|
||||
. docker-temp-stop.sh
|
|
@ -2786,7 +2786,9 @@ INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldIns
|
|||
(7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL),
|
||||
(7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL),
|
||||
(7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL),
|
||||
(7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'");
|
||||
(7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"),
|
||||
(16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 5689, 'Shield');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description)
|
||||
VALUES
|
||||
|
@ -2800,7 +2802,6 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM
|
|||
(1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL),
|
||||
(1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 5689, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL),
|
||||
(1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL);
|
||||
|
||||
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', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
-- Import compiled functions
|
||||
CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so';
|
||||
CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so';
|
|
@ -595,6 +595,8 @@ export default {
|
|||
moreMenuUpdateDiscount: 'vn-item[name="discount"]',
|
||||
moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]',
|
||||
moreMenuRefund: 'vn-item[name="refund"]',
|
||||
refundWithWarehouse: 'vn-item[name="refundWithWarehouse"]',
|
||||
refundWithoutWarehouse: 'vn-item[name="refundWithoutWarehouse"]',
|
||||
moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input',
|
||||
transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text',
|
||||
transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',
|
||||
|
|
|
@ -220,14 +220,25 @@ describe('Ticket Edit sale path', () => {
|
|||
|
||||
it('should log in as salesAssistant and navigate to ticket sales', async() => {
|
||||
await page.loginAndModule('salesAssistant', 'ticket');
|
||||
await page.accessToSearchResult('16');
|
||||
await page.accessToSearchResult('17');
|
||||
await page.accessToSection('ticket.card.sale');
|
||||
});
|
||||
|
||||
it('should select the third sale and create a refund', async() => {
|
||||
it('should select the first sale and create a refund with warehouse', async() => {
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenuRefund);
|
||||
await page.waitToClick(selectors.ticketSales.refundWithWarehouse);
|
||||
await page.waitForSnackbar();
|
||||
await page.waitForState('ticket.card.sale');
|
||||
});
|
||||
|
||||
it('should select the first sale and create a refund without warehouse', async() => {
|
||||
await page.accessToSearchResult('18');
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenuRefund);
|
||||
await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse);
|
||||
await page.waitForSnackbar();
|
||||
await page.waitForState('ticket.card.sale');
|
||||
});
|
||||
|
@ -246,7 +257,6 @@ describe('Ticket Edit sale path', () => {
|
|||
it('should select the third sale and create a claim of it', async() => {
|
||||
await page.accessToSearchResult('16');
|
||||
await page.accessToSection('ticket.card.sale');
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
|
||||
|
|
|
@ -49,7 +49,11 @@ describe('Claim summary path', () => {
|
|||
});
|
||||
|
||||
it(`should click on the first sale ID making the item descriptor visible`, async() => {
|
||||
await page.waitToClick(selectors.claimSummary.firstSaleItemId);
|
||||
const firstItem = selectors.claimSummary.firstSaleItemId;
|
||||
await page.evaluate(selectors => {
|
||||
document.querySelector(selectors).scrollIntoView();
|
||||
}, firstItem);
|
||||
await page.click(firstItem);
|
||||
await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage);
|
||||
const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover);
|
||||
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
@import "./variables";
|
||||
@import "./effects";
|
||||
|
||||
@mixin mobile {
|
||||
@media screen and (max-width: $mobile-width) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
@mixin browser($browser) {
|
||||
html[data-browser*="#{$browser}"] & {
|
||||
@content;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
@import "./util";
|
||||
|
||||
$font-size: 11pt;
|
||||
$menu-width: 256px;
|
||||
$topbar-height: 56px;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import "variables";
|
||||
@import "util";
|
||||
|
||||
@keyframes fadein {
|
||||
from {
|
||||
|
@ -16,7 +16,7 @@ vn-background {
|
|||
background-color: black;
|
||||
z-index: 14;
|
||||
|
||||
@media screen and (max-width: $mobile-width) {
|
||||
@include mobile {
|
||||
&.shown {
|
||||
display: block;
|
||||
opacity: .3;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import "effects";
|
||||
@import "util";
|
||||
|
||||
vn-layout {
|
||||
& > vn-topbar {
|
||||
|
@ -134,7 +134,7 @@ vn-layout {
|
|||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: $mobile-width) {
|
||||
@include mobile {
|
||||
& > vn-topbar {
|
||||
& > .start > .logo {
|
||||
display: none;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</vn-crud-model>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-sm vn-px-sm">
|
||||
class="vn-w-sm vn-px-sm vn-pb-xl">
|
||||
<div class="change vn-mb-sm" ng-repeat="log in $ctrl.logs">
|
||||
<div class="left">
|
||||
<vn-avatar class="vn-mt-xs"
|
||||
|
@ -33,17 +33,6 @@
|
|||
</div>
|
||||
<vn-card class="detail">
|
||||
<div class="header vn-pa-sm">
|
||||
<div
|
||||
class="action-date text-secondary text-caption vn-mr-sm"
|
||||
title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}">
|
||||
<vn-icon
|
||||
class="action vn-mr-xs"
|
||||
ng-class="::$ctrl.actionsClass[log.action]"
|
||||
icon="{{::$ctrl.actionsIcon[log.action]}}"
|
||||
translate-attr="::{title: $ctrl.actionsText[log.action]}">
|
||||
</vn-icon>
|
||||
{{::$ctrl.relativeDate(log.creationDate)}}
|
||||
</div>
|
||||
<div class="action-model">
|
||||
<span class="model-name"
|
||||
ng-if="::$ctrl.showModelName && log.changedModel"
|
||||
|
@ -52,13 +41,27 @@
|
|||
{{::log.changedModelI18n}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="model vn-pb-sm vn-px-sm"
|
||||
title="{{::log.changedModelValue}}"
|
||||
ng-if="::log.changedModelId || log.changedModelValue">
|
||||
class="action-date text-secondary text-caption vn-ml-sm"
|
||||
title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}">
|
||||
{{::$ctrl.relativeDate(log.creationDate)}}
|
||||
<vn-icon
|
||||
class="action vn-ml-xs"
|
||||
ng-class="::$ctrl.actionsClass[log.action]"
|
||||
icon="{{::$ctrl.actionsIcon[log.action]}}"
|
||||
translate-attr="::{title: $ctrl.actionsText[log.action]}">
|
||||
</vn-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="model vn-pb-sm vn-px-sm"
|
||||
ng-if="::$ctrl.showModelName">
|
||||
<span class="model-id" ng-if="::log.changedModelId">#{{::log.changedModelId}}</span>
|
||||
<span class="model-value">{{::log.changedModelValue}}</span>
|
||||
<vn-icon
|
||||
icon="filter_alt"
|
||||
translate-attr="{title: 'Show all record changes'}"
|
||||
ng-click="$ctrl.filterByEntity(log)">
|
||||
</vn-icon>
|
||||
<span class="model-value" title="{{::log.changedModelValue}}">{{::log.changedModelValue}}</span>
|
||||
</div>
|
||||
<div class="changes vn-pa-sm"
|
||||
ng-class="{expanded: log.expand}"
|
||||
|
@ -75,16 +78,16 @@
|
|||
<span class="json-field" title="{{::prop.name}}">
|
||||
{{::prop.nameI18n}}:
|
||||
</span>
|
||||
<vn-json-value value="::$ctrl.mainVal(prop, log.action)"></vn-json-value><span ng-if="::!$last">,</span>
|
||||
<vn-json-value value="::prop.val.val"></vn-json-value><span ng-if="::!$last">,</span>
|
||||
</span>
|
||||
<div ng-if="log.expand" class="expanded-json">
|
||||
<div ng-repeat="prop in ::log.props">
|
||||
<span class="json-field" title="{{::prop.name}}">
|
||||
{{::prop.nameI18n}}:
|
||||
</span>
|
||||
<vn-json-value value="::$ctrl.mainVal(prop, log.action)"></vn-json-value>
|
||||
<vn-log-value val="::prop.val"></vn-log-value>
|
||||
<span ng-if="::log.action == 'update'">
|
||||
← <vn-json-value value="::prop.old"></vn-json-value>
|
||||
← <vn-log-value val="::prop.old"></vn-log-value>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -96,10 +99,36 @@
|
|||
</div>
|
||||
</div>
|
||||
</vn-data-viewer>
|
||||
<vn-float-button
|
||||
ng-if="model.userFilter"
|
||||
icon="filter_alt_off"
|
||||
translate-attr="{title: 'Quit filter'}"
|
||||
ng-click="$ctrl.resetFilter()"
|
||||
fixed-bottom-right>
|
||||
</vn-float-button>
|
||||
<vn-side-menu side="right">
|
||||
<form vn-vertical
|
||||
ng-model-options="{updateOn: 'change blur'}"
|
||||
class="vn-pa-md filter">
|
||||
<vn-textfield
|
||||
label="Search"
|
||||
ng-model="filter.search">
|
||||
<append>
|
||||
<vn-icon
|
||||
icon="info_outline"
|
||||
vn-tooltip="Search by id or concept"
|
||||
pointer>
|
||||
</vn-icon>
|
||||
</append>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
label="Entity"
|
||||
ng-model="filter.changedModel"
|
||||
value-field="changedModel"
|
||||
show-field="changedModelI18n"
|
||||
data="$ctrl.models"
|
||||
class="changed-model">
|
||||
</vn-autocomplete>
|
||||
<vn-vertical>
|
||||
<vn-radio
|
||||
label="All"
|
||||
|
@ -145,30 +174,16 @@
|
|||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
label="Search"
|
||||
ng-model="filter.search">
|
||||
label="Changes"
|
||||
ng-model="filter.changes">
|
||||
<append>
|
||||
<vn-icon
|
||||
icon="info_outline"
|
||||
vn-tooltip="Search by id or concept"
|
||||
vn-tooltip="Search by changes"
|
||||
pointer>
|
||||
</vn-icon>
|
||||
</append>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
label="Entity"
|
||||
ng-model="filter.changedModel"
|
||||
value-field="changedModel"
|
||||
show-field="changedModelI18n"
|
||||
data="$ctrl.models"
|
||||
class="changed-model">
|
||||
</vn-autocomplete>
|
||||
<!-- FIXME: Cannot use LIKE with JSON columns
|
||||
<vn-textfield
|
||||
label="Changes"
|
||||
ng-model="filter.changes">
|
||||
</vn-textfield>
|
||||
-->
|
||||
<vn-vertical>
|
||||
<vn-check
|
||||
label="Creates"
|
||||
|
@ -195,18 +210,6 @@
|
|||
label="To"
|
||||
ng-model="filter.to">
|
||||
</vn-date-picker>
|
||||
<vn-button-bar vn-vertical>
|
||||
<vn-button
|
||||
label="Filter"
|
||||
ng-click="$ctrl.applyFilter(filter)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Reset"
|
||||
class="flat"
|
||||
ng-click="$ctrl.resetFilter()"
|
||||
ng-if="model.userFilter">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
</vn-side-menu>
|
||||
<vn-worker-descriptor-popover vn-id="workerDescriptor">
|
||||
|
|
|
@ -64,29 +64,47 @@ export default class Controller extends Section {
|
|||
set logs(value) {
|
||||
this._logs = value;
|
||||
if (!value) return;
|
||||
|
||||
const empty = {};
|
||||
const validations = window.validations;
|
||||
const castJsonValue = this.castJsonValue;
|
||||
|
||||
for (const log of value) {
|
||||
const oldValues = log.oldInstance || empty;
|
||||
const newValues = log.newInstance || empty;
|
||||
const notDelete = log.action != 'delete';
|
||||
const olds = (notDelete ? log.oldInstance : null) || empty;
|
||||
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
|
||||
const locale = validations[log.changedModel]?.locale || empty;
|
||||
log.changedModelI18n = firstUpper(locale.name) || log.changedModel;
|
||||
|
||||
let props = Object.keys(oldValues).concat(Object.keys(newValues));
|
||||
let props = Object.keys(olds).concat(Object.keys(vals));
|
||||
props = [...new Set(props)];
|
||||
|
||||
log.props = [];
|
||||
for (const prop of props) {
|
||||
if (prop.endsWith('$')) continue;
|
||||
log.props.push({
|
||||
name: prop,
|
||||
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
||||
old: this.castJsonValue(oldValues[prop]),
|
||||
new: this.castJsonValue(newValues[prop])
|
||||
old: getVal(olds, prop),
|
||||
val: getVal(vals, prop)
|
||||
});
|
||||
}
|
||||
log.props.sort(
|
||||
(a, b) => a.nameI18n.localeCompare(b.nameI18n));
|
||||
}
|
||||
|
||||
function getVal(vals, prop) {
|
||||
let val, id;
|
||||
const showProp = `${prop}$`;
|
||||
|
||||
if (vals[showProp] != null) {
|
||||
val = vals[showProp];
|
||||
id = vals[prop];
|
||||
} else
|
||||
val = vals[prop];
|
||||
|
||||
return {val: castJsonValue(val), id};
|
||||
}
|
||||
}
|
||||
|
||||
get models() {
|
||||
|
@ -113,10 +131,6 @@ export default class Controller extends Section {
|
|||
: value;
|
||||
}
|
||||
|
||||
mainVal(prop, action) {
|
||||
return action == 'delete' ? prop.old : prop.new;
|
||||
}
|
||||
|
||||
relativeDate(dateVal) {
|
||||
if (dateVal == null) return '';
|
||||
const date = new Date(dateVal);
|
||||
|
@ -150,14 +164,15 @@ export default class Controller extends Section {
|
|||
if (value == null || value == '') return null;
|
||||
switch (prop) {
|
||||
case 'search':
|
||||
if (/^[0-9]+$/.test(value))
|
||||
return {changedModelId: value};
|
||||
const or = [];
|
||||
if (/^\s*[0-9]+\s*$/.test(value))
|
||||
return {changedModelId: value.trim()};
|
||||
else
|
||||
return {changedModelValue: {like: `%${value}%`}};
|
||||
case 'changes':
|
||||
return {or: [
|
||||
{oldInstance: {like: `%${value}%`}},
|
||||
{newInstance: {like: `%${value}%`}},
|
||||
{oldJson: {like: `%${value}%`}},
|
||||
{newJson: {like: `%${value}%`}},
|
||||
{description: {like: `%${value}%`}}
|
||||
]};
|
||||
case 'who':
|
||||
|
@ -206,6 +221,14 @@ export default class Controller extends Section {
|
|||
return this.$.model.applyFilter(lbFilter);
|
||||
}
|
||||
|
||||
filterByEntity(log) {
|
||||
this.$.filter = {
|
||||
who: 'all',
|
||||
search: log.changedModelId,
|
||||
changedModel: log.changedModel
|
||||
};
|
||||
}
|
||||
|
||||
searchUser(search) {
|
||||
if (/^[0-9]+$/.test(search)) {
|
||||
return {id: search};
|
||||
|
@ -238,3 +261,12 @@ ngModule.vnComponent('vnLog', {
|
|||
url: '@'
|
||||
}
|
||||
});
|
||||
|
||||
ngModule.component('vnLogValue', {
|
||||
template:
|
||||
'<vn-json-value value="::$ctrl.val.val"></vn-json-value>' +
|
||||
'<span ng-if="::$ctrl.val.id" class="id-value"> #{{::$ctrl.val.id}}</span>',
|
||||
bindings: {
|
||||
val: '<?',
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,6 +2,9 @@ Date: Fecha
|
|||
Concept: Concepto
|
||||
Search: Buscar
|
||||
Search by id or concept: Buscar por identificador o concepto
|
||||
Search by changes: |
|
||||
Buscar por cambios. Los atributos deben buscarse por su nombre interno,
|
||||
para obtenerlo situar el cursor sobre el atributo.
|
||||
Entity: Entidad
|
||||
Action: Acción
|
||||
Author: Autor
|
||||
|
@ -13,9 +16,12 @@ Creates: Crea
|
|||
Edits: Modifica
|
||||
Deletes: Elimina
|
||||
Accesses: Accede
|
||||
All: Todo
|
||||
System: Sistema
|
||||
Details: Detalles
|
||||
note: nota
|
||||
Changes: Cambios
|
||||
today: hoy
|
||||
yesterday: ayer
|
||||
Show all record changes: Mostrar todos los cambios realizados en el registro
|
||||
Quit filter: Quitar filtro
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@import "variables";
|
||||
@import "effects";
|
||||
@import "util";
|
||||
|
||||
vn-log {
|
||||
.change {
|
||||
|
@ -77,7 +76,7 @@ vn-log {
|
|||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 1.4em;
|
||||
font-size: 18px;
|
||||
|
||||
&.notice {
|
||||
background-color: $color-notice-medium
|
||||
|
@ -98,7 +97,22 @@ vn-log {
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-height: 18px;
|
||||
|
||||
& > vn-icon {
|
||||
@extend %clickable-light;
|
||||
vertical-align: middle;
|
||||
padding: 2px;
|
||||
margin: -2px;
|
||||
font-size: 18px;
|
||||
color: $color-font-secondary;
|
||||
float: right;
|
||||
display: none;
|
||||
|
||||
@include mobile {
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
& > .model-value {
|
||||
font-style: italic;
|
||||
}
|
||||
|
@ -107,6 +121,9 @@ vn-log {
|
|||
font-size: .9rem;
|
||||
}
|
||||
}
|
||||
&:hover > .model > vn-icon {
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
.changes {
|
||||
|
@ -144,3 +161,7 @@ vn-log {
|
|||
}
|
||||
}
|
||||
}
|
||||
vn-log-value > .id-value {
|
||||
font-size: .9rem;
|
||||
color: $color-font-secondary;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@import "./variables";
|
||||
@import "./effects";
|
||||
@import "./util";
|
||||
|
||||
form vn-horizontal {
|
||||
align-items: center;
|
||||
|
@ -22,7 +21,7 @@ form vn-horizontal {
|
|||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: $mobile-width) {
|
||||
@include mobile {
|
||||
flex-direction: column;
|
||||
align-items: initial;
|
||||
|
||||
|
|
|
@ -1,4 +1,61 @@
|
|||
{
|
||||
"name": "Log",
|
||||
"base": "VnModel"
|
||||
"base": "VnModel",
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"oldJson": {
|
||||
"type": "String",
|
||||
"mysql": {"columnName": "oldInstance"}
|
||||
},
|
||||
"newJson": {
|
||||
"type": "String",
|
||||
"mysql": {"columnName": "newInstance"}
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,8 +196,48 @@ module.exports = function(Self) {
|
|||
/*
|
||||
* Shortcut to VnMySQL.executeP()
|
||||
*/
|
||||
rawSql(query, params, options, cb) {
|
||||
return this.dataSource.connector.executeP(query, params, options, cb);
|
||||
async rawSql(query, params, options) {
|
||||
const userId = options?.userId;
|
||||
const connector = this.dataSource.connector;
|
||||
let conn;
|
||||
let res;
|
||||
const opts = Object.assign({}, options);
|
||||
|
||||
try {
|
||||
if (userId) {
|
||||
conn = await new Promise((resolve, reject) => {
|
||||
connector.client.getConnection(function(err, conn) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
resolve(conn);
|
||||
});
|
||||
});
|
||||
|
||||
const opts = Object.assign({}, options);
|
||||
if (!opts.transaction) {
|
||||
opts.transaction = {
|
||||
connection: conn,
|
||||
connector
|
||||
};
|
||||
}
|
||||
|
||||
await connector.executeP(
|
||||
'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))',
|
||||
[userId], opts
|
||||
);
|
||||
}
|
||||
|
||||
res = await connector.executeP(query, params, opts);
|
||||
|
||||
if (userId) {
|
||||
await connector.executeP('CALL account.myUser_logout()', null, opts);
|
||||
}
|
||||
} finally {
|
||||
if (conn) conn.release();
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
name: subrole
|
||||
columns:
|
||||
id: id
|
||||
role: rol
|
||||
inheritsFrom: inherits
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
name: subrol
|
||||
columns:
|
||||
id: id
|
||||
role: rol
|
||||
inheritsFrom: hereda
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('changePassword', {
|
||||
Self.remoteMethodCtx('changePassword', {
|
||||
description: 'Changes the user password',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
|
@ -27,9 +27,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.changePassword = async function(id, oldPassword, newPassword) {
|
||||
Self.changePassword = async function(ctx, id, oldPassword, newPassword) {
|
||||
await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`,
|
||||
[id, oldPassword, newPassword]);
|
||||
[id, oldPassword, newPassword], {userId: ctx.req.accessToken.userId});
|
||||
await Self.app.models.Account.syncById(id, newPassword);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('setPassword', {
|
||||
Self.remoteMethodCtx('setPassword', {
|
||||
description: 'Sets the user password',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
|
@ -21,9 +21,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.setPassword = async function(id, newPassword) {
|
||||
Self.setPassword = async function(ctx, id, newPassword) {
|
||||
await Self.rawSql(`CALL account.user_setPassword(?, ?)`,
|
||||
[id, newPassword]);
|
||||
[id, newPassword], {userId: ctx.req.accessToken.userId});
|
||||
await Self.app.models.Account.syncById(id, newPassword);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,8 +2,9 @@ const {models} = require('vn-loopback/server/server');
|
|||
|
||||
describe('account changePassword()', () => {
|
||||
it('should throw an error when old password is wrong', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
let err;
|
||||
await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999')
|
||||
await models.Account.changePassword(ctx, 1, 'wrongPassword', 'nightmare.9999')
|
||||
.catch(error => err = error.sqlMessage);
|
||||
|
||||
expect(err).toBeDefined();
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('Account setPassword()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should throw an error when password does not meet requirements', async() => {
|
||||
let req = models.Account.setPassword(1, 'insecurePass');
|
||||
let req = models.Account.setPassword(ctx, 1, 'insecurePass');
|
||||
|
||||
await expectAsync(req).toBeRejected();
|
||||
});
|
||||
|
||||
it('should update password when it passes requirements', async() => {
|
||||
let req = models.Account.setPassword(1, 'Very$ecurePa22.');
|
||||
let req = models.Account.setPassword(ctx, 1, 'Very$ecurePa22.');
|
||||
|
||||
await expectAsync(req).toBeResolved();
|
||||
});
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "account.roleLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "account.userLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ module.exports = Self => {
|
|||
};
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "claimLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
name: SMS
|
||||
columns:
|
||||
id: id
|
||||
senderFk: sender
|
||||
sender: sender number
|
||||
destination: destination
|
||||
message: message
|
||||
statusCode: status code
|
||||
status: status
|
||||
created: created
|
|
@ -0,0 +1,10 @@
|
|||
name: SMS
|
||||
columns:
|
||||
id: id
|
||||
senderFk: remitente
|
||||
sender: número remitente
|
||||
destination: destinatario
|
||||
message: mensaje
|
||||
statusCode: código estado
|
||||
status: estado
|
||||
created: creado
|
|
@ -23,7 +23,7 @@ module.exports = Self => {
|
|||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('consumptionSendQueued', {
|
||||
Self.remoteMethodCtx('consumptionSendQueued', {
|
||||
description: 'Send all queued invoices',
|
||||
accessType: 'WRITE',
|
||||
accepts: [],
|
||||
|
@ -15,7 +15,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.consumptionSendQueued = async() => {
|
||||
Self.consumptionSendQueued = async ctx => {
|
||||
const queues = await Self.rawSql(`
|
||||
SELECT
|
||||
id,
|
||||
|
@ -68,7 +68,7 @@ module.exports = Self => {
|
|||
SET status = 'printed',
|
||||
printed = ?
|
||||
WHERE id = ?`,
|
||||
[Date.vnNew(), queue.id]);
|
||||
[Date.vnNew(), queue.id], {userId: ctx.req.accessToken.userId});
|
||||
} catch (error) {
|
||||
await Self.rawSql(`
|
||||
UPDATE clientConsumptionQueue
|
||||
|
|
|
@ -55,7 +55,7 @@ module.exports = function(Self) {
|
|||
date.setHours(0, 0, 0, 0);
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -72,7 +72,7 @@ module.exports = Self => {
|
|||
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const postalCode = [];
|
||||
const args = ctx.args;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = function(Self) {
|
||||
Self.remoteMethod('getCard', {
|
||||
Self.remoteMethodCtx('getCard', {
|
||||
description: 'Get client basic data and debt',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
|
@ -18,8 +18,8 @@ module.exports = function(Self) {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getCard = async(id, options) => {
|
||||
const myOptions = {};
|
||||
Self.getCard = async(ctx, id, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getDebt', {
|
||||
Self.remoteMethodCtx('getDebt', {
|
||||
description: 'Returns the boolean debt of a client',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
|
@ -19,8 +19,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getDebt = async(clientFk, options) => {
|
||||
const myOptions = {};
|
||||
Self.getDebt = async(ctx, clientFk, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('setPassword', {
|
||||
Self.remoteMethodCtx('setPassword', {
|
||||
description: 'Sets the password of a non-worker client',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -21,14 +21,14 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.setPassword = async function(id, newPassword) {
|
||||
Self.setPassword = async function(ctx, id, newPassword) {
|
||||
const models = Self.app.models;
|
||||
|
||||
const isClient = await models.Client.findById(id);
|
||||
const isAccount = await models.Account.findById(id);
|
||||
|
||||
if (isClient && !isAccount)
|
||||
await models.Account.setPassword(id, newPassword);
|
||||
await models.Account.setPassword(ctx, id, newPassword);
|
||||
else
|
||||
throw new UserError(`Modifiable password only via recovery or by an administrator`);
|
||||
};
|
||||
|
|
|
@ -5,10 +5,11 @@ describe('Client getCard()', () => {
|
|||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1101;
|
||||
const result = await models.Client.getCard(id, options);
|
||||
const result = await models.Client.getCard(ctx, id, options);
|
||||
|
||||
expect(result.id).toEqual(id);
|
||||
expect(result.name).toEqual('Bruce Wayne');
|
||||
|
|
|
@ -3,11 +3,12 @@ const models = require('vn-loopback/server/server').models;
|
|||
describe('client getDebt()', () => {
|
||||
it('should return the client debt', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.getDebt(1101, options);
|
||||
const result = await models.Client.getDebt(ctx, 1101, options);
|
||||
|
||||
expect(result.debt).toEqual(jasmine.any(Number));
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Client setPassword', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should throw an error the setPassword target is not just a client but a worker', async() => {
|
||||
let error;
|
||||
|
||||
try {
|
||||
await models.Client.setPassword(1, 't0pl3v3l.p455w0rd!');
|
||||
await models.Client.setPassword(ctx, 1, 't0pl3v3l.p455w0rd!');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
@ -17,7 +18,7 @@ describe('Client setPassword', () => {
|
|||
let error;
|
||||
|
||||
try {
|
||||
await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!');
|
||||
await models.Client.setPassword(ctx, 1101, 't0pl3v3l.p455w0rd!');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client summary()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should return a summary object containing data', async() => {
|
||||
const clientId = 1101;
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
@ -8,7 +9,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.id).toEqual(clientId);
|
||||
expect(result.name).toEqual('Bruce Wayne');
|
||||
|
@ -27,7 +28,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.mana.mana).toEqual(0.34);
|
||||
|
||||
|
@ -45,7 +46,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.debt.debt).toEqual(jasmine.any(Number));
|
||||
|
||||
|
@ -63,7 +64,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.averageInvoiced.invoiced).toEqual(1500);
|
||||
|
||||
|
@ -81,7 +82,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.totalGreuge).toEqual(203.71);
|
||||
|
||||
|
@ -99,7 +100,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.recovery).toEqual(null);
|
||||
|
||||
|
@ -117,7 +118,7 @@ describe('client summary()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Client.summary(clientId, options);
|
||||
const result = await models.Client.summary(ctx, clientId, options);
|
||||
|
||||
expect(result.recovery.id).toEqual(3);
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('summary', {
|
||||
Self.remoteMethodCtx('summary', {
|
||||
description: 'Returns a client summary',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.summary = async(clientFk, options) => {
|
||||
Self.summary = async(ctx, clientFk, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
|
@ -28,7 +28,7 @@ module.exports = Self => {
|
|||
|
||||
const summaryObj = await getSummary(models.Client, clientFk, myOptions);
|
||||
summaryObj.mana = await models.Client.getMana(clientFk, myOptions);
|
||||
summaryObj.debt = await models.Client.getDebt(clientFk, myOptions);
|
||||
summaryObj.debt = await models.Client.getDebt(ctx, clientFk, myOptions);
|
||||
summaryObj.averageInvoiced = await models.Client.getAverageInvoiced(clientFk, myOptions);
|
||||
summaryObj.totalGreuge = await models.Greuge.sumAmount(clientFk, myOptions);
|
||||
summaryObj.recovery = await getRecoveries(models.Recovery, clientFk, myOptions);
|
||||
|
|
|
@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
|
|||
const base64url = require('base64url');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('confirm', {
|
||||
Self.remoteMethodCtx('confirm', {
|
||||
description: 'Confirms electronic payment transaction',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.confirm = async(signatureVersion, merchantParameters, signature) => {
|
||||
Self.confirm = async(ctx, signatureVersion, merchantParameters, signature) => {
|
||||
const $ = Self.app.models;
|
||||
let transaction;
|
||||
|
||||
|
@ -83,7 +83,7 @@ module.exports = Self => {
|
|||
params['Ds_Currency'],
|
||||
params['Ds_Response'],
|
||||
params['Ds_ErrorCode']
|
||||
]);
|
||||
], {userId: ctx.req.accessToken.userId});
|
||||
|
||||
return true;
|
||||
} catch (err) {
|
||||
|
|
|
@ -34,6 +34,6 @@ module.exports = Self => {
|
|||
'CALL hedera.tpvTransaction_end(?, ?)', [
|
||||
orderId,
|
||||
status
|
||||
]);
|
||||
], {userId});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ module.exports = Self => {
|
|||
amount,
|
||||
companyId,
|
||||
userId
|
||||
]);
|
||||
], {userId});
|
||||
|
||||
if (!row)
|
||||
throw new UserError('Transaction error');
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "clientLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>{{::clientInforma.rating}}</vn-td>
|
||||
<vn-td number>{{::clientInforma.recommendedCredit}}</vn-td>
|
||||
<vn-td>{{::clientInforma.recommendedCredit | currency: 'EUR': 2}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = Self => {
|
|||
const args = ctx.args;
|
||||
const models = Self.app.models;
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "entryLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = Self => {
|
|||
|
||||
Self.toBook = async(ctx, id, options) => {
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -5,57 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "invoiceInLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": [
|
||||
"creationDate DESC",
|
||||
"id DESC"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('book', {
|
||||
Self.remoteMethodCtx('book', {
|
||||
description: 'Book an invoiceOut',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
|
@ -20,10 +20,10 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.book = async(ref, options) => {
|
||||
Self.book = async(ctx, ref, options) => {
|
||||
const models = Self.app.models;
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports = Self => {
|
|||
|
||||
Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, options) => {
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = Self => {
|
|||
const args = ctx.args;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = Self => {
|
|||
Self.invoiceClient = async(ctx, options) => {
|
||||
const args = ctx.args;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('refund', {
|
||||
Self.remoteMethodCtx('refund', {
|
||||
description: 'Create refund tickets with sales and services if provided',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
accepts: [
|
||||
{
|
||||
arg: 'ref',
|
||||
type: 'string',
|
||||
description: 'The invoice reference'
|
||||
}],
|
||||
description: 'The invoice reference',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'withWarehouse',
|
||||
type: 'boolean',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['number'],
|
||||
root: true
|
||||
|
@ -17,7 +25,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.refund = async(ref, options) => {
|
||||
Self.refund = async(ctx, ref, withWarehouse, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
@ -35,7 +43,7 @@ module.exports = Self => {
|
|||
const tickets = await models.Ticket.find(filter, myOptions);
|
||||
|
||||
const ticketsIds = tickets.map(ticket => ticket.id);
|
||||
const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions);
|
||||
const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceOut book()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const invoiceOutId = 5;
|
||||
|
||||
it('should update the booked property', async() => {
|
||||
|
@ -12,7 +13,7 @@ describe('invoiceOut book()', () => {
|
|||
const bookedDate = originalInvoiceOut.booked;
|
||||
const invoiceOutRef = originalInvoiceOut.ref;
|
||||
|
||||
await models.InvoiceOut.book(invoiceOutRef, options);
|
||||
await models.InvoiceOut.book(ctx, invoiceOutRef, options);
|
||||
|
||||
const updatedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options);
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ const LoopBackContext = require('loopback-context');
|
|||
|
||||
describe('InvoiceOut refund()', () => {
|
||||
const userId = 5;
|
||||
const ctx = {req: {accessToken: userId}};
|
||||
const withWarehouse = true;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
};
|
||||
|
@ -15,7 +17,7 @@ describe('InvoiceOut refund()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const result = await models.InvoiceOut.refund('T1111111', options);
|
||||
const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
|
||||
|
|
|
@ -76,14 +76,27 @@
|
|||
translate>
|
||||
Show CITES letter
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="refundConfirmation.show()"
|
||||
name="refundInvoice"
|
||||
<vn-item class="dropdown"
|
||||
vn-click-stop="refundMenu.show($event, 'left')"
|
||||
vn-tooltip="Create a single ticket with all the content of the current invoice"
|
||||
vn-acl="invoicing, claimManager, salesAssistant"
|
||||
vn-acl-action="remove"
|
||||
translate>
|
||||
Refund
|
||||
Refund...
|
||||
<vn-menu vn-id="refundMenu">
|
||||
<vn-list>
|
||||
<vn-item
|
||||
ng-click="$ctrl.refundInvoiceOut(true)"
|
||||
translate>
|
||||
with warehouse
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.refundInvoiceOut(false)"
|
||||
translate>
|
||||
without warehouse
|
||||
</vn-item>
|
||||
</vn-list>
|
||||
</vn-menu>
|
||||
</vn-item>
|
||||
</vn-list>
|
||||
</vn-menu>
|
||||
|
@ -97,11 +110,6 @@
|
|||
on-accept="$ctrl.bookInvoiceOut()"
|
||||
question="Are you sure you want to book this invoice?">
|
||||
</vn-confirm>
|
||||
<vn-confirm
|
||||
vn-id="refundConfirmation"
|
||||
on-accept="$ctrl.refundInvoiceOut()"
|
||||
question="Are you sure you want to refund this invoice?">
|
||||
</vn-confirm>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
|
|
|
@ -114,9 +114,9 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
refundInvoiceOut() {
|
||||
refundInvoiceOut(withWarehouse) {
|
||||
const query = 'InvoiceOuts/refund';
|
||||
const params = {ref: this.invoiceOut.ref};
|
||||
const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse};
|
||||
this.$http.post(query, params).then(res => {
|
||||
const refundTicket = res.data;
|
||||
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
|
||||
|
|
|
@ -20,3 +20,4 @@ Regenerate PDF invoice: Regenerar PDF factura
|
|||
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 following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}"
|
||||
Refund...: Abono...
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getBalance', {
|
||||
Self.remoteMethodCtx('getBalance', {
|
||||
description: 'Returns the ',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
|
@ -19,8 +19,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getBalance = async(filter, options) => {
|
||||
const myOptions = {};
|
||||
Self.getBalance = async(ctx, filter, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('new', {
|
||||
Self.remoteMethodCtx('new', {
|
||||
description: 'returns the created item',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -19,9 +19,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.new = async(params, options) => {
|
||||
Self.new = async(ctx, params, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item getBalance()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should return the balance lines of a client type loses in which one has highlighted true', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
@ -25,7 +26,7 @@ describe('item getBalance()', () => {
|
|||
date: null
|
||||
}
|
||||
};
|
||||
const results = await models.Item.getBalance(filter, options);
|
||||
const results = await models.Item.getBalance(ctx, filter, options);
|
||||
|
||||
const result = results.find(element => element.clientType == 'loses');
|
||||
|
||||
|
@ -59,8 +60,8 @@ describe('item getBalance()', () => {
|
|||
}
|
||||
};
|
||||
|
||||
const firstItemBalance = await models.Item.getBalance(firstFilter, options);
|
||||
const secondItemBalance = await models.Item.getBalance(secondFilter, options);
|
||||
const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options);
|
||||
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
||||
|
||||
expect(firstItemBalance[9].claimFk).toEqual(null);
|
||||
expect(secondItemBalance[5].claimFk).toEqual(2);
|
||||
|
|
|
@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item new()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
|
@ -30,7 +31,7 @@ describe('item new()', () => {
|
|||
tag: 1
|
||||
};
|
||||
|
||||
let item = await models.Item.new(itemParams, options);
|
||||
let item = await models.Item.new(ctx, itemParams, options);
|
||||
|
||||
let itemType = await models.ItemType.findById(item.typeFk, options);
|
||||
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "itemLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('addToOrder', {
|
||||
Self.remoteMethodCtx('addToOrder', {
|
||||
description: 'Creates rows (lines) for a order',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -21,8 +21,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.addToOrder = async(params, options) => {
|
||||
const myOptions = {};
|
||||
Self.addToOrder = async(ctx, params, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order addToOrder()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const orderId = 8;
|
||||
it('should add a row to a given order', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
@ -21,7 +22,7 @@ describe('order addToOrder()', () => {
|
|||
}]
|
||||
};
|
||||
|
||||
await models.OrderRow.addToOrder(params, options);
|
||||
await models.OrderRow.addToOrder(ctx, params, options);
|
||||
|
||||
const modifiedRows = await models.OrderRow.find({where: {orderFk: orderId}}, options);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ module.exports = Self => {
|
|||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const query = `CALL hedera.order_confirmWithUser(?, ?)`;
|
||||
const response = await Self.rawSql(query, [orderFk, userId]);
|
||||
const response = await Self.rawSql(query, [orderFk, userId], {userId});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('new', {
|
||||
Self.remoteMethodCtx('new', {
|
||||
description: 'Create a new order and returns the new ID',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
|
@ -32,8 +32,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.new = async(landed, addressId, agencyModeId, options) => {
|
||||
const myOptions = {};
|
||||
Self.new = async(ctx, landed, addressId, agencyModeId, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('newFromTicket', {
|
||||
Self.remoteMethodCtx('newFromTicket', {
|
||||
description: 'Create a new order and returns the new ID',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -18,7 +18,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.newFromTicket = async(ticketFk, options) => {
|
||||
Self.newFromTicket = async(ctx, ticketFk, options) => {
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
|
@ -39,7 +39,7 @@ module.exports = Self => {
|
|||
const addressFk = ticket.addressFk;
|
||||
const agencyModeFk = ticket.agencyModeFk;
|
||||
|
||||
const orderID = await Self.app.models.Order.new(landed, addressFk, agencyModeFk, myOptions);
|
||||
const orderID = await Self.app.models.Order.new(ctx, landed, addressFk, agencyModeFk, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('order new()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should throw an error if the client isnt active', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
@ -13,7 +14,7 @@ describe('order new()', () => {
|
|||
const addressFk = 6;
|
||||
const agencyModeFk = 1;
|
||||
|
||||
await models.Order.new(landed, addressFk, agencyModeFk, options);
|
||||
await models.Order.new(ctx, landed, addressFk, agencyModeFk, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -34,7 +35,7 @@ describe('order new()', () => {
|
|||
const addressFk = 121;
|
||||
const agencyModeFk = 1;
|
||||
|
||||
orderId = await models.Order.new(landed, addressFk, agencyModeFk, options);
|
||||
orderId = await models.Order.new(ctx, landed, addressFk, agencyModeFk, options);
|
||||
|
||||
const highestOrderIdInFixtures = 3;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order newFromTicket()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should create a new order from an existing ticket', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
@ -9,7 +10,7 @@ describe('order newFromTicket()', () => {
|
|||
|
||||
const ticketId = 11;
|
||||
|
||||
const orderId = await models.Order.newFromTicket(ticketId, options);
|
||||
const orderId = await models.Order.newFromTicket(ctx, ticketId, options);
|
||||
|
||||
const highestOrderIdInFixtures = 3;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class Controller extends SearchPanel {
|
|||
|
||||
addValue() {
|
||||
this.filter.values.push({});
|
||||
setTimeout(() => this.popover.relocate());
|
||||
setTimeout(() => this.parentPopover.relocate());
|
||||
}
|
||||
|
||||
changeTag() {
|
||||
|
@ -36,7 +36,7 @@ ngModule.vnComponent('vnOrderCatalogSearchPanel', {
|
|||
controller: Controller,
|
||||
bindings: {
|
||||
onSubmit: '&?',
|
||||
popover: '<?',
|
||||
parentPopover: '<?',
|
||||
resultTags: '<?'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
on-close="$ctrl.onPopoverClose()">
|
||||
<vn-order-catalog-search-panel
|
||||
on-submit="$ctrl.onPanelSubmit($filter)"
|
||||
popover="popover"
|
||||
parent-popover="popover"
|
||||
result-tags="$ctrl.resultTags">
|
||||
</vn-order-catalog-search-panel>
|
||||
</vn-popover>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('createInvoiceIn', {
|
||||
Self.remoteMethodCtx('createInvoiceIn', {
|
||||
description: 'Creates an invoiceIn from one or more agency terms',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -24,11 +24,11 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.createInvoiceIn = async(rows, dms, options) => {
|
||||
Self.createInvoiceIn = async(ctx, rows, dms, options) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('AgencyTerm createInvoiceIn()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
|
@ -42,7 +43,7 @@ describe('AgencyTerm createInvoiceIn()', () => {
|
|||
const oldInvoiceInDueDay = await models.InvoiceInDueDay.findById(invoiceInDueDayId, null, options);
|
||||
const oldInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options);
|
||||
|
||||
await models.AgencyTerm.createInvoiceIn(rows, dms, options);
|
||||
await models.AgencyTerm.createInvoiceIn(ctx, rows, dms, options);
|
||||
|
||||
const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ module.exports = Self => {
|
|||
const tx = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
let options = {transaction: tx};
|
||||
let options = {transaction: tx, userId};
|
||||
|
||||
const priority = await Self.rawSql(query, [id], options);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "routeLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "shelvingLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,54 +5,5 @@
|
|||
"mysql": {
|
||||
"table": "supplierLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ module.exports = Self => {
|
|||
|
||||
Self.recalculatePrice = async(ctx, sales, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('refund', {
|
||||
Self.remoteMethodCtx('refund', {
|
||||
description: 'Create refund tickets with sales and services if provided',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
|
@ -11,6 +11,11 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'servicesIds',
|
||||
type: ['number']
|
||||
},
|
||||
{
|
||||
arg: 'withWarehouse',
|
||||
type: 'boolean',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -23,9 +28,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.refund = async(salesIds, servicesIds, options) => {
|
||||
Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
@ -65,7 +70,7 @@ module.exports = Self => {
|
|||
const now = Date.vnNew();
|
||||
const [firstTicketId] = ticketsIds;
|
||||
|
||||
const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
|
||||
const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);
|
||||
|
||||
for (const sale of sales) {
|
||||
const createdSale = await models.Sale.create({
|
||||
|
@ -113,7 +118,7 @@ module.exports = Self => {
|
|||
}
|
||||
};
|
||||
|
||||
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) {
|
||||
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) {
|
||||
const models = Self.app.models;
|
||||
|
||||
const filter = {include: {relation: 'address'}};
|
||||
|
@ -125,7 +130,7 @@ module.exports = Self => {
|
|||
addressFk: ticket.address().id,
|
||||
agencyModeFk: refundAgencyMode.id,
|
||||
nickname: ticket.address().nickname,
|
||||
warehouseFk: ticket.warehouseFk,
|
||||
warehouseFk: withWarehouse ? ticket.warehouseFk : null,
|
||||
companyFk: ticket.companyFk,
|
||||
landed: now,
|
||||
zoneFk: refoundZoneId
|
||||
|
|
|
@ -3,11 +3,12 @@ const LoopBackContext = require('loopback-context');
|
|||
|
||||
describe('Sale refund()', () => {
|
||||
const userId = 5;
|
||||
const ctx = {req: {accessToken: userId}};
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
accessToken: {userId},
|
||||
};
|
||||
|
||||
const servicesIds = [3];
|
||||
const withWarehouse = true;
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
|
@ -22,7 +23,7 @@ describe('Sale refund()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options);
|
||||
const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
|
||||
|
||||
expect(refundedTicket).toBeDefined();
|
||||
|
||||
|
@ -40,7 +41,7 @@ describe('Sale refund()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ticket = await models.Sale.refund(salesIds, servicesIds, options);
|
||||
const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
|
||||
|
||||
const refundedTicket = await models.Ticket.findOne({
|
||||
where: {
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('sale reserve()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
originalTicketSales = await models.Ticket.getSales(11, options);
|
||||
originalTicketSales = await models.Ticket.getSales(ctx, 11, options);
|
||||
|
||||
expect(originalTicketSales[0].reserved).toEqual(false);
|
||||
expect(originalTicketSales[1].reserved).toEqual(false);
|
||||
|
@ -63,7 +63,7 @@ describe('sale reserve()', () => {
|
|||
|
||||
await models.Sale.reserve(ctx, ticketId, sales, reserved, options);
|
||||
|
||||
const reservedTicketSales = await models.Ticket.getSales(ticketId, options);
|
||||
const reservedTicketSales = await models.Ticket.getSales(ctx, ticketId, options);
|
||||
|
||||
expect(reservedTicketSales[0].reserved).toEqual(true);
|
||||
expect(reservedTicketSales[1].reserved).toEqual(true);
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
|||
Self.updatePrice = async(ctx, id, newPrice, options) => {
|
||||
const $t = ctx.req.__; // $translate
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
|
||||
const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions);
|
||||
const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions);
|
||||
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
|
||||
if (!workerDepartment) return false;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue