Merge branch '5347-clientCreate-→-client_create' of https://gitea.verdnatura.es/verdnatura/salix into 5347-clientCreate-→-client_create
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2023-06-28 14:07:38 +02:00
commit 54e75dc850
32 changed files with 220 additions and 432 deletions

View File

@ -5,6 +5,15 @@ 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).
## [2328.01] - 2023-07-13
### Added
### Changed
### Fixed
## [2326.01] - 2023-06-29
### Added

View File

@ -3,6 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('renewToken', {
description: 'Checks if the token has more than renewPeriod seconds to live and if so, renews it',
accessType: 'WRITE',
accepts: [],
returns: {
type: 'Object',

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES
('VnUser', 'renewToken', 'WRITE', 'ALLOW', 'ROLE', 'employee')

View File

View File

@ -1179,8 +1179,6 @@ export default {
allBuyCheckbox: 'vn-entry-buy-index thead vn-check',
firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check',
deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]',
addBuyButton: 'vn-entry-buy-index vn-icon[icon="add"]',
secondBuyPackingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price3"]',
secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]',
secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]',
secondBuyGrouping: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.grouping"]',

View File

@ -66,97 +66,4 @@ describe('Entry import, create and edit buys path', () => {
await page.waitToClick(selectors.globalItems.acceptButton);
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
});
it('should add a new buy', async() => {
await page.waitToClick(selectors.entryBuys.addBuyButton);
await page.write(selectors.entryBuys.secondBuyPackingPrice, '999');
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '999');
await page.write(selectors.entryBuys.secondBuyPrice, '999');
await page.write(selectors.entryBuys.secondBuyGrouping, '999');
await page.write(selectors.entryBuys.secondBuyPacking, '999');
await page.write(selectors.entryBuys.secondBuyWeight, '999');
await page.write(selectors.entryBuys.secondBuyStickers, '999');
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '1');
await page.write(selectors.entryBuys.secondBuyQuantity, '999');
await page.autocompleteSearch(selectors.entryBuys.secondBuyItem, '1');
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 2);
});
it('should edit the newest buy and check data', async() => {
await page.clearInput(selectors.entryBuys.secondBuyPackingPrice);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyPackingPrice, '100');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyGroupingPrice);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '200');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyPrice);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyPrice, '300');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyGrouping);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyGrouping, '400');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyPacking);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyPacking, '500');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyWeight);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyWeight, '600');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyStickers);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyStickers, '700');
await page.keyboard.press('Enter');
await page.waitForSnackbar();
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '94');
await page.waitForSnackbar();
await page.clearInput(selectors.entryBuys.secondBuyQuantity);
await page.waitForTimeout(250);
await page.write(selectors.entryBuys.secondBuyQuantity, '800');
await page.keyboard.press('Enter');
await page.reloadSection('entry.card.buy.index');
const secondBuyPackingPrice = await page.getValue(selectors.entryBuys.secondBuyPackingPrice);
const secondBuyGroupingPrice = await page.getValue(selectors.entryBuys.secondBuyGroupingPrice);
const secondBuyPrice = await page.getValue(selectors.entryBuys.secondBuyPrice);
const secondBuyGrouping = await page.getValue(selectors.entryBuys.secondBuyGrouping);
const secondBuyPacking = await page.getValue(selectors.entryBuys.secondBuyPacking);
const secondBuyWeight = await page.getValue(selectors.entryBuys.secondBuyWeight);
const secondBuyStickers = await page.getValue(selectors.entryBuys.secondBuyStickers);
const secondBuyPackage = await page.getValue(selectors.entryBuys.secondBuyPackage);
const secondBuyQuantity = await page.getValue(selectors.entryBuys.secondBuyQuantity);
expect(secondBuyPackingPrice).toEqual('100');
expect(secondBuyGroupingPrice).toEqual('200');
expect(secondBuyPrice).toEqual('300');
expect(secondBuyGrouping).toEqual('400');
expect(secondBuyPacking).toEqual('500');
expect(secondBuyWeight).toEqual('600');
expect(secondBuyStickers).toEqual('700');
expect(secondBuyPackage).toEqual('94');
expect(secondBuyQuantity).toEqual('800');
});
});

View File

@ -115,7 +115,7 @@
"This client is not invoiceable": "This client is not invoiceable",
"INACTIVE_PROVIDER": "Inactive provider",
"reference duplicated": "reference duplicated",
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
"The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
"This item is not available": "This item is not available",
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
@ -175,5 +175,6 @@
"Pass expired": "The password has expired, change it from Salix",
"Can't transfer claimed sales": "Can't transfer claimed sales",
"Invalid quantity": "Invalid quantity",
"Failed to upload delivery note": "Error to upload delivery note {{id}}"
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address"
}

View File

@ -211,7 +211,7 @@
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
"Amounts do not match": "Las cantidades no coinciden",
"The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
"The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
@ -265,7 +265,7 @@
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
"There is no assigned email for this client": "No hay correo asignado para este cliente",
"Exists an invoice with a previous date": "Existe una factura con fecha anterior",
"Exists an invoice with a future date": "Existe una factura con fecha posterior",
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
"Warehouse inventory not set": "El almacén inventario no está establecido",
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
@ -294,5 +294,9 @@
"Invalid NIF for VIES": "Invalid NIF for VIES",
"Ticket does not exist": "Este ticket no existe",
"Ticket is already signed": "Este ticket ya ha sido firmado",
"Fecha fuera de rango": "Fecha fuera de rango",
"Error while generating PDF": "Error al generar PDF",
"Error when sending mail to client": "Error al enviar el correo al cliente",
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado"
}

View File

@ -52,4 +52,5 @@ columns:
hasInvoiceSimplified: simplified invoice
typeFk: type
lastSalesPersonFk: last salesperson
rating: rating
recommendedCredit: recommended credit

View File

@ -52,4 +52,5 @@ columns:
hasInvoiceSimplified: factura simple
typeFk: tipo
lastSalesPersonFk: último comercial
rating: clasificación
recommendedCredit: crédito recomendado

View File

@ -1,165 +0,0 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethodCtx('addBuy', {
description: 'Inserts a new buy for the current entry',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The entry id',
http: {source: 'path'}
},
{
arg: 'itemFk',
type: 'number',
required: true
},
{
arg: 'quantity',
type: 'number',
required: true
},
{
arg: 'packageFk',
type: 'string',
required: true
},
{
arg: 'packing',
type: 'number',
},
{
arg: 'grouping',
type: 'number'
},
{
arg: 'weight',
type: 'number',
},
{
arg: 'stickers',
type: 'number',
},
{
arg: 'price2',
type: 'number',
},
{
arg: 'price3',
type: 'number',
},
{
arg: 'buyingValue',
type: 'number'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/:id/addBuy`,
verb: 'POST'
}
});
Self.addBuy = async(ctx, options) => {
const conn = Self.dataSource.connector;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const models = Self.app.models;
ctx.args.entryFk = ctx.args.id;
// remove unwanted properties
delete ctx.args.id;
delete ctx.args.ctx;
const newBuy = await models.Buy.create(ctx.args, myOptions);
const filter = {
fields: [
'id',
'itemFk',
'stickers',
'packing',
'grouping',
'quantity',
'packageFk',
'weight',
'buyingValue',
'price2',
'price3'
],
include: {
relation: 'item',
scope: {
fields: [
'id',
'typeFk',
'name',
'size',
'minPrice',
'tag5',
'value5',
'tag6',
'value6',
'tag7',
'value7',
'tag8',
'value8',
'tag9',
'value9',
'tag10',
'value10',
'groupingMode'
],
include: {
relation: 'itemType',
scope: {
fields: ['code', 'description']
}
}
}
}
};
const stmts = [];
let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');
stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.buyRecalc
(INDEX (id))
ENGINE = MEMORY
SELECT ? AS id`, [newBuy.id]);
stmts.push(stmt);
stmts.push('CALL buy_recalcPrices()');
const sql = ParameterizedSQL.join(stmts, ';');
await conn.executeStmt(sql, myOptions);
const buy = await models.Buy.findById(newBuy.id, filter, myOptions);
if (tx) await tx.commit();
return buy;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -75,7 +75,7 @@ module.exports = Self => {
value[field] = newValue;
if (filter) {
ctx.args.filter = {where: filter, limit: null};
ctx.args = {where: filter, limit: null};
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
}

View File

@ -1,42 +0,0 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('entry addBuy()', () => {
const activeCtx = {
accessToken: {userId: 18},
};
const ctx = {
req: activeCtx
};
const entryId = 2;
it('should create a new buy for the given entry', async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
const itemId = 4;
const quantity = 10;
ctx.args = {
id: entryId,
itemFk: itemId,
quantity: quantity,
packageFk: 3
};
const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx};
try {
const newBuy = await models.Entry.addBuy(ctx, options);
expect(newBuy.itemFk).toEqual(itemId);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -53,7 +53,36 @@ describe('Buy editLatestsBuys()', () => {
const options = {transaction: tx};
try {
const filter = {'i.typeFk': 1};
const filter = {'categoryFk': 1, 'tags': []};
const ctx = {
args: {
filter: filter
},
req: {accessToken: {userId: 1}}
};
const field = 'size';
const newValue = 88;
await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
expect(result[field]).toEqual(newValue);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should change the value of a given column for filter tags', async() => {
const tx = await models.Buy.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {'tags': [{tagFk: 1, value: 'Brown'}]};
const ctx = {
args: {
filter: filter

View File

@ -3,7 +3,6 @@ module.exports = Self => {
require('../methods/entry/filter')(Self);
require('../methods/entry/getEntry')(Self);
require('../methods/entry/getBuys')(Self);
require('../methods/entry/addBuy')(Self);
require('../methods/entry/importBuys')(Self);
require('../methods/entry/importBuysPreview')(Self);
require('../methods/entry/lastItemBuys')(Self);

View File

@ -222,13 +222,6 @@
</vn-data-viewer>
<div fixed-bottom-right>
<vn-vertical style="align-items: center;">
<vn-button class="round md vn-mb-sm"
ng-click="model.insert({})"
icon="add"
vn-tooltip="Add buy"
tooltip-position="left"
vn-bind="+">
</vn-button>
<a ui-sref="entry.card.buy.import" >
<vn-button class="round md vn-mb-sm"
icon="publish"

View File

@ -13,11 +13,6 @@ export default class Controller extends Section {
query: `Buys/${buy.id}`,
method: 'patch'
};
} else {
options = {
query: `Entries/${this.entry.id}/addBuy`,
method: 'post'
};
}
this.$http[options.method](options.query, buy).then(res => {
if (!res.data) return;

View File

@ -25,17 +25,6 @@ describe('Entry buy', () => {
controller.saveBuy(buy);
$httpBackend.flush();
});
it(`should call the entry addBuy post route if the received buy has no ID`, () => {
controller.entry = {id: 1};
const buy = {itemFk: 1, quantity: 1, packageFk: 1};
const query = `Entries/${controller.entry.id}/addBuy`;
$httpBackend.expectPOST(query).respond(200);
controller.saveBuy(buy);
$httpBackend.flush();
});
});
describe('deleteBuys()', () => {

View File

@ -1,5 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
const print = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('createPdf', {
@ -26,9 +25,6 @@ module.exports = Self => {
Self.createPdf = async function(ctx, id, options) {
const models = Self.app.models;
if (process.env.NODE_ENV == 'test')
throw new UserError(`Action not allowed on the test environment`);
let tx;
const myOptions = {};
@ -41,40 +37,20 @@ module.exports = Self => {
}
try {
const invoiceOut = await Self.findById(id, null, myOptions);
const invoiceOut = await Self.findById(id, {fields: ['hasPdf']}, myOptions);
if (invoiceOut.hasPdf) {
const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE');
if (invoiceOut.hasPdf && !canCreatePdf)
if (!canCreatePdf)
throw new UserError(`You don't have enough privileges`);
}
await invoiceOut.updateAttributes({
hasPdf: true
}, myOptions);
const invoiceReport = new print.Report('invoice', {
reference: invoiceOut.ref,
recipientId: invoiceOut.clientFk
});
const buffer = await invoiceReport.toPdfStream();
const issued = invoiceOut.issued;
const year = issued.getFullYear().toString();
const month = (issued.getMonth() + 1).toString();
const day = issued.getDate().toString();
const fileName = `${year}${invoiceOut.ref}.pdf`;
// Store invoice
await print.storage.write(buffer, {
type: 'invoice',
path: `${year}/${month}/${day}`,
fileName: fileName
});
await Self.makePdf(id, myOptions);
if (tx) await tx.commit();
} catch (e) {
} catch (err) {
if (tx) await tx.rollback();
throw e;
throw err;
}
};
};

View File

@ -43,7 +43,9 @@ module.exports = Self => {
Object.assign(myOptions, options);
try {
const invoiceOut = await models.InvoiceOut.findById(id, null, myOptions);
const invoiceOut = await models.InvoiceOut.findById(id, {
fields: ['ref', 'issued']
}, myOptions);
const issued = invoiceOut.issued;
const year = issued.getFullYear().toString();
@ -73,7 +75,7 @@ module.exports = Self => {
return [stream, file.contentType, `filename="${file.name}"`];
} catch (error) {
if (error.code === 'ENOENT')
throw new UserError('The PDF document does not exists');
throw new UserError('The PDF document does not exist');
throw error;
}

View File

@ -51,6 +51,9 @@ module.exports = Self => {
const args = ctx.args;
const models = Self.app.models;
const myOptions = {userId: ctx.req.accessToken.userId};
const $t = ctx.req.__; // $translate
const origin = ctx.req.headers.origin;
let tx;
if (typeof options == 'object')
@ -109,17 +112,22 @@ module.exports = Self => {
], myOptions);
const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, myOptions);
if (newInvoice.id) {
if (!newInvoice)
throw new UserError('No tickets to invoice', 'notInvoiced');
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
invoiceOut = await models.InvoiceOut.findById(newInvoice.id, {
fields: ['id', 'ref', 'clientFk'],
include: {
relation: 'client'
relation: 'client',
scope: {
fields: ['email', 'isToBeMailed', 'salesPersonFk']
}
}
}, myOptions);
invoiceId = newInvoice.id;
}
if (tx) await tx.commit();
} catch (e) {
@ -127,8 +135,34 @@ module.exports = Self => {
throw e;
}
if (invoiceId) {
if (!invoiceOut.client().isToBeMailed) {
try {
await Self.makePdf(invoiceId);
} catch (err) {
console.error(err);
throw new UserError('Error while generating PDF', 'pdfError');
}
if (invoiceOut.client().isToBeMailed) {
try {
ctx.args = {
reference: invoiceOut.ref,
recipientId: args.clientId,
recipient: invoiceOut.client().email
};
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
} catch (err) {
const message = $t('Mail not sent', {
clientId: args.clientId,
clientUrl: `${origin}/#!/claim/${args.id}/summary`
});
const salesPersonId = invoiceOut.client().salesPersonFk;
if (salesPersonId)
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
throw new UserError('Error when sending mail to client', 'mailNotSent');
}
} else {
const query = `
CALL vn.report_print(
'invoice',
@ -138,15 +172,8 @@ module.exports = Self => {
'normal'
);`;
await models.InvoiceOut.rawSql(query, [args.printerFk, invoiceOut.ref]);
} else {
ctx.args = {
reference: invoiceOut.ref,
recipientId: invoiceOut.clientFk,
recipient: invoiceOut.client().email
};
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
}
}
return invoiceId;
};

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
const {Email} = require('vn-print');
module.exports = Self => {
@ -74,6 +75,10 @@ module.exports = Self => {
]
};
try {
return email.send(mailOptions);
} catch (err) {
throw new UserError('Error when sending mail to client', 'mailNotSent');
}
};
};

View File

@ -18,12 +18,14 @@ describe('InvoiceOut invoiceClient()', () => {
accessToken: {userId: userId},
__: value => {
return value;
}
},
headers: {origin: 'http://localhost'}
};
const ctx = {req: activeCtx};
it('should make a global invoicing', async() => {
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true)));
spyOn(models.InvoiceOut, 'invoiceEmail');
const tx = await models.InvoiceOut.beginTransaction({});

View File

@ -1,3 +1,5 @@
const print = require('vn-print');
module.exports = Self => {
require('../methods/invoiceOut/filter')(Self);
require('../methods/invoiceOut/summary')(Self);
@ -19,4 +21,34 @@ module.exports = Self => {
require('../methods/invoiceOut/getInvoiceDate')(Self);
require('../methods/invoiceOut/negativeBases')(Self);
require('../methods/invoiceOut/negativeBasesCsv')(Self);
Self.makePdf = async function(id, options) {
const fields = ['id', 'hasPdf', 'ref', 'issued'];
const invoiceOut = await Self.findById(id, {fields}, options);
const invoiceReport = new print.Report('invoice', {
reference: invoiceOut.ref
});
const buffer = await invoiceReport.toPdfStream();
const issued = invoiceOut.issued;
const year = issued.getFullYear().toString();
const month = (issued.getMonth() + 1).toString();
const day = issued.getDate().toString();
const fileName = `${year}${invoiceOut.ref}.pdf`;
// Store invoice
await invoiceOut.updateAttributes({
hasPdf: true
}, options);
if (process.env.NODE_ENV !== 'test') {
await print.storage.write(buffer, {
type: 'invoice',
path: `${year}/${month}/${day}`,
fileName: fileName
});
}
};
};

View File

@ -55,7 +55,11 @@
{{::error.address.nickname}}
</vn-td>
<vn-td expand>
<span class="chip alert">{{::error.message}}</span>
<span
class="chip"
ng-class="error.isWarning ? 'warning': 'alert'">
{{::error.message}}
</span>
</vn-td>
</vn-tr>
</vn-tbody>

View File

@ -19,12 +19,12 @@ class Controller extends Section {
}
getInvoiceDate(companyFk) {
const params = { companyFk: companyFk };
const params = {companyFk: companyFk};
this.fetchInvoiceDate(params);
}
fetchInvoiceDate(params) {
this.$http.get('InvoiceOuts/getInvoiceDate', { params })
this.$http.get('InvoiceOuts/getInvoiceDate', {params})
.then(res => {
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
this.invoiceDate = this.minInvoicingDate;
@ -49,7 +49,7 @@ class Controller extends Section {
if (this.invoiceDate < this.maxShipped)
throw new UserError('Invoice date can\'t be less than max date');
if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
throw new UserError('Exists an invoice with a previous date');
throw new UserError('Exists an invoice with a future date');
if (!this.companyFk)
throw new UserError('Choose a valid company');
if (!this.printerFk)
@ -108,16 +108,30 @@ class Controller extends Section {
this.$http.post(`InvoiceOuts/invoiceClient`, params)
.then(() => this.invoiceNext())
.catch(res => {
const message = res.data?.error?.message || res.message;
if (res.status >= 400 && res.status < 500) {
this.errors.unshift({address, message});
const error = res.data?.error;
let isWarning;
const filter = {
where: {
id: address.clientId
}
};
switch (error?.code) {
case 'pdfError':
case 'mailNotSent':
isWarning = true;
break;
}
const message = error?.message || res.message;
this.errors.unshift({address, message, isWarning});
this.invoiceNext();
} else {
this.invoicing = false;
this.status = 'done';
throw new UserError(`Critical invoicing error, proccess stopped`);
}
})
});
}
invoiceNext() {

View File

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

View File

@ -5,10 +5,9 @@ module.exports = {
name: 'report-footer',
async serverPrefetch() {
this.company = await db.findOne(`
SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes
SELECT IFNULL(ci.footnotes, c.footnotes) footnotes
FROM company c
LEFT JOIN companyL10n cl ON c.id = cl.id
LEFT JOIN companyI18n ci ON ci.companyFk = cl.id
LEFT JOIN companyI18n ci ON ci.companyFk = c.id
AND ci.lang = (SELECT lang FROM account.user where id = ?)
WHERE c.code = ?`,
[this.recipientId, this.companyCode]);

View File

@ -46,14 +46,21 @@ module.exports = {
const fileNames = attachments.join(',\n');
await db.rawSql(`
INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, attachment, status)
VALUES (?, ?, 1, ?, ?, ?, ?)`, [
INSERT INTO vn.mail
SET receiver = ?,
replyTo = ?,
sent = ?,
subject = ?,
body = ?,
attachment = ?,
status = ?`, [
options.to,
options.replyTo,
error ? 2 : 1,
options.subject,
options.text || options.html,
fileNames,
error && error.message || 'Sent'
error && error.message || 'OK'
]);
}

View File

@ -16,6 +16,10 @@ h2 {
font-size: 22px
}
.column-oriented td,
.column-oriented th {
padding: 6px
}
#nickname h2 {
max-width: 400px;

View File

@ -62,7 +62,7 @@
</tbody>
</table>
</div>
<div class="vn-mt-lg" v-for="ticket in tickets">
<div class="vn-mt-ml" v-for="ticket in tickets">
<div class="table-title clearfix">
<div class="pull-left">
<h2>{{$t('deliveryNote')}}</h2>
@ -106,13 +106,6 @@
<td class="centered">{{sale.vatType}}</td>
<td class="number">{{saleImport(sale) | currency('EUR', $i18n.locale)}}</td>
</tr>
<tr class="description font light-gray">
<td colspan="7">
<span v-if="sale.value5"> <strong>{{sale.tag5}}</strong> {{sale.value5}} </span>
<span v-if="sale.value6"> <strong>{{sale.tag6}}</strong> {{sale.value6}} </span>
<span v-if="sale.value7"> <strong>{{sale.tag7}}</strong> {{sale.value7}} </span>
</td>
</tr>
</tbody>
<tfoot>
<tr>