This commit is contained in:
parent
8d8d217fe7
commit
908908a643
|
@ -1,13 +1,13 @@
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('debBalancesCompEmail', {
|
Self.remoteMethodCtx('balanceCompensationEmail', {
|
||||||
description: 'Sends the debit balances compensation email with an attached PDF',
|
description: 'Sends the debit balances compensation email with an attached PDF',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
type: 'number',
|
type: 'Number',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The receipt id',
|
description: 'The receipt id',
|
||||||
http: { source: 'path' }
|
http: { source: 'path' }
|
||||||
|
@ -18,20 +18,20 @@ module.exports = Self => {
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/deb-balances-comp-email',
|
path: '/:id/balance-compensation-email',
|
||||||
verb: 'POST'
|
verb: 'POST'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.debBalancesCompEmail = async (ctx, id) => {
|
Self.balanceCompensationEmail = async (ctx, id) => {
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const receipt = await models.Receipt.findById(id, {fields: ['clientFk']});
|
const receipt = await models.Receipt.findById(id, {fields: ['clientFk']});
|
||||||
const client = await models.Client.findById(receipt.clientFk, {fields:['email']});
|
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(),
|
lang: ctx.req.getLocale(),
|
||||||
recipient: client.name+',administracion@verdnatura.es',
|
recipient: client.email+',administracion@verdnatura.es',
|
||||||
id
|
id
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { Report } = require('vn-print');
|
const { Report } = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('debBalancesCompPdf', {
|
Self.remoteMethodCtx('balanceCompensationPdf', {
|
||||||
description: 'Returns the the debit balances compensation pdf',
|
description: 'Returns the the debit balances compensation pdf',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
|
@ -29,12 +29,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/deb-balances-comp-pdf',
|
path: '/:id/balance-compensation-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.debBalancesCompPdf = async(ctx, id) => {
|
Self.balanceCompensationPdf = async(ctx, id) => {
|
||||||
const args = Object.assign({}, ctx.args);
|
const args = Object.assign({}, ctx.args);
|
||||||
const params = {lang: ctx.req.getLocale()};
|
const params = {lang: ctx.req.getLocale()};
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ module.exports = Self => {
|
||||||
for (const param in args)
|
for (const param in args)
|
||||||
params[param] = args[param];
|
params[param] = args[param];
|
||||||
|
|
||||||
const report = new Report('deb-balances-comp', params);
|
const report = new Report('balance-compensation', params);
|
||||||
const stream = await report.toPdfStream();
|
const stream = await report.toPdfStream();
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
@ -2,8 +2,8 @@ const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/receipt/filter')(Self);
|
require('../methods/receipt/filter')(Self);
|
||||||
require('../methods/receipt/debBalancesCompEmail')(Self);
|
require('../methods/receipt/balanceCompensationEmail')(Self);
|
||||||
require('../methods/receipt/debBalancesCompPdf')(Self);
|
require('../methods/receipt/balanceCompensationPdf')(Self);
|
||||||
|
|
||||||
Self.validateBinded('amountPaid', isNotZero, {
|
Self.validateBinded('amountPaid', isNotZero, {
|
||||||
message: 'Amount cannot be zero',
|
message: 'Amount cannot be zero',
|
||||||
|
|
|
@ -2,9 +2,8 @@ import ngModule from '../../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $, vnReport, vnEmail) {
|
constructor($element, $, vnEmail) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.vnReport = vnReport;
|
|
||||||
this.vnEmail = vnEmail;
|
this.vnEmail = vnEmail;
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: {
|
include: {
|
||||||
|
@ -94,11 +93,11 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEmail(balance) {
|
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', {
|
ngModule.vnComponent('vnClientBalanceIndex', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "balance-compensation.pdf",
|
||||||
|
"component": "balance-compensation"
|
||||||
|
}
|
||||||
|
]
|
|
@ -5,7 +5,7 @@ const attachment = new Component('attachment');
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'deb-balances-comp',
|
name: 'balance-compensation',
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.fetchClient(this.id);
|
||||||
},
|
},
|
||||||
|
@ -23,9 +23,9 @@ module.exports = {
|
||||||
return {
|
return {
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
filename: 'deb-balances-comp.pdf',
|
filename: 'balance-compensation.pdf',
|
||||||
type: 'pdf',
|
type: 'pdf',
|
||||||
path: `Receipts/${this.id}/deb-balances-comp-pdf`
|
path: `Receipts/${this.id}/balance-compensation-pdf`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
|
@ -1,6 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"filename": "deb-balances-comp.pdf",
|
|
||||||
"component": "deb-balances-comp"
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -13,16 +13,16 @@
|
||||||
<div class="grid-block">
|
<div class="grid-block">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="size50">
|
<div class="size50">
|
||||||
<p style="text-align: right;">Algemesí, a {{currentDate()}}</p>
|
<p style="text-align: right;">{{$t('Place')}} {{currentDate()}}</p>
|
||||||
<h3 style="text-align: center; margin-top: 8%;">{{'Compensación de saldos deudores y acreedores' | uppercase}}</h3>
|
<h3 style="text-align: center; margin-top: 8%;">{{$t('Compensation') | uppercase}}</h3>
|
||||||
<p style="margin-top: 8%;">De una parte:</p>
|
<p style="margin-top: 8%;">{{$t('In one hand')}}:</p>
|
||||||
<p style="text-align: justify;">Verdnatura Levante SL con CIF B-97367486 y domicilio sito en calle Fenollar 2, Valencia.</p>
|
<p style="text-align: justify;">{{company.name}} {{$t('CIF')}} {{company.nif}} {{$t('Home')}} {{company.street}}, {{company.city}}.</p>
|
||||||
<p style="margin-top: 5%;">De la otra:</p>
|
<p style="margin-top: 5%;">{{$t('In other hand')}}:</p>
|
||||||
<p style="text-align: justify;">Don/Doña {{client.name}} con NIF {{client.fi}}, y domicilio sito en {{client.street}}, {{client.city}}.</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%;">{{'Acuerdan' | uppercase}}</h4>
|
<h4 style="text-align: center;margin-top: 10%;">{{$t('Agree') | 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%;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%;">Por favor, rogamos confirmen la recepción de esta compensación al email <span style="color:blue">administracion@verdnatura.es</span></p>
|
<p style="margin-top: 8%;">{{$t('Reception')}} <span style="color:blue">administracion@verdnatura.es</span></p>
|
||||||
<div style="margin-top: 8%;"><small >Saludos cordiales,</small></div>
|
<div style="margin-top: 8%;"><small >{{$t('Greetings')}}</small></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -1,19 +1,20 @@
|
||||||
const config = require(`vn-print/core/config`);
|
|
||||||
const Component = require(`vn-print/core/component`);
|
const Component = require(`vn-print/core/component`);
|
||||||
const reportHeader = new Component('report-header');
|
const reportHeader = new Component('report-header');
|
||||||
const reportFooter = new Component('report-footer');
|
const reportFooter = new Component('report-footer');
|
||||||
const md5 = require('md5');
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'deb-balances-comp',
|
name: 'balance-compensation',
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.fetchClient(this.id);
|
||||||
|
this.company = await this.fetchCompany();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchClient(id) {
|
fetchClient(id) {
|
||||||
return this.findOneFromDef('client', [id]);
|
return this.findOneFromDef('client', [id]);
|
||||||
},
|
},
|
||||||
|
fetchCompany() {
|
||||||
|
return this.findOneFromDef('company');
|
||||||
|
},
|
||||||
|
|
||||||
currentDate() {
|
currentDate() {
|
||||||
const current = new Date();
|
const current = new Date();
|
||||||
|
@ -27,7 +28,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: [Number, String],
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The receipt id'
|
description: 'The receipt id'
|
||||||
}
|
}
|
|
@ -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,
|
|
@ -7,6 +7,6 @@ SELECT
|
||||||
r.amountPaid,
|
r.amountPaid,
|
||||||
r.payed
|
r.payed
|
||||||
FROM client c
|
FROM client c
|
||||||
JOIN receipt r ON r.clientFk = c.id
|
JOIN receipt r ON r.clientFk = c.id
|
||||||
JOIN supplier s ON c.fi = s.nif
|
JOIN supplier s ON c.fi = s.nif
|
||||||
WHERE r.id = ?;
|
WHERE r.id = ?;
|
|
@ -0,0 +1,7 @@
|
||||||
|
SELECT
|
||||||
|
s.name,
|
||||||
|
s.nif,
|
||||||
|
s.street,
|
||||||
|
s.city
|
||||||
|
FROM supplier s
|
||||||
|
WHERE s.id = 442;
|
|
@ -1 +0,0 @@
|
||||||
reportName: compensacion-saldo
|
|
Loading…
Reference in New Issue