refs #4547 correcciones
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2022-11-02 15:54:23 +01:00
parent 8d8d217fe7
commit 908908a643
18 changed files with 65 additions and 43 deletions

View File

@ -1,13 +1,13 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('debBalancesCompEmail', {
Self.remoteMethodCtx('balanceCompensationEmail', {
description: 'Sends the debit balances compensation email with an attached PDF',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'number',
type: 'Number',
required: true,
description: 'The receipt id',
http: { source: 'path' }
@ -18,20 +18,20 @@ module.exports = Self => {
root: true
},
http: {
path: '/:id/deb-balances-comp-email',
path: '/:id/balance-compensation-email',
verb: 'POST'
}
});
Self.debBalancesCompEmail = async (ctx, id) => {
Self.balanceCompensationEmail = async (ctx, id) => {
const models = Self.app.models;
const receipt = await models.Receipt.findById(id, {fields: ['clientFk']});
const client = await models.Client.findById(receipt.clientFk, {fields:['email']});
const email = new Email('deb-balances-comp', {
const email = new Email('balance-compensation', {
lang: ctx.req.getLocale(),
recipient: client.name+',administracion@verdnatura.es',
recipient: client.email+',administracion@verdnatura.es',
id
});

View File

@ -1,7 +1,7 @@
const { Report } = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('debBalancesCompPdf', {
Self.remoteMethodCtx('balanceCompensationPdf', {
description: 'Returns the the debit balances compensation pdf',
accessType: 'READ',
accepts: [
@ -29,12 +29,12 @@ module.exports = Self => {
}
],
http: {
path: '/:id/deb-balances-comp-pdf',
path: '/:id/balance-compensation-pdf',
verb: 'GET'
}
});
Self.debBalancesCompPdf = async(ctx, id) => {
Self.balanceCompensationPdf = async(ctx, id) => {
const args = Object.assign({}, ctx.args);
const params = {lang: ctx.req.getLocale()};
@ -42,7 +42,7 @@ module.exports = Self => {
for (const param in args)
params[param] = args[param];
const report = new Report('deb-balances-comp', params);
const report = new Report('balance-compensation', params);
const stream = await report.toPdfStream();
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];

View File

@ -2,8 +2,8 @@ const LoopBackContext = require('loopback-context');
module.exports = function(Self) {
require('../methods/receipt/filter')(Self);
require('../methods/receipt/debBalancesCompEmail')(Self);
require('../methods/receipt/debBalancesCompPdf')(Self);
require('../methods/receipt/balanceCompensationEmail')(Self);
require('../methods/receipt/balanceCompensationPdf')(Self);
Self.validateBinded('amountPaid', isNotZero, {
message: 'Amount cannot be zero',

View File

@ -2,9 +2,8 @@ import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $, vnReport, vnEmail) {
constructor($element, $, vnEmail) {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
this.filter = {
include: {
@ -94,11 +93,11 @@ class Controller extends Section {
}
sendEmail(balance) {
return this.vnEmail.send(`Receipts/${balance.id}/deb-balances-comp-email`);
return this.vnEmail.send(`Receipts/${balance.id}/balance-compensation-email`);
}
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
Controller.$inject = ['$element', '$scope', 'vnEmail'];
ngModule.vnComponent('vnClientBalanceIndex', {
template: require('./index.html'),

View File

@ -0,0 +1,6 @@
[
{
"filename": "balance-compensation.pdf",
"component": "balance-compensation"
}
]

View File

@ -5,7 +5,7 @@ const attachment = new Component('attachment');
module.exports = {
name: 'deb-balances-comp',
name: 'balance-compensation',
async serverPrefetch() {
this.client = await this.fetchClient(this.id);
},
@ -23,9 +23,9 @@ module.exports = {
return {
attachments: [
{
filename: 'deb-balances-comp.pdf',
filename: 'balance-compensation.pdf',
type: 'pdf',
path: `Receipts/${this.id}/deb-balances-comp-pdf`
path: `Receipts/${this.id}/balance-compensation-pdf`
}
]
};

View File

@ -1,6 +0,0 @@
[
{
"filename": "deb-balances-comp.pdf",
"component": "deb-balances-comp"
}
]

View File

@ -13,16 +13,16 @@
<div class="grid-block">
<div class="columns">
<div class="size50">
<p style="text-align: right;">Algemesí, a {{currentDate()}}</p>
<h3 style="text-align: center; margin-top: 8%;">{{'Compensación de saldos deudores y acreedores' | uppercase}}</h3>
<p style="margin-top: 8%;">De una parte:</p>
<p style="text-align: justify;">Verdnatura Levante SL con CIF B-97367486 y domicilio sito en calle Fenollar 2, Valencia.</p>
<p style="margin-top: 5%;">De la otra:</p>
<p style="text-align: justify;">Don/Doña {{client.name}} con NIF {{client.fi}}, y domicilio sito en {{client.street}}, {{client.city}}.</p>
<h4 style="text-align: center;margin-top: 10%;">{{'Acuerdan' | uppercase}}</h4>
<p style="margin-top: 8%;text-align: justify;">En fecha de {{client.payed | date('%d-%m-%Y')}} se ha compensado el saldo de {{client.amountPaid}} € del cliente/proveedor {{client.name}} con el cliente/proveedor Verdnatura Levante SL.</p>
<p style="margin-top: 8%;">Por favor, rogamos confirmen la recepción de esta compensación al email <span style="color:blue">administracion@verdnatura.es</span></p>
<div style="margin-top: 8%;"><small >Saludos cordiales,</small></div>
<p style="text-align: right;">{{$t('Place')}} {{currentDate()}}</p>
<h3 style="text-align: center; margin-top: 8%;">{{$t('Compensation') | uppercase}}</h3>
<p style="margin-top: 8%;">{{$t('In one hand')}}:</p>
<p style="text-align: justify;">{{company.name}} {{$t('CIF')}} {{company.nif}} {{$t('Home')}} {{company.street}}, {{company.city}}.</p>
<p style="margin-top: 5%;">{{$t('In other hand')}}:</p>
<p style="text-align: justify;">{{$t('Sr')}} {{client.name}} {{$t('NIF')}} {{client.fi}} {{$t('Home')}} {{client.street}}, {{client.city}}.</p>
<h4 style="text-align: center;margin-top: 10%;">{{$t('Agree') | uppercase}}</h4>
<p style="margin-top: 8%;text-align: justify;">{{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} € {{$t('From client')}} {{client.name}} {{$t('To client')}} {{company.name}}.</p>
<p style="margin-top: 8%;">{{$t('Reception')}} <span style="color:blue">administracion@verdnatura.es</span></p>
<div style="margin-top: 8%;"><small >{{$t('Greetings')}}</small></div>
</div>
</div>
</div>

View File

@ -1,19 +1,20 @@
const config = require(`vn-print/core/config`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const md5 = require('md5');
const fs = require('fs-extra');
module.exports = {
name: 'deb-balances-comp',
name: 'balance-compensation',
async serverPrefetch() {
this.client = await this.fetchClient(this.id);
this.company = await this.fetchCompany();
},
methods: {
fetchClient(id) {
return this.findOneFromDef('client', [id]);
},
fetchCompany() {
return this.findOneFromDef('company');
},
currentDate() {
const current = new Date();
@ -27,7 +28,7 @@ module.exports = {
},
props: {
id: {
type: [Number, String],
type: Number,
required: true,
description: 'The receipt id'
}

View File

@ -0,0 +1,16 @@
reportName: compensacion-saldo
Place: Algemesí, a
Compensation: Compensación de saldos deudores y acreedores
In one hand: De una parte
CIF: con CIF
NIF: con NIF
Home: y domicilio sito en
In other hand: De la otra
Sr: Don/Doña
Agree: Acuerdan
Date: En fecha de
Compensate: se ha compensado el saldo de
From client: del cliente/proveedor
To client: con el cliente/proveedor
Reception: Por favor, rogamos confirmen la recepción de esta compensación al email
Greetings: Saludos cordiales,

View File

@ -7,6 +7,6 @@ SELECT
r.amountPaid,
r.payed
FROM client c
JOIN receipt r ON r.clientFk = c.id
JOIN supplier s ON c.fi = s.nif
JOIN receipt r ON r.clientFk = c.id
JOIN supplier s ON c.fi = s.nif
WHERE r.id = ?;

View File

@ -0,0 +1,7 @@
SELECT
s.name,
s.nif,
s.street,
s.city
FROM supplier s
WHERE s.id = 442;

View File

@ -1 +0,0 @@
reportName: compensacion-saldo