Credit insurance refactor #328
This commit is contained in:
parent
d6f0be2209
commit
c0167edc3e
|
@ -34,7 +34,7 @@
|
|||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
<a vn-auto ui-sref="client.card.creditInsurance.insurance.index({classificationId: {{classification.id}}})">
|
||||
<vn-icon-button icon="desktop_windows" vn-tooltip="List classifications"></vn-icon-button>
|
||||
<vn-icon-button icon="desktop_windows" vn-tooltip="View credits"></vn-icon-button>
|
||||
</a>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
|
|
|
@ -2,5 +2,6 @@ Contract credit insurance: Contratos de seguro de crédito
|
|||
New contract: Nuevo contrato
|
||||
Close contract: Cerrar contrato
|
||||
Edit contract: Modificar contrato
|
||||
List classifications: Ver clasificaciones
|
||||
Are you sure you want to close this contract?: ¿Seguro que quieres cerrar este contrato?
|
||||
View credits: Ver créditos
|
||||
Are you sure you want to close this contract?: ¿Seguro que quieres cerrar este contrato?
|
||||
Grade: Grado
|
|
@ -8,7 +8,7 @@
|
|||
<form name="form"
|
||||
ng-submit="watcher.submitGo('client.card.creditInsurance.insurance.index', {classificationId: post.params.classificationId})">
|
||||
<vn-card pad-large>
|
||||
<vn-title>New classification</vn-title>
|
||||
<vn-title>New credit</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
|
@ -37,5 +37,9 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<button
|
||||
class="mdl-button mdl-button--raised mdl-button--colored"
|
||||
translate
|
||||
ui-sref="client.card.creditInsurance.insurance.index({classificationId: post.params.classificationId})">Cancel</button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,15 +1,14 @@
|
|||
import ngModule from '../../../module';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $filter) {
|
||||
constructor($filter) {
|
||||
this.insurance = {
|
||||
created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
|
||||
};
|
||||
this.classificationId = $state.params.classificationId;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$state', '$filter'];
|
||||
Controller.$inject = ['$filter'];
|
||||
|
||||
ngModule.component('vnClientCreditInsuranceInsuranceCreate', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -1 +1 @@
|
|||
New classification: Nueva clasificación
|
||||
New credit: Nuevo crédito
|
|
@ -1,31 +1,38 @@
|
|||
<mg-ajax path="/client/api/CreditInsurances/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||
<mg-ajax path="/client/api/CreditClassifications/{{index.params.classificationId}}/creditInsurances" options="vnIndex"></mg-ajax>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-title>Requested credits</vn-title>
|
||||
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
||||
<vn-column-header vn-one pad-medium-h field="credit" text="Credit"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="grade" text="Grade"></vn-column-header>
|
||||
<vn-column-header vn-two pad-medium-h field="created" text="Created" default-order="DESC"></vn-column-header>
|
||||
</vn-grid-header>
|
||||
<vn-one class="list list-content">
|
||||
<vn-horizontal
|
||||
vn-one class="list list-element text-center"
|
||||
pad-small-bottom
|
||||
ng-repeat="insurance in index.model.instances track by insurance.id">
|
||||
<vn-one pad-medium-h>{{::insurance.credit}}</vn-one>
|
||||
<vn-one pad-medium-h>{{::insurance.grade}}</vn-one>
|
||||
<vn-two pad-medium-h>{{::insurance.created | date: 'dd/MM/yyyy'}}</vn-two>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
|
||||
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th number translate>Credit</th>
|
||||
<th number translate>Grade</th>
|
||||
<th translate>Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="insurance in index.model track by insurance.id" class="list list-element">
|
||||
<td number>{{::insurance.credit | currency: '€': 2}}</td>
|
||||
<td number>{{::insurance.grade}}</td>
|
||||
<td>{{::insurance.created | date: 'dd/MM/yyyy'}}</td>
|
||||
</tr>
|
||||
<tr ng-if="index.model.count === 0" class="list list-element">
|
||||
<td colspan="6" style="text-align: center" translate>No results</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<button
|
||||
class="mdl-button mdl-button--raised mdl-button--colored"
|
||||
translate
|
||||
ui-sref="client.card.creditInsurance.index">Back</button>
|
||||
</vn-button-bar>
|
||||
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
|
||||
<!-- <vn-auto-paging vn-one margin-large-top index="index" total="index.model.count" items="$ctrl.instances"></vn-auto-paging> -->
|
||||
</vn-vertical>
|
||||
<a ui-sref="client.card.creditInsurance.insurance.create({classificationId: {{index.params.classificationId}}})"
|
||||
fixed-bottom-right vn-tooltip="New classification" vn-bind="+" ng-if="!$ctrl.isClosed">
|
||||
fixed-bottom-right vn-tooltip="New credit" vn-bind="+" ng-if="!$ctrl.isClosed">
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -21,3 +21,4 @@ Credit contracts: Contratos de crédito
|
|||
Verified data: Datos comprobados
|
||||
Mandate: Mandato
|
||||
Amount: Importe
|
||||
Back: Volver
|
|
@ -1,14 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.installMethod('filter', filterParams);
|
||||
|
||||
function filterParams(params) {
|
||||
return {
|
||||
where: {
|
||||
creditClassification: params.creditClassificationFk
|
||||
},
|
||||
skip: (params.page - 1) * params.size,
|
||||
limit: params.size,
|
||||
order: params.order
|
||||
};
|
||||
}
|
||||
};
|
|
@ -1,6 +1,4 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/credit-insurance/filter')(Self);
|
||||
|
||||
Self.validateCredit = function(credit) {
|
||||
return credit >= 0;
|
||||
};
|
||||
|
@ -20,6 +18,26 @@ module.exports = function(Self) {
|
|||
allowNull: true
|
||||
});
|
||||
|
||||
async function validateNullGrade(err, done) {
|
||||
let filter = {
|
||||
fields: ['grade'],
|
||||
where: {
|
||||
creditClassification: this.creditClassification
|
||||
},
|
||||
order: 'created DESC'
|
||||
};
|
||||
let insurance = await Self.findOne(filter);
|
||||
|
||||
if (insurance && (!insurance.grade && this.grade || insurance.grade && ! this.grade))
|
||||
err();
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
Self.validateAsync('nullGrade', validateNullGrade, {
|
||||
message: 'The grade must be similar to the last one'
|
||||
});
|
||||
|
||||
Self.messageSend = async function(data, accessToken) {
|
||||
let filter = {
|
||||
include: {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"That payment method requires an IBAN": "El método de pago seleccionado requiere que se especifique el IBAN",
|
||||
"State cannot be blank": "El estado no puede estar en blanco",
|
||||
"Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado",
|
||||
"EXPIRED_DATE": "EXPIRED_DATE",
|
||||
"NO_AGENCY_AVAILABLE": "NO_AGENCY_AVAILABLE"
|
||||
"NO_AGENCY_AVAILABLE": "NO_AGENCY_AVAILABLE",
|
||||
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
|
||||
"The grade must be similar to the last one": "El grado debe ser similar al último crédito"
|
||||
}
|
|
@ -75,7 +75,7 @@ function vnBoot(app, rootDir, rootModule) {
|
|||
let packageJson = require(`${rootDir}/../package.json`);
|
||||
let appName = packageJson.name;
|
||||
let baseUrl = app.get('url').replace(/\/$/, '');
|
||||
console.log(`Web server ${appName} listening at: %s`, baseUrl);
|
||||
console.log(`Web server ${appName} listening at: %s`, `${baseUrl}/explorer`);
|
||||
}
|
||||
|
||||
let args = port ? [port, onListen] : [onListen];
|
||||
|
|
Loading…
Reference in New Issue