7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +00:00
13 changed files with 111 additions and 86 deletions
Showing only changes of commit c048389412 - Show all commits

24
db/dbWatcher.js Normal file
View File

@ -0,0 +1,24 @@
const fs = require('fs');
const {spawn} = require('child_process');
function watchDatabaseChanges() {
console.log('Watching for changes in db/routines and db/versions');
fs.watch('db', {recursive: true}, (eventType, filename) => {
if (filename.endsWith('.sql')) {
let command;
if (filename.startsWith('routines')) command = 'push';
else if (filename.startsWith('versions')) command = 'run';
if (command) {
const process = spawn('myt', [command]);
process.stdout.on('data', data => console.log(data.toString()));
process.stderr.on('data', data => console.error(`stderr: ${data}`));
process.on('error', error => console.error(`error: ${error.message}`));
process.on('close', () => console.log('Watching for changes in db/routines and db/versions'));
}
}
});
}
if (require.main === module) watchDatabaseChanges();
module.exports = watchDatabaseChanges;

View File

@ -53,7 +53,7 @@ BEGIN
IFNULL(c.street, ''),
c.accountingAccount,
@fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)),
IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)),
IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)),
IFNULL(c.postcode, ''),
IFNULL(c.city, ''),
IFNULL(pr.CodigoProvincia, ''),
@ -91,7 +91,7 @@ BEGIN
IFNULL(s.street, ''),
s.account,
@nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)),
IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)),
IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)),
IFNULL(s.postCode,''),
IFNULL(s.city, ''),
IFNULL(pr.CodigoProvincia, ''),

View File

@ -1,56 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`(
vItemFk INT,
vWarehouseFk INT,
vQuantity INT,
vIsTrash BOOLEAN)
BEGIN
DECLARE vTicketFk INT;
DECLARE vClientFk INT;
DECLARE vCompanyVnlFk INT DEFAULT 442;
DECLARE vCalc INT;
SELECT barcodeToItem(vItemFk) INTO vItemFk;
SELECT IF(vIsTrash, 200, 400) INTO vClientFk;
SELECT t.id INTO vTicketFk
FROM ticket t
JOIN address a ON a.id=t.addressFk
WHERE t.warehouseFk = vWarehouseFk
AND t.clientFk = vClientFk
AND DATE(t.shipped) = util.VN_CURDATE()
AND a.isDefaultAddress
LIMIT 1;
CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk);
IF vTicketFk IS NULL THEN
CALL ticket_add(
vClientFk,
util.VN_CURDATE(),
vWarehouseFk,
vCompanyVnlFk,
NULL,
NULL,
NULL,
util.VN_CURDATE(),
account.myUser_getId(),
FALSE,
vTicketFk);
END IF;
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
SELECT vTicketFk,
vItemFk,
CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
vQuantity
FROM item
WHERE id = vItemFk;
UPDATE cache.visible
SET visible = visible - vQuantity
WHERE calc_id = vCalc
AND item_id = vItemFk;
END$$
DELIMITER ;

View File

@ -0,0 +1,6 @@
ALTER TABLE vn.country
ADD IF NOT EXISTS viesCode varchar(2) DEFAULT NULL NULL AFTER code;
UPDATE IGNORE vn.country
SET viesCode = 'FR'
WHERE code = 'MC'; -- Mónaco

View File

@ -6,6 +6,7 @@ const log = require('fancy-log');
const Myt = require('@verdnatura/myt/myt');
const Run = require('@verdnatura/myt/myt-run');
const Start = require('@verdnatura/myt/myt-start');
const watchDatabaseChanges = require('./db/dbWatcher');
// Configuration
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
function watch(done) {
gulp.watch(routeFiles, gulp.series(routes));
gulp.watch(localeFiles, gulp.series(locales));
watchDatabaseChanges();
done();
}
watch.description = `Watches for changes in routes and locale files`;

View File

@ -33,7 +33,6 @@ module.exports = Self => {
try {
await Self.makePdf(id, options);
} catch (err) {
console.error(err);
throw new UserError('Error while generating PDF', 'pdfError');
}

View File

@ -36,6 +36,11 @@ module.exports = Self => {
type: 'number',
required: true
},
{
arg: 'checked',
type: 'boolean',
required: true
},
],
returns: {
type: 'boolean',
@ -51,6 +56,7 @@ module.exports = Self => {
const models = Self.app.models;
const myOptions = {userId: ctx.req.accessToken.userId};
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
const checked = ctx.args.checked;
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -96,9 +102,10 @@ module.exports = Self => {
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
if (!checked) {
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
return invoiceId;
}
} catch (e) {
if (tx) await tx.rollback();
throw e;

View File

@ -1,15 +1,3 @@
<vn-crud-model
auto-load="true"
url="CplusRectificationTypes"
data="cplusRectificationTypes"
order="description">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="SiiTypeInvoiceOuts"
data="siiTypeInvoiceOuts"
where="{code: {like: 'R%'}}">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="InvoiceCorrectionTypes"
@ -211,14 +199,14 @@
vn-one
vn-id="cplusRectificationType"
required="true"
data="cplusRectificationTypes"
data="$ctrl.cplusRectificationTypes"
show-field="description"
value-field="id"
ng-model="$ctrl.cplusRectificationType"
search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}"
label="Rectificative type">
<tpl-item>
{{::description}}
{{ ::description}}
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
@ -226,7 +214,7 @@
<vn-autocomplete
vn-one
vn-id="siiTypeInvoiceOut"
data="siiTypeInvoiceOuts"
data="$ctrl.siiTypeInvoiceOuts"
show-field="description"
value-field="id"
fields="['id','code','description']"
@ -248,6 +236,14 @@
label="Type">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-check
ng-model="$ctrl.isChecked"
label="destinationClient"
info="transferInvoiceInfo"
/>
</vn-check>
</vn-horizontal>
</section>
</tpl-body>
<tpl-buttons>

View File

@ -7,6 +7,7 @@ class Controller extends Section {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
this.checked = true;
}
get invoiceOut() {
@ -23,6 +24,26 @@ class Controller extends Section {
return this.aclService.hasAny(['invoicing']);
}
get isChecked() {
return this.checked;
}
set isChecked(value) {
this.checked = value;
}
$onInit() {
this.$http.get(`CplusRectificationTypes`, {filter: {order: 'description'}})
.then(res => {
this.cplusRectificationTypes = res.data;
this.cplusRectificationType = res.data.filter(type => type.description == 'I Por diferencias')[0].id;
});
this.$http.get(`SiiTypeInvoiceOuts`, {filter: {where: {code: {like: 'R%'}}}})
.then(res => {
this.siiTypeInvoiceOuts = res.data;
this.siiTypeInvoiceOut = res.data.filter(type => type.code == 'R4')[0].id;
});
}
loadData() {
const filter = {
include: [
@ -34,7 +55,7 @@ class Controller extends Section {
}, {
relation: 'client',
scope: {
fields: ['id', 'name', 'email']
fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
}
}
]
@ -136,13 +157,25 @@ class Controller extends Section {
newClientFk: this.clientId,
cplusRectificationTypeFk: this.cplusRectificationType,
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
invoiceCorrectionTypeFk: this.invoiceCorrectionType
invoiceCorrectionTypeFk: this.invoiceCorrectionType,
checked: this.checked
};
this.$http.get(`Clients/${this.clientId}`).then(response => {
const clientData = response.data;
const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
if (this.checked && hasToInvoiceByAddress) {
if (!window.confirm(this.$t('confirmTransferInvoice')))
return;
}
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
const invoiceId = res.data;
this.vnApp.showSuccess(this.$t('Transferred invoice'));
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
});
});
}
}

View File

@ -1,3 +1,7 @@
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
Transfer invoice to...: Transfer invoice to...
Cplus Type: Cplus Type
transferInvoice: Transfer Invoice
destinationClient: Bill destination client
transferInvoiceInfo: New tickets from the destination customer will be generated in the default consignee.
confirmTransferInvoice: Destination customer has marked to bill by consignee, do you want to continue?

View File

@ -24,3 +24,7 @@ Refund...: Abono...
Transfer invoice to...: Transferir factura a...
Rectificative type: Tipo rectificativa
Transferred invoice: Factura transferida
transferInvoice: Transferir factura
destinationClient: Facturar cliente destino
transferInvoiceInfo: Los nuevos tickets del cliente destino serán generados en el consignatario por defecto.
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?

View File

@ -19,6 +19,9 @@ module.exports = Self => {
type: 'number',
required: true,
description: 'The requested item quantity',
}, {
arg: 'attenderFk',
type: 'number'
}],
returns: {
type: 'object',
@ -73,12 +76,14 @@ module.exports = Self => {
ticketFk: request.ticketFk,
itemFk: ctx.args.itemFk,
quantity: ctx.args.quantity,
attenderFk: ctx.args.attenderFk,
concept: item.name
}, myOptions);
await request.updateAttributes({
saleFk: sale.id,
itemFk: sale.itemFk,
isOk: true
isOk: true,
attenderFk: sale.attenderFk,
}, myOptions);
const query = `CALL vn.sale_calculateComponent(?, NULL)`;

View File

@ -113,7 +113,8 @@
"test:e2e": "node e2e/tests.js",
"test:front": "jest --watch",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
"lint": "eslint ./ --cache --ignore-pattern .gitignore"
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
"watch:db": "node ./db/dbWatcher.js"
},
"jest": {
"projects": [