Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5595-modify-loggable-tables-in-procs
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-06-09 09:03:23 +02:00
commit 81a96e7d82
62 changed files with 604 additions and 932 deletions

View File

@ -5,14 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2326.01] - 2023-06-29
### Added
### Changed
### Fixed
-
## [2324.01] - 2023-06-08 ## [2324.01] - 2023-06-08
### Added ### 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
### Changed ### Changed
- - (General -> Permisos) Mejorada seguridad
### Fixed ### Fixed
- -

View File

@ -11,9 +11,9 @@ RUN apt-get update \
ca-certificates \ ca-certificates \
gnupg2 \ gnupg2 \
graphicsmagick \ 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 \ && apt-get install -y --no-install-recommends nodejs \
&& npm install -g npm@8.19.2 && npm install -g npm@9.6.6
# Puppeteer # Puppeteer

8
Jenkinsfile vendored
View File

@ -39,7 +39,7 @@ pipeline {
NODE_ENV = "" NODE_ENV = ""
} }
steps { steps {
nodejs('node-v14') { nodejs('node-v20') {
sh 'npm install --no-audit --prefer-offline' sh 'npm install --no-audit --prefer-offline'
sh 'gulp install --ci' sh 'gulp install --ci'
} }
@ -57,14 +57,14 @@ pipeline {
parallel { parallel {
stage('Frontend') { stage('Frontend') {
steps { steps {
nodejs('node-v14') { nodejs('node-v20') {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2' sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2'
} }
} }
} }
stage('Backend') { stage('Backend') {
steps { steps {
nodejs('node-v14') { nodejs('node-v20') {
sh 'npm run test:back:ci' sh 'npm run test:back:ci'
} }
} }
@ -80,7 +80,7 @@ pipeline {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
} }
steps { steps {
nodejs('node-v14') { nodejs('node-v20') {
sh 'gulp build' sh 'gulp build'
} }

View File

@ -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 ;

View File

@ -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 ;

View File

@ -0,0 +1 @@
ALTER TABLE `vn`.`ticket` MODIFY COLUMN warehouseFk smallint(6) unsigned DEFAULT NULL NULL;

View File

View File

@ -595,6 +595,8 @@ export default {
moreMenuUpdateDiscount: 'vn-item[name="discount"]', moreMenuUpdateDiscount: 'vn-item[name="discount"]',
moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]',
moreMenuRefund: 'vn-item[name="refund"]', 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', 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', 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', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',

View File

@ -220,14 +220,25 @@ describe('Ticket Edit sale path', () => {
it('should log in as salesAssistant and navigate to ticket sales', async() => { it('should log in as salesAssistant and navigate to ticket sales', async() => {
await page.loginAndModule('salesAssistant', 'ticket'); await page.loginAndModule('salesAssistant', 'ticket');
await page.accessToSearchResult('16'); await page.accessToSearchResult('17');
await page.accessToSection('ticket.card.sale'); 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.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuRefund); 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.waitForSnackbar();
await page.waitForState('ticket.card.sale'); 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() => { it('should select the third sale and create a claim of it', async() => {
await page.accessToSearchResult('16'); await page.accessToSearchResult('16');
await page.accessToSection('ticket.card.sale'); await page.accessToSection('ticket.card.sale');
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);

View File

@ -49,7 +49,11 @@ describe('Claim summary path', () => {
}); });
it(`should click on the first sale ID making the item descriptor visible`, async() => { 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); await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage);
const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover); const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover);

View File

@ -1,4 +1,11 @@
@import "./variables";
@import "./effects";
@mixin mobile {
@media screen and (max-width: $mobile-width) {
@content;
}
}
@mixin browser($browser) { @mixin browser($browser) {
html[data-browser*="#{$browser}"] & { html[data-browser*="#{$browser}"] & {
@content; @content;

View File

@ -1,5 +1,3 @@
@import "./util";
$font-size: 11pt; $font-size: 11pt;
$menu-width: 256px; $menu-width: 256px;
$topbar-height: 56px; $topbar-height: 56px;

View File

@ -1,4 +1,4 @@
@import "variables"; @import "util";
@keyframes fadein { @keyframes fadein {
from { from {
@ -16,7 +16,7 @@ vn-background {
background-color: black; background-color: black;
z-index: 14; z-index: 14;
@media screen and (max-width: $mobile-width) { @include mobile {
&.shown { &.shown {
display: block; display: block;
opacity: .3; opacity: .3;

View File

@ -1,4 +1,4 @@
@import "effects"; @import "util";
vn-layout { vn-layout {
& > vn-topbar { & > vn-topbar {
@ -134,7 +134,7 @@ vn-layout {
border-radius: 50%; border-radius: 50%;
} }
} }
@media screen and (max-width: $mobile-width) { @include mobile {
& > vn-topbar { & > vn-topbar {
& > .start > .logo { & > .start > .logo {
display: none; display: none;

View File

@ -16,7 +16,7 @@
</vn-crud-model> </vn-crud-model>
<vn-data-viewer <vn-data-viewer
model="model" 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="change vn-mb-sm" ng-repeat="log in $ctrl.logs">
<div class="left"> <div class="left">
<vn-avatar class="vn-mt-xs" <vn-avatar class="vn-mt-xs"
@ -33,17 +33,6 @@
</div> </div>
<vn-card class="detail"> <vn-card class="detail">
<div class="header vn-pa-sm"> <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"> <div class="action-model">
<span class="model-name" <span class="model-name"
ng-if="::$ctrl.showModelName && log.changedModel" ng-if="::$ctrl.showModelName && log.changedModel"
@ -52,13 +41,27 @@
{{::log.changedModelI18n}} {{::log.changedModelI18n}}
</span> </span>
</div> </div>
<div
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>
<div <div class="model vn-pb-sm vn-px-sm"
class="model vn-pb-sm vn-px-sm" ng-if="::$ctrl.showModelName">
title="{{::log.changedModelValue}}"
ng-if="::log.changedModelId || log.changedModelValue">
<span class="model-id" ng-if="::log.changedModelId">#{{::log.changedModelId}}</span> <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>
<div class="changes vn-pa-sm" <div class="changes vn-pa-sm"
ng-class="{expanded: log.expand}" ng-class="{expanded: log.expand}"
@ -75,16 +78,16 @@
<span class="json-field" title="{{::prop.name}}"> <span class="json-field" title="{{::prop.name}}">
{{::prop.nameI18n}}: {{::prop.nameI18n}}:
</span> </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> </span>
<div ng-if="log.expand" class="expanded-json"> <div ng-if="log.expand" class="expanded-json">
<div ng-repeat="prop in ::log.props"> <div ng-repeat="prop in ::log.props">
<span class="json-field" title="{{::prop.name}}"> <span class="json-field" title="{{::prop.name}}">
{{::prop.nameI18n}}: {{::prop.nameI18n}}:
</span> </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'"> <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> </span>
</div> </div>
</div> </div>
@ -96,6 +99,13 @@
</div> </div>
</div> </div>
</vn-data-viewer> </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"> <vn-side-menu side="right">
<form vn-vertical <form vn-vertical
ng-model-options="{updateOn: 'change blur'}" ng-model-options="{updateOn: 'change blur'}"
@ -163,12 +173,17 @@
data="$ctrl.models" data="$ctrl.models"
class="changed-model"> class="changed-model">
</vn-autocomplete> </vn-autocomplete>
<!-- FIXME: Cannot use LIKE with JSON columns
<vn-textfield <vn-textfield
label="Changes" label="Changes"
ng-model="filter.changes"> ng-model="filter.changes">
<append>
<vn-icon
icon="info_outline"
vn-tooltip="Search by changes"
pointer>
</vn-icon>
</append>
</vn-textfield> </vn-textfield>
-->
<vn-vertical> <vn-vertical>
<vn-check <vn-check
label="Creates" label="Creates"
@ -195,18 +210,6 @@
label="To" label="To"
ng-model="filter.to"> ng-model="filter.to">
</vn-date-picker> </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> </form>
</vn-side-menu> </vn-side-menu>
<vn-worker-descriptor-popover vn-id="workerDescriptor"> <vn-worker-descriptor-popover vn-id="workerDescriptor">

View File

@ -64,29 +64,47 @@ export default class Controller extends Section {
set logs(value) { set logs(value) {
this._logs = value; this._logs = value;
if (!value) return; if (!value) return;
const empty = {}; const empty = {};
const validations = window.validations; const validations = window.validations;
const castJsonValue = this.castJsonValue;
for (const log of value) { for (const log of value) {
const oldValues = log.oldInstance || empty; const notDelete = log.action != 'delete';
const newValues = log.newInstance || empty; const olds = (notDelete ? log.oldInstance : null) || empty;
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
const locale = validations[log.changedModel]?.locale || empty; const locale = validations[log.changedModel]?.locale || empty;
log.changedModelI18n = firstUpper(locale.name) || log.changedModel; 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)]; props = [...new Set(props)];
log.props = []; log.props = [];
for (const prop of props) { for (const prop of props) {
if (prop.endsWith('$')) continue;
log.props.push({ log.props.push({
name: prop, name: prop,
nameI18n: firstUpper(locale.columns?.[prop]) || prop, nameI18n: firstUpper(locale.columns?.[prop]) || prop,
old: this.castJsonValue(oldValues[prop]), old: getVal(olds, prop),
new: this.castJsonValue(newValues[prop]) val: getVal(vals, prop)
}); });
} }
log.props.sort( log.props.sort(
(a, b) => a.nameI18n.localeCompare(b.nameI18n)); (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() { get models() {
@ -113,10 +131,6 @@ export default class Controller extends Section {
: value; : value;
} }
mainVal(prop, action) {
return action == 'delete' ? prop.old : prop.new;
}
relativeDate(dateVal) { relativeDate(dateVal) {
if (dateVal == null) return ''; if (dateVal == null) return '';
const date = new Date(dateVal); const date = new Date(dateVal);
@ -150,14 +164,15 @@ export default class Controller extends Section {
if (value == null || value == '') return null; if (value == null || value == '') return null;
switch (prop) { switch (prop) {
case 'search': case 'search':
if (/^[0-9]+$/.test(value)) const or = [];
return {changedModelId: value}; if (/^\s*[0-9]+\s*$/.test(value))
return {changedModelId: value.trim()};
else else
return {changedModelValue: {like: `%${value}%`}}; return {changedModelValue: {like: `%${value}%`}};
case 'changes': case 'changes':
return {or: [ return {or: [
{oldInstance: {like: `%${value}%`}}, {oldJson: {like: `%${value}%`}},
{newInstance: {like: `%${value}%`}}, {newJson: {like: `%${value}%`}},
{description: {like: `%${value}%`}} {description: {like: `%${value}%`}}
]}; ]};
case 'who': case 'who':
@ -206,6 +221,14 @@ export default class Controller extends Section {
return this.$.model.applyFilter(lbFilter); return this.$.model.applyFilter(lbFilter);
} }
filterByEntity(log) {
this.$.filter = {
who: 'all',
search: log.changedModelId,
changedModel: log.changedModel
};
}
searchUser(search) { searchUser(search) {
if (/^[0-9]+$/.test(search)) { if (/^[0-9]+$/.test(search)) {
return {id: search}; return {id: search};
@ -238,3 +261,12 @@ ngModule.vnComponent('vnLog', {
url: '@' 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: '<?',
}
});

View File

@ -2,6 +2,9 @@ Date: Fecha
Concept: Concepto Concept: Concepto
Search: Buscar Search: Buscar
Search by id or concept: Buscar por identificador o concepto 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 Entity: Entidad
Action: Acción Action: Acción
Author: Autor Author: Autor
@ -13,9 +16,12 @@ Creates: Crea
Edits: Modifica Edits: Modifica
Deletes: Elimina Deletes: Elimina
Accesses: Accede Accesses: Accede
All: Todo
System: Sistema System: Sistema
Details: Detalles Details: Detalles
note: nota note: nota
Changes: Cambios Changes: Cambios
today: hoy today: hoy
yesterday: ayer yesterday: ayer
Show all record changes: Mostrar todos los cambios realizados en el registro
Quit filter: Quitar filtro

View File

@ -1,5 +1,4 @@
@import "variables"; @import "util";
@import "effects";
vn-log { vn-log {
.change { .change {
@ -77,7 +76,7 @@ vn-log {
border-radius: 50%; border-radius: 50%;
width: 24px; width: 24px;
height: 24px; height: 24px;
font-size: 1.4em; font-size: 18px;
&.notice { &.notice {
background-color: $color-notice-medium background-color: $color-notice-medium
@ -98,7 +97,22 @@ vn-log {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; 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 { & > .model-value {
font-style: italic; font-style: italic;
} }
@ -107,6 +121,9 @@ vn-log {
font-size: .9rem; font-size: .9rem;
} }
} }
&:hover > .model > vn-icon {
display: initial;
}
} }
} }
.changes { .changes {
@ -144,3 +161,7 @@ vn-log {
} }
} }
} }
vn-log-value > .id-value {
font-size: .9rem;
color: $color-font-secondary;
}

View File

@ -1,5 +1,4 @@
@import "./variables"; @import "./util";
@import "./effects";
form vn-horizontal { form vn-horizontal {
align-items: center; align-items: center;
@ -22,10 +21,10 @@ form vn-horizontal {
} }
} }
@media screen and (max-width: $mobile-width) { @include mobile {
flex-direction: column; flex-direction: column;
align-items: initial; align-items: initial;
& > * { & > * {
&, &,
&:first-child, &:first-child,

View File

@ -1,4 +1,61 @@
{ {
"name": "Log", "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"]
}
} }

View File

@ -1,4 +1,5 @@
name: subrole name: subrole
columns: columns:
id: id
role: rol role: rol
inheritsFrom: inherits inheritsFrom: inherits

View File

@ -1,4 +1,5 @@
name: subrol name: subrol
columns: columns:
id: id
role: rol role: rol
inheritsFrom: hereda inheritsFrom: hereda

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "account.roleLog" "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"]
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "account.userLog" "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"]
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "claimLog" "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"]
} }
} }

View File

@ -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

View File

@ -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

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "clientLog" "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"]
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "entryLog" "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"]
} }
} }

View File

@ -5,57 +5,5 @@
"mysql": { "mysql": {
"table": "invoiceInLog" "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"
]
} }
} }

View File

@ -2,11 +2,19 @@ module.exports = Self => {
Self.remoteMethodCtx('refund', { Self.remoteMethodCtx('refund', {
description: 'Create refund tickets with sales and services if provided', description: 'Create refund tickets with sales and services if provided',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [
arg: 'ref', {
type: 'string', arg: 'ref',
description: 'The invoice reference' type: 'string',
}], description: 'The invoice reference',
required: true
},
{
arg: 'withWarehouse',
type: 'boolean',
required: true
}
],
returns: { returns: {
type: ['number'], type: ['number'],
root: true root: true
@ -17,7 +25,7 @@ module.exports = Self => {
} }
}); });
Self.refund = async(ctx, ref, options) => { Self.refund = async(ctx, ref, withWarehouse, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -35,7 +43,7 @@ module.exports = Self => {
const tickets = await models.Ticket.find(filter, myOptions); const tickets = await models.Ticket.find(filter, myOptions);
const ticketsIds = tickets.map(ticket => ticket.id); const ticketsIds = tickets.map(ticket => ticket.id);
const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, myOptions); const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -4,6 +4,7 @@ const LoopBackContext = require('loopback-context');
describe('InvoiceOut refund()', () => { describe('InvoiceOut refund()', () => {
const userId = 5; const userId = 5;
const ctx = {req: {accessToken: userId}}; const ctx = {req: {accessToken: userId}};
const withWarehouse = true;
const activeCtx = { const activeCtx = {
accessToken: {userId: userId}, accessToken: {userId: userId},
}; };
@ -16,7 +17,7 @@ describe('InvoiceOut refund()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const result = await models.InvoiceOut.refund(ctx, 'T1111111', options); const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options);
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@ -76,14 +76,27 @@
translate> translate>
Show CITES letter Show CITES letter
</vn-item> </vn-item>
<vn-item <vn-item class="dropdown"
ng-click="refundConfirmation.show()" vn-click-stop="refundMenu.show($event, 'left')"
name="refundInvoice"
vn-tooltip="Create a single ticket with all the content of the current invoice" vn-tooltip="Create a single ticket with all the content of the current invoice"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> 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-item>
</vn-list> </vn-list>
</vn-menu> </vn-menu>
@ -97,12 +110,7 @@
on-accept="$ctrl.bookInvoiceOut()" on-accept="$ctrl.bookInvoiceOut()"
question="Are you sure you want to book this invoice?"> question="Are you sure you want to book this invoice?">
</vn-confirm> </vn-confirm>
<vn-confirm <vn-client-descriptor-popover
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-id="clientDescriptor">
</vn-client-descriptor-popover> </vn-client-descriptor-popover>
@ -148,4 +156,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Confirm</button> <button response="accept" translate>Confirm</button>
</tpl-buttons> </tpl-buttons>
</vn-dialog> </vn-dialog>

View File

@ -114,9 +114,9 @@ class Controller extends Section {
}); });
} }
refundInvoiceOut() { refundInvoiceOut(withWarehouse) {
const query = 'InvoiceOuts/refund'; 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 => { this.$http.post(query, params).then(res => {
const refundTicket = res.data; const refundTicket = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {

View File

@ -13,10 +13,11 @@ InvoiceOut deleted: Factura eliminada
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura? Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura?
InvoiceOut booked: Factura asentada InvoiceOut booked: Factura asentada
Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura?
Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual
Regenerate PDF invoice: Regenerar PDF factura Regenerate PDF invoice: Regenerar PDF factura
The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
The email can't be empty: El correo no puede estar vacío The email can't be empty: El correo no puede estar vacío
The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}"
Refund...: Abono...

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "itemLog" "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"]
} }
} }

View File

@ -23,7 +23,7 @@ class Controller extends SearchPanel {
addValue() { addValue() {
this.filter.values.push({}); this.filter.values.push({});
setTimeout(() => this.popover.relocate()); setTimeout(() => this.parentPopover.relocate());
} }
changeTag() { changeTag() {
@ -36,7 +36,7 @@ ngModule.vnComponent('vnOrderCatalogSearchPanel', {
controller: Controller, controller: Controller,
bindings: { bindings: {
onSubmit: '&?', onSubmit: '&?',
popover: '<?', parentPopover: '<?',
resultTags: '<?' resultTags: '<?'
} }
}); });

View File

@ -18,7 +18,7 @@
</vn-searchbar> </vn-searchbar>
</vn-portal> </vn-portal>
<vn-order-catalog-view <vn-order-catalog-view
model="model" model="model"
order="$ctrl.order"> order="$ctrl.order">
</vn-order-catalog-view> </vn-order-catalog-view>
<vn-side-menu side="right"> <vn-side-menu side="right">
@ -31,7 +31,7 @@
label="Category"> label="Category">
</vn-autocomplete> </vn-autocomplete>
<vn-one ng-repeat="category in categories"> <vn-one ng-repeat="category in categories">
<vn-icon <vn-icon
ng-class="{'active': $ctrl.categoryId == category.id}" ng-class="{'active': $ctrl.categoryId == category.id}"
icon="{{::category.icon}}" icon="{{::category.icon}}"
vn-tooltip="{{::category.name}}" vn-tooltip="{{::category.name}}"
@ -83,7 +83,7 @@
</div> </div>
</vn-vertical> </vn-vertical>
<vn-vertical class="input vn-pt-md"> <vn-vertical class="input vn-pt-md">
<vn-textfield vn-one <vn-textfield vn-one
vn-id="search" vn-id="search"
ng-keyUp="$ctrl.onSearchByTag($event)" ng-keyUp="$ctrl.onSearchByTag($event)"
label="Search tag"> label="Search tag">
@ -104,20 +104,20 @@
on-close="$ctrl.onPopoverClose()"> on-close="$ctrl.onPopoverClose()">
<vn-order-catalog-search-panel <vn-order-catalog-search-panel
on-submit="$ctrl.onPanelSubmit($filter)" on-submit="$ctrl.onPanelSubmit($filter)"
popover="popover" parent-popover="popover"
result-tags="$ctrl.resultTags"> result-tags="$ctrl.resultTags">
</vn-order-catalog-search-panel> </vn-order-catalog-search-panel>
</vn-popover> </vn-popover>
<div class="chips"> <div class="chips">
<vn-chip <vn-chip
ng-if="$ctrl.itemId" ng-if="$ctrl.itemId"
removable="true" removable="true"
vn-tooltip="Item id" vn-tooltip="Item id"
on-remove="$ctrl.removeItemId()" on-remove="$ctrl.removeItemId()"
class="colored"> class="colored">
<span>Id: {{$ctrl.itemId}}</span> <span>Id: {{$ctrl.itemId}}</span>
</vn-chip> </vn-chip>
<vn-chip <vn-chip
ng-if="$ctrl.itemName" ng-if="$ctrl.itemName"
removable="true" removable="true"
vn-tooltip="Item" vn-tooltip="Item"
@ -130,20 +130,20 @@
<span>{{$ctrl.itemName}}</span> <span>{{$ctrl.itemName}}</span>
</div> </div>
</vn-chip> </vn-chip>
<vn-chip <vn-chip
ng-if="category.selection" ng-if="category.selection"
removable="true" removable="true"
vn-tooltip="Category" vn-tooltip="Category"
on-remove="$ctrl.categoryId = null" on-remove="$ctrl.categoryId = null"
class="colored"> class="colored">
<span translate>{{category.selection.name}}</span> <span translate>{{category.selection.name}}</span>
</vn-chip> </vn-chip>
<vn-chip <vn-chip
ng-if="type.selection" ng-if="type.selection"
removable="true" removable="true"
vn-tooltip="Type" vn-tooltip="Type"
on-remove="$ctrl.typeId = null" on-remove="$ctrl.typeId = null"
class="colored"> class="colored">
<span translate>{{type.selection.name}}</span> <span translate>{{type.selection.name}}</span>
</vn-chip> </vn-chip>
<vn-chip <vn-chip
@ -151,7 +151,7 @@
removable="true" removable="true"
on-remove="$ctrl.remove($index)" on-remove="$ctrl.remove($index)"
vn-tooltip="{{::$ctrl.formatTooltip(tagGroup)}}" vn-tooltip="{{::$ctrl.formatTooltip(tagGroup)}}"
class="colored"> class="colored">
<div> <div>
<span ng-if="::tagGroup.tagFk"> <span ng-if="::tagGroup.tagFk">
<span translate>{{::tagGroup.tagSelection.name}}</span>: <span translate>{{::tagGroup.tagSelection.name}}</span>:
@ -163,4 +163,4 @@
</div> </div>
</vn-chip> </vn-chip>
</div> </div>
</vn-side-menu> </vn-side-menu>

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "routeLog" "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"]
} }
} }

View File

@ -1,58 +1,9 @@
{ {
"name": "ShelvingLog", "name": "ShelvingLog",
"base": "Log", "base": "Log",
"options": { "options": {
"mysql": { "mysql": {
"table": "shelvingLog" "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"]
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "supplierLog" "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"]
} }
} }

View File

@ -11,6 +11,11 @@ module.exports = Self => {
{ {
arg: 'servicesIds', arg: 'servicesIds',
type: ['number'] type: ['number']
},
{
arg: 'withWarehouse',
type: 'boolean',
required: true
} }
], ],
returns: { returns: {
@ -23,7 +28,7 @@ module.exports = Self => {
} }
}); });
Self.refund = async(ctx, salesIds, servicesIds, options) => { Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {userId: ctx.req.accessToken.userId}; const myOptions = {userId: ctx.req.accessToken.userId};
let tx; let tx;
@ -65,7 +70,7 @@ module.exports = Self => {
const now = Date.vnNew(); const now = Date.vnNew();
const [firstTicketId] = ticketsIds; 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) { for (const sale of sales) {
const createdSale = await models.Sale.create({ 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 models = Self.app.models;
const filter = {include: {relation: 'address'}}; const filter = {include: {relation: 'address'}};
@ -125,7 +130,7 @@ module.exports = Self => {
addressFk: ticket.address().id, addressFk: ticket.address().id,
agencyModeFk: refundAgencyMode.id, agencyModeFk: refundAgencyMode.id,
nickname: ticket.address().nickname, nickname: ticket.address().nickname,
warehouseFk: ticket.warehouseFk, warehouseFk: withWarehouse ? ticket.warehouseFk : null,
companyFk: ticket.companyFk, companyFk: ticket.companyFk,
landed: now, landed: now,
zoneFk: refoundZoneId zoneFk: refoundZoneId

View File

@ -7,8 +7,8 @@ describe('Sale refund()', () => {
const activeCtx = { const activeCtx = {
accessToken: {userId}, accessToken: {userId},
}; };
const servicesIds = [3]; const servicesIds = [3];
const withWarehouse = true;
beforeEach(() => { beforeEach(() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
@ -23,7 +23,7 @@ describe('Sale refund()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, options); const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
expect(refundedTicket).toBeDefined(); expect(refundedTicket).toBeDefined();
@ -41,7 +41,7 @@ describe('Sale refund()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, options); const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
const refundedTicket = await models.Ticket.findOne({ const refundedTicket = await models.Ticket.findOne({
where: { where: {

View File

@ -7,6 +7,11 @@ module.exports = Self => {
arg: 'ticketsIds', arg: 'ticketsIds',
type: ['number'], type: ['number'],
required: true required: true
},
{
arg: 'withWarehouse',
type: 'boolean',
required: true
} }
], ],
returns: { returns: {
@ -19,7 +24,7 @@ module.exports = Self => {
} }
}); });
Self.refund = async(ctx, ticketsIds, options) => { Self.refund = async(ctx, ticketsIds, withWarehouse, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -41,7 +46,7 @@ module.exports = Self => {
const services = await models.TicketService.find(filter, myOptions); const services = await models.TicketService.find(filter, myOptions);
const servicesIds = services.map(service => service.id); const servicesIds = services.map(service => service.id);
const refundedTickets = await models.Sale.refund(ctx, salesIds, servicesIds, myOptions); const refundedTickets = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -1,58 +1,9 @@
{ {
"name": "TicketLog", "name": "TicketLog",
"base": "Log", "base": "Log",
"options": { "options": {
"mysql": { "mysql": {
"table": "ticketLog" "table": "ticketLog"
}
},
"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"]
} }
} }

View File

@ -150,7 +150,7 @@
<td>{{::ticket.futureIpt | dashIfEmpty}}</td> <td>{{::ticket.futureIpt | dashIfEmpty}}</td>
<td> <td>
<span <span
class="chip {{ticket.classColor}}"> class="chip {{ticket.futureClassColor}}">
{{::ticket.futureState | dashIfEmpty}} {{::ticket.futureState | dashIfEmpty}}
</span> </span>
</td> </td>

View File

@ -102,13 +102,6 @@ export default class Controller extends Section {
return checkedLines; return checkedLines;
} }
stateColor(state) {
if (state === 'OK')
return 'success';
else if (state === 'Libre')
return 'notice';
}
dateRange(value) { dateRange(value) {
const minHour = new Date(value); const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0); minHour.setHours(0, 0, 0, 0);

View File

@ -61,24 +61,6 @@ describe('Component vnTicketAdvance', () => {
}); });
}); });
describe('stateColor()', () => {
it('should return success to the OK tickets', () => {
const ok = controller.stateColor(controller.$.model.data[0].state);
const notOk = controller.stateColor(controller.$.model.data[1].state);
expect(ok).toEqual('success');
expect(notOk).not.toEqual('success');
});
it('should return success to the FREE tickets', () => {
const notFree = controller.stateColor(controller.$.model.data[0].state);
const free = controller.stateColor(controller.$.model.data[1].state);
expect(free).toEqual('notice');
expect(notFree).not.toEqual('notice');
});
});
describe('dateRange()', () => { describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => { it('should return two dates with the hours at the start and end of the given date', () => {
const now = Date.vnNew(); const now = Date.vnNew();

View File

@ -141,12 +141,27 @@
translate> translate>
Recalculate components Recalculate components
</vn-item> </vn-item>
<vn-item <vn-item class="dropdown"
ng-click="refundAllConfirmation.show()" vn-click-stop="refundMenu.show($event, 'left')"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove" vn-acl-action="remove"
vn-tooltip="Create a single ticket with all the content of the current ticket"
translate> translate>
Refund all Refund all...
<vn-menu vn-id="refundMenu">
<vn-list>
<vn-item
ng-click="$ctrl.refund(true)"
translate>
with warehouse
</vn-item>
<vn-item
ng-click="$ctrl.refund(false)"
translate>
without warehouse
</vn-item>
</vn-list>
</vn-menu>
</vn-item> </vn-item>
</vn-list> </vn-list>
</vn-menu> </vn-menu>
@ -319,14 +334,6 @@
message="Recalculate components"> message="Recalculate components">
</vn-confirm> </vn-confirm>
<!-- Refund all confirmation dialog -->
<vn-confirm
vn-id="refundAllConfirmation"
on-accept="$ctrl.refund()"
question="Are you sure you want to refund all?"
message="Refund all">
</vn-confirm>
<!-- Client balance popup--> <!-- Client balance popup-->
<vn-client-balance-create <vn-client-balance-create
vn-id="balance-create" vn-id="balance-create"

View File

@ -297,16 +297,17 @@ class Controller extends Section {
.then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
} }
async refund() { refund(withWarehouse) {
const params = {ticketsIds: [this.id]}; const params = {ticketsIds: [this.id], withWarehouse: withWarehouse};
const query = 'Tickets/refund'; const query = 'Tickets/refund';
return this.$http.post(query, params).then(res => { return this.$http.post(query, params)
const refundTicket = res.data; .then(res => {
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { const refundTicket = res.data;
ticketId: refundTicket.id this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
})); ticketId: refundTicket.id
this.$state.go('ticket.card.sale', {id: refundTicket.id}); }));
}); this.$state.go('ticket.card.sale', {id: refundTicket.id});
});
} }
onSmsSend(sms) { onSmsSend(sms) {

View File

@ -10,7 +10,9 @@ Send CSV: Enviar CSV
Send CSV Delivery Note: Enviar albarán en CSV Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF Send PDF Delivery Note: Enviar albarán en PDF
Show Proforma: Ver proforma Show Proforma: Ver proforma
Refund all: Abonar todo Refund all...: Abonar todo...
with warehouse: con almacén
without warehouse: sin almacén
Invoice sent: Factura enviada Invoice sent: Factura enviada
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
Transfer client: Transferir cliente Transfer client: Transferir cliente
@ -18,3 +20,4 @@ SMS Notify changes: SMS Notificar cambios
PDF sent!: ¡PDF enviado! PDF sent!: ¡PDF enviado!
Already exist signed delivery note: Ya existe albarán de entrega firmado Already exist signed delivery note: Ya existe albarán de entrega firmado
Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega? Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega?
Create a single ticket with all the content of the current ticket: Crea un ticket único con todo el contenido del ticket actual

View File

@ -158,7 +158,7 @@
<td>{{::ticket.futureIpt | dashIfEmpty}}</td> <td>{{::ticket.futureIpt | dashIfEmpty}}</td>
<td> <td>
<span <span
class="chip {{ticket.classColor}}"> class="chip {{ticket.futureClassColor}}">
{{::ticket.futureState}} {{::ticket.futureState}}
</span> </span>
</td> </td>

View File

@ -529,11 +529,28 @@
ng-if="$ctrl.isEditable && $ctrl.hasReserves()"> ng-if="$ctrl.isEditable && $ctrl.hasReserves()">
Unmark as reserved Unmark as reserved
</vn-item> </vn-item>
<vn-item translate <vn-item class="dropdown"
name="refund" name="refund"
ng-click="$ctrl.createRefund()" vn-click-stop="refundMenu.show($event, 'left')"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove"> vn-acl-action="remove"
Refund translate>
</vn-item> Refund...
<vn-menu vn-id="refundMenu">
<vn-list>
<vn-item
name="refundWithWarehouse"
ng-click="$ctrl.createRefund(true)"
translate>
with warehouse
</vn-item>
<vn-item
name="refundWithoutWarehouse"
ng-click="$ctrl.createRefund(false)"
translate>
without warehouse
</vn-item>
</vn-list>
</vn-menu>
</vn-item>
</vn-menu> </vn-menu>

View File

@ -520,13 +520,12 @@ class Controller extends Section {
}); });
} }
createRefund() { createRefund(withWarehouse) {
const sales = this.selectedValidSales(); const sales = this.selectedValidSales();
if (!sales) return; if (!sales) return;
const salesIds = sales.map(sale => sale.id); const salesIds = sales.map(sale => sale.id);
const params = {salesIds: salesIds, withWarehouse: withWarehouse};
const params = {salesIds: salesIds};
const query = 'Sales/refund'; const query = 'Sales/refund';
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
const refundTicket = res.data; const refundTicket = res.data;

View File

@ -36,10 +36,10 @@ Warehouse: Almacen
Agency: Agencia Agency: Agencia
Shipped: F. envio Shipped: F. envio
Packaging: Encajado Packaging: Encajado
Refund: Abono Refund...: Abono...
Promotion mana: Maná promoción Promotion mana: Maná promoción
Claim mana: Maná reclamación Claim mana: Maná reclamación
History: Historial History: Historial
Do you want to continue?: ¿Desea continuar? Do you want to continue?: ¿Desea continuar?
Claim out of time: Reclamación fuera de plazo Claim out of time: Reclamación fuera de plazo
Do you want to create a claim?: ¿Quieres crear una reclamación? Do you want to create a claim?: ¿Quieres crear una reclamación?

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "travelLog" "table": "travelLog"
} }
},
"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"]
} }
} }

View File

@ -1,55 +1,14 @@
{ {
"name": "DeviceProductionLog", "name": "DeviceProductionLog",
"base": "Log", "base": "Log",
"options": { "options": {
"mysql": { "mysql": {
"table": "deviceProductionLog" "table": "deviceProductionLog"
}
},
"properties": {
"id": {
"id": true,
"type": "number",
"forceId": false
},
"originFk": {
"type": "number",
"required": true
},
"userFk": {
"type": "number"
},
"deviceProduction": {
"type": "number"
},
"action": {
"type": "string",
"required": true
},
"created": {
"type": "date"
},
"oldInstance": {
"type": "object"
},
"newInstance": {
"type": "object"
},
"changedModel": {
"type": "string"
},
"changedModelId": {
"type": "number"
}
},
"relations": {
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
} }
}, },
"scope": { "properties": {
"order": ["created DESC", "id DESC"] "deviceProduction": {
"type": "number"
}
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "workerLog" "table": "workerLog"
} }
},
"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"]
} }
} }

View File

@ -5,54 +5,5 @@
"mysql": { "mysql": {
"table": "zoneLog" "table": "zoneLog"
} }
},
"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"]
} }
} }

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "23.22.01", "version": "23.24.01",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "salix-back", "name": "salix-back",
"version": "23.22.01", "version": "23.24.01",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"axios": "^1.2.2", "axios": "^1.2.2",

View File

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

View File

@ -9,7 +9,7 @@ let mode = env == 'development' ? env : 'production';
let baseConfig = { let baseConfig = {
entry: {salix: 'salix'}, entry: {salix: 'salix'},
mode: mode, mode,
output: { output: {
path: path.join(__dirname, 'dist'), path: path.join(__dirname, 'dist'),
publicPath: '/' publicPath: '/'