Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 5194-cambios-ticketFutureAdvance
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
8b088e831a
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Client', 'getClientOrSupplierReference', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -67,7 +67,7 @@ module.exports = function(Self) {
|
|||
|
||||
try {
|
||||
delete args.ctx; // Remove unwanted properties
|
||||
const newReceipt = await models.Receipt.create(args, myOptions);
|
||||
|
||||
const originalClient = await models.Client.findById(args.clientFk, null, myOptions);
|
||||
const bank = await models.Bank.findById(args.bankFk, null, myOptions);
|
||||
const accountingType = await models.AccountingType.findById(bank.accountingTypeFk, null, myOptions);
|
||||
|
@ -76,23 +76,8 @@ module.exports = function(Self) {
|
|||
if (!args.compensationAccount)
|
||||
throw new UserError('Compensation account is empty');
|
||||
|
||||
const supplierCompensation = await models.Supplier.findOne({
|
||||
where: {
|
||||
account: args.compensationAccount
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
let clientCompensation = {};
|
||||
|
||||
if (!supplierCompensation) {
|
||||
clientCompensation = await models.Client.findOne({
|
||||
where: {
|
||||
accountingAccount: args.compensationAccount
|
||||
}
|
||||
}, myOptions);
|
||||
}
|
||||
if (!supplierCompensation && !clientCompensation)
|
||||
throw new UserError('Invalid account');
|
||||
// Check compensation account exists
|
||||
await models.Client.getClientOrSupplierReference(args.compensationAccount, myOptions);
|
||||
|
||||
await Self.rawSql(
|
||||
`CALL vn.ledger_doCompensation(?, ?, ?, ?, ?, ?, ?)`,
|
||||
|
@ -151,7 +136,7 @@ module.exports = function(Self) {
|
|||
myOptions
|
||||
);
|
||||
}
|
||||
|
||||
const newReceipt = await models.Receipt.create(args, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return newReceipt;
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getClientOrSupplierReference', {
|
||||
description: 'Returns the reference of a compensation providing a bank account',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'bankAccount',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The bank account of a client or a supplier'
|
||||
},
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getClientOrSupplierReference`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getClientOrSupplierReference = async(bankAccount, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let reference = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const supplierCompensation = await models.Supplier.findOne({
|
||||
where: {
|
||||
account: bankAccount
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
reference.supplierId = supplierCompensation?.id;
|
||||
reference.supplierName = supplierCompensation?.name;
|
||||
|
||||
let clientCompensation = {};
|
||||
|
||||
if (!supplierCompensation) {
|
||||
clientCompensation = await models.Client.findOne({
|
||||
where: {
|
||||
accountingAccount: bankAccount
|
||||
}
|
||||
}, myOptions);
|
||||
reference.clientId = clientCompensation?.id;
|
||||
reference.clientName = clientCompensation?.name;
|
||||
}
|
||||
|
||||
if (!supplierCompensation && !clientCompensation)
|
||||
throw new UserError('Invalid account');
|
||||
|
||||
return reference;
|
||||
};
|
||||
};
|
|
@ -47,4 +47,5 @@ module.exports = Self => {
|
|||
require('../methods/client/incotermsAuthorizationEmail')(Self);
|
||||
require('../methods/client/consumptionSendQueued')(Self);
|
||||
require('../methods/client/filter')(Self);
|
||||
require('../methods/client/getClientOrSupplierReference')(Self);
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</vn-crud-model>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
label="Date"
|
||||
label="Date"
|
||||
ng-model="$ctrl.receipt.payed"
|
||||
required="true">
|
||||
</vn-date-picker>
|
||||
|
@ -48,6 +48,14 @@
|
|||
max="$ctrl.maxAmount">
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-vertical ng-show="$ctrl.bankSelection.accountingType.code == 'compensation'">
|
||||
<h6 translate>Compensation</h6>
|
||||
<vn-textfield
|
||||
ng-model="$ctrl.receipt.compensationAccount"
|
||||
label="Compensation Account"
|
||||
on-change="$ctrl.accountShortToStandard(value)">
|
||||
</vn-textfield>
|
||||
</vn-vertical>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Reference"
|
||||
|
@ -71,17 +79,9 @@
|
|||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
<vn-vertical ng-show="$ctrl.bankSelection.accountingType.code == 'compensation'">
|
||||
<h6 translate>Compensation</h6>
|
||||
<vn-textfield
|
||||
ng-model="$ctrl.receipt.compensationAccount"
|
||||
label="Compensation Account"
|
||||
on-change="$ctrl.accountShortToStandard(value)">
|
||||
</vn-textfield>
|
||||
</vn-vertical>
|
||||
<vn-horizontal ng-show="$ctrl.bankSelection.accountingType.code == 'cash'">
|
||||
<vn-check
|
||||
label="View receipt"
|
||||
<vn-check
|
||||
label="View receipt"
|
||||
ng-model="$ctrl.viewReceipt">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
|
@ -89,4 +89,4 @@
|
|||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate vn-focus>Accept</button>
|
||||
</tpl-buttons>
|
||||
</tpl-buttons>
|
||||
|
|
|
@ -60,11 +60,15 @@ class Controller extends Dialog {
|
|||
const accountingType = value.accountingType;
|
||||
|
||||
this.viewReceipt = accountingType.code == 'cash';
|
||||
if (accountingType.receiptDescription != null) {
|
||||
this.receipt.description = accountingType.receiptDescription;
|
||||
if (this.originalDescription) this.receipt.description += `, ${this.originalDescription}`;
|
||||
} else if (this.originalDescription)
|
||||
this.receipt.description = this.originalDescription;
|
||||
if (accountingType.code == 'compensation')
|
||||
this.receipt.description = '';
|
||||
else {
|
||||
if (accountingType.receiptDescription != null) {
|
||||
this.receipt.description = accountingType.receiptDescription;
|
||||
if (this.originalDescription) this.receipt.description += `, ${this.originalDescription}`;
|
||||
} else if (this.originalDescription)
|
||||
this.receipt.description = this.originalDescription;
|
||||
}
|
||||
this.maxAmount = accountingType && accountingType.maxAmount;
|
||||
|
||||
this.receipt.payed = new Date();
|
||||
|
@ -110,7 +114,25 @@ class Controller extends Dialog {
|
|||
}
|
||||
|
||||
accountShortToStandard(value) {
|
||||
this.receipt.compensationAccount = value.replace('.', '0'.repeat(11 - value.length));
|
||||
if (value) {
|
||||
this.receipt.compensationAccount = value.replace('.', '0'.repeat(11 - value.length));
|
||||
const params = {bankAccount: this.receipt.compensationAccount};
|
||||
this.$http.get(`Clients/getClientOrSupplierReference`, {params})
|
||||
.then(res => {
|
||||
if (res.data.clientId) {
|
||||
this.receipt.description = this.$t('Client Compensation Reference', {
|
||||
clientId: res.data.clientId,
|
||||
clientName: res.data.clientName
|
||||
});
|
||||
} else {
|
||||
this.receipt.description = this.$t('Supplier Compensation Reference', {
|
||||
supplierId: res.data.supplierId,
|
||||
supplierName: res.data.supplierName
|
||||
});
|
||||
}
|
||||
});
|
||||
} else
|
||||
this.receipt.description = '';
|
||||
}
|
||||
|
||||
getAmountPaid() {
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
View receipt: Ver recibo
|
||||
Amount exceeded: Según ley contra el fraude no se puede recibir cobros por importe igual o superior a {{maxAmount}}
|
||||
Amount exceeded: Según ley contra el fraude no se puede recibir cobros por importe igual o superior a {{maxAmount}}
|
||||
Client Compensation Reference: "({{clientId}}) Ntro Cliente: {{clientName}}"
|
||||
Supplier Compensation Reference: "({{supplierId}}) Ntro Proveedor: {{supplierName}}"
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
</p>
|
||||
<h4 style="text-align: center; margin-top: 10%">{{$t('Agree') | uppercase}}</h4>
|
||||
<p style="margin-top: 8%; text-align: justify">
|
||||
{{$t('Date')}} {{formatDate(client.payed, '%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
|
||||
{{$t('From client')}} {{client.name}} {{$t('Toclient')}} {{company.name}}.
|
||||
{{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
|
||||
{{$t('From client')}} {{client.name}} {{$t('Against the balance of')}}: {{client.invoiceFk}}.
|
||||
</p>
|
||||
<p style="margin-top: 8%">
|
||||
{{$t('Reception')}} <span style="color: blue">administracion@verdnatura.es</span>
|
||||
|
|
|
@ -4,13 +4,13 @@ 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
|
||||
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
|
||||
Compensate: se ha compensado el saldo de
|
||||
From client: del cliente/proveedor
|
||||
To client: con el cliente/proveedor
|
||||
Against the balance of: contra el saldo de
|
||||
Reception: Por favor, rogamos confirmen la recepción de esta compensación al email
|
||||
Greetings: Saludos cordiales,
|
||||
Greetings: Saludos cordiales,
|
||||
|
|
|
@ -4,6 +4,7 @@ SELECT
|
|||
c.street,
|
||||
c.fi,
|
||||
c.city,
|
||||
r.invoiceFk,
|
||||
r.amountPaid,
|
||||
r.payed
|
||||
FROM client c
|
||||
|
|
Loading…
Reference in New Issue