show grade on client summary + fix insurance datetime #375
This commit is contained in:
parent
e863388346
commit
10953841ec
|
@ -6,7 +6,7 @@
|
|||
vn-one
|
||||
label="Credit"
|
||||
model="$ctrl.creditClassification.credit",
|
||||
rule="CreditInsurance.credit"
|
||||
rule="creditInsurance.credit"
|
||||
step="1"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
|
@ -20,7 +20,7 @@
|
|||
vn-one
|
||||
label="Since"
|
||||
model="$ctrl.creditClassification.started"
|
||||
ini-options="{dateFormat: 'd-m-Y'}">
|
||||
ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -14,7 +14,7 @@ class Controller {
|
|||
|
||||
submit() {
|
||||
if (this.$scope.form.$invalid)
|
||||
return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid'));
|
||||
return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
|
||||
|
||||
let query = `/client/api/creditClassifications/createWithInsurance`;
|
||||
let data = this.creditClassification;
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('Client', () => {
|
|||
describe('_getClassifications()', () => {
|
||||
it('should perform a GET query to define the classifications property in the controller', () => {
|
||||
let res = ['some classifications'];
|
||||
let query = '/client/api/CreditClassifications?filter=%7B%22order%22%3A%22finished%20ASC%2C%20started%20DESC%22%2C%22include%22%3A%5B%7B%22relation%22%3A%22creditInsurances%22%2C%22scope%22%3A%7B%22fields%22%3A%5B%22id%22%2C%22credit%22%2C%22created%22%2C%22grade%22%5D%2C%22order%22%3A%22created%20DESC%22%2C%22limit%22%3A2%7D%7D%5D%2C%22where%22%3A%7B%7D%7D';
|
||||
let query = '/client/api/CreditClassifications?filter=%7B%22order%22%3A%22finished%20ASC%2C%20started%20DESC%22%2C%22include%22%3A%5B%7B%22relation%22%3A%22insurances%22%2C%22scope%22%3A%7B%22fields%22%3A%5B%22id%22%2C%22credit%22%2C%22created%22%2C%22grade%22%5D%2C%22order%22%3A%22created%20DESC%22%2C%22limit%22%3A2%7D%7D%5D%2C%22where%22%3A%7B%7D%7D';
|
||||
|
||||
$httpBackend.whenGET(query).respond(res);
|
||||
$httpBackend.expectGET(query);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div><vn-label translate>To</vn-label> {{classification.finished | date:'dd/MM/yyyy'}}</div>
|
||||
</vn-one>
|
||||
<vn-vertical vn-one pad-medium-h>
|
||||
<vn-horizontal ng-repeat="insurance in classification.creditInsurances track by insurance.id">
|
||||
<vn-horizontal ng-repeat="insurance in classification.insurances track by insurance.id">
|
||||
<vn-one>
|
||||
<vn-label-value label="Credit"
|
||||
value="{{::insurance.credit}}">
|
||||
|
|
|
@ -17,7 +17,7 @@ class Controller {
|
|||
order: 'finished ASC, started DESC',
|
||||
include: [
|
||||
{
|
||||
relation: 'creditInsurances',
|
||||
relation: 'insurances',
|
||||
scope: {
|
||||
fields: ['id', 'credit', 'created', 'grade'],
|
||||
order: 'created DESC',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="/client/api/CreditClassifications/{{post.params.classificationId}}/creditInsurances" options="vnPost"></mg-ajax>
|
||||
<mg-ajax path="/client/api/CreditClassifications/{{post.params.classificationId}}/insurances" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.insurance"
|
||||
|
@ -22,7 +22,7 @@
|
|||
<vn-date-picker vn-one
|
||||
label="Date"
|
||||
model="$ctrl.insurance.created"
|
||||
ini-options="{enableTime: true, dateFormat: 'd-m-Y h:i', time_24hr: true}">
|
||||
ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -3,7 +3,7 @@ import ngModule from '../../../module';
|
|||
class Controller {
|
||||
constructor($filter) {
|
||||
this.insurance = {
|
||||
created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
|
||||
created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="/client/api/CreditClassifications/{{index.params.classificationId}}/creditInsurances" options="vnIndex"></mg-ajax>
|
||||
<mg-ajax path="/client/api/CreditClassifications/{{index.params.classificationId}}/insurances" options="vnIndex"></mg-ajax>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
|
|
|
@ -199,9 +199,16 @@
|
|||
<vn-label-value label="Credit"
|
||||
value="{{$ctrl.summary.credit | currency:'€ ':2}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Secured credit"
|
||||
value="{{$ctrl.summary.creditInsurance | currency:'€ ':2}}">
|
||||
</vn-label-value>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-label-value label="Secured credit"
|
||||
value="{{$ctrl.summary.creditInsurance | currency:'€ ':2}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one title="Grade">
|
||||
{{$ctrl.grade ? ' / ' + $ctrl.grade : ' / - '}}
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
|
|
|
@ -11,8 +11,12 @@ class Controller {
|
|||
return;
|
||||
|
||||
this.$http.get(`/client/api/Clients/${this.client.id}/summary`).then(res => {
|
||||
if (res && res.data)
|
||||
if (res && res.data) {
|
||||
this.summary = res.data;
|
||||
|
||||
if (res.data.classifications.length)
|
||||
this.grade = res.data.classifications[0].insurances[0].grade;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ describe('Item', () => {
|
|||
|
||||
describe('submit()', () => {
|
||||
it("should return an error message 'The barcode must be unique' when the code isnt unique", () => {
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.barcodes = [
|
||||
{code: 123454, itemFk: 1, id: 1},
|
||||
{code: 123454, itemFk: 1}
|
||||
|
@ -96,7 +96,7 @@ describe('Item', () => {
|
|||
controller.oldBarcodes = {1: {id: 1, code: 123454, itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The barcode must be unique');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('The barcode must be unique');
|
||||
});
|
||||
|
||||
it("should perfom a query to delete barcodes", () => {
|
||||
|
@ -131,7 +131,7 @@ describe('Item', () => {
|
|||
});
|
||||
|
||||
it("should return a message 'No changes to save' when there are no changes to apply", () => {
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.oldBarcodes = [
|
||||
{code: 1, itemFk: 1, id: 1},
|
||||
{code: 2, itemFk: 1, id: 2}
|
||||
|
@ -139,7 +139,7 @@ describe('Item', () => {
|
|||
controller.barcodes = [];
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -86,7 +86,7 @@ export default class Controller {
|
|||
}
|
||||
|
||||
if (repeatedBarcodes) {
|
||||
return this.vnApp.showMessage(this.$translate.instant('The barcode must be unique'));
|
||||
return this.vnApp.showError(this.$translate.instant('The barcode must be unique'));
|
||||
}
|
||||
|
||||
canSubmit = barcodesObj.update.length > 0 || barcodesObj.create.length > 0 || barcodesObj.delete.length > 0;
|
||||
|
@ -98,7 +98,7 @@ export default class Controller {
|
|||
this.$scope.watcher.notifySaved();
|
||||
});
|
||||
}
|
||||
this.vnApp.showMessage(this.$translate.instant('No changes to save'));
|
||||
this.vnApp.showError(this.$translate.instant('No changes to save'));
|
||||
}
|
||||
|
||||
setOldBarcodes(response) {
|
||||
|
|
|
@ -122,11 +122,11 @@ export default class Controller {
|
|||
});
|
||||
|
||||
if (this.$scope.form.$invalid) {
|
||||
return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid'));
|
||||
return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
|
||||
}
|
||||
|
||||
if (repeatedWarehouse) {
|
||||
return this.vnApp.showMessage(this.$translate.instant('The niche must be unique'));
|
||||
return this.vnApp.showError(this.$translate.instant('The niche must be unique'));
|
||||
}
|
||||
|
||||
canSubmit = nichesObj.update.length > 0 || nichesObj.create.length > 0 || nichesObj.delete.length > 0;
|
||||
|
@ -138,7 +138,7 @@ export default class Controller {
|
|||
this.$scope.watcher.notifySaved();
|
||||
});
|
||||
}
|
||||
this.vnApp.showMessage(this.$translate.instant('No changes to save'));
|
||||
this.vnApp.showError(this.$translate.instant('No changes to save'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ describe('Item', () => {
|
|||
describe('submit()', () => {
|
||||
it("should return an error message 'The niche must be unique' when the niche warehouse isnt unique", () => {
|
||||
controller.$scope.form = {};
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.niches = [
|
||||
{warehouseFk: 1, code: 123454, itemFk: 1, id: 1},
|
||||
{warehouseFk: 1, code: 123454, itemFk: 1}
|
||||
|
@ -106,7 +106,7 @@ describe('Item', () => {
|
|||
controller.oldNiches = {1: {warehouseFk: 1, id: 1, code: 123454, itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The niche must be unique');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('The niche must be unique');
|
||||
});
|
||||
|
||||
it("should perfom a query to delete niches", () => {
|
||||
|
@ -144,7 +144,7 @@ describe('Item', () => {
|
|||
|
||||
it("should return a message 'No changes to save' when there are no changes to apply", () => {
|
||||
controller.$scope.form = {$setPristine: () => {}};
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.oldNiches = [
|
||||
{warehouseFk: 1, code: 1, itemFk: 1, id: 1},
|
||||
{warehouseFk: 2, code: 2, itemFk: 1, id: 2}
|
||||
|
@ -152,7 +152,7 @@ describe('Item', () => {
|
|||
controller.niches = [];
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -132,7 +132,7 @@ describe('Item', () => {
|
|||
// TODO: Server validation should be implemented
|
||||
xit("should return an error message 'The tag must be unique' when the tag value isnt unique", () => {
|
||||
controller.$.form = [];
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.tags = [
|
||||
{typeFk: 1, value: 123454, itemFk: 1, id: 1},
|
||||
{typeFk: 1, value: 123454, itemFk: 1}
|
||||
|
@ -140,7 +140,7 @@ describe('Item', () => {
|
|||
controller.orgTags = {1: {typeFk: 1, id: 1, value: 123454, itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The tag must be unique');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('The tag must be unique');
|
||||
});
|
||||
|
||||
it("should perfom a query to delete tags", () => {
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class Controller {
|
|||
|
||||
let url = `/item/api/Items/${this.$stateParams.id}/updateTaxes`;
|
||||
this.$http.post(url, data).then(
|
||||
() => this.vnApp.showMessage(this._.instant('Data saved!'))
|
||||
() => this.vnApp.showSuccess(this._.instant('Data saved!'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,11 +106,11 @@ class Controller {
|
|||
});
|
||||
|
||||
if (this.$scope.form.$invalid) {
|
||||
return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid'));
|
||||
return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
|
||||
}
|
||||
|
||||
if (repeatedType) {
|
||||
return this.vnApp.showMessage(this.$translate.instant('The observation type must be unique'));
|
||||
return this.vnApp.showError(this.$translate.instant('The observation type must be unique'));
|
||||
}
|
||||
|
||||
canSubmit = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||
|
@ -122,7 +122,7 @@ class Controller {
|
|||
this.$scope.watcher.notifySaved();
|
||||
});
|
||||
}
|
||||
this.vnApp.showMessage(this.$translate.instant('No changes to save'));
|
||||
this.vnApp.showError(this.$translate.instant('No changes to save'));
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
|
|
|
@ -90,7 +90,7 @@ describe('ticket', () => {
|
|||
it("should return an error message 'Some fields are invalid'", () => {
|
||||
controller.$scope.form = {};
|
||||
controller.$scope.form.$invalid = true;
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.ticketObservations = [
|
||||
{id: 1, observationTypeFk: 1, description: 'one', itemFk: 1},
|
||||
{observationTypeFk: 1, description: 'one', itemFk: 1}
|
||||
|
@ -98,12 +98,12 @@ describe('ticket', () => {
|
|||
controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Some fields are invalid');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('Some fields are invalid');
|
||||
});
|
||||
|
||||
it("should return an error message 'The observation type must be unique'", () => {
|
||||
controller.$scope.form = {};
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.ticketObservations = [
|
||||
{id: 1, observationTypeFk: 1, description: 'one', itemFk: 1},
|
||||
{observationTypeFk: 1, description: 'one', itemFk: 1}
|
||||
|
@ -111,7 +111,7 @@ describe('ticket', () => {
|
|||
controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The observation type must be unique');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('The observation type must be unique');
|
||||
});
|
||||
|
||||
it("should perfom a query to delete observations", () => {
|
||||
|
@ -149,7 +149,7 @@ describe('ticket', () => {
|
|||
|
||||
it("should return a message 'No changes to save' when there are no changes to apply", () => {
|
||||
controller.$scope.form = {$setPristine: () => {}};
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
spyOn(controller.vnApp, 'showError').and.callThrough();
|
||||
controller.oldObservations = [
|
||||
{id: 1, observationTypeFk: 1, description: 'one', showAddIcon: false},
|
||||
{id: 2, observationTypeFk: 2, description: 'two', showAddIcon: true}
|
||||
|
@ -157,7 +157,7 @@ describe('ticket', () => {
|
|||
controller.ticketObservations = [];
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save');
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,10 +26,10 @@ class Controller {
|
|||
});
|
||||
|
||||
if (this.$.form.$invalid)
|
||||
return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid'));
|
||||
return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
|
||||
|
||||
if (!this.hasChanges(packagesObj))
|
||||
return this.vnApp.showMessage(this.$translate.instant('No changes to save'));
|
||||
return this.vnApp.showError(this.$translate.instant('No changes to save'));
|
||||
|
||||
this.$http.post(query, packagesObj).then(res => {
|
||||
this.$.index.accept();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"model": "Client",
|
||||
"foreignKey": "client"
|
||||
},
|
||||
"creditInsurances": {
|
||||
"insurances": {
|
||||
"type": "hasMany",
|
||||
"model": "CreditInsurance",
|
||||
"foreignKey": "creditClassification"
|
||||
|
|
|
@ -47,6 +47,19 @@ module.exports = Self => {
|
|||
where: {isDefaultAddress: true},
|
||||
fields: ['nickname', 'street', 'city', 'postalCode']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'classifications',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'insurances',
|
||||
scope: {
|
||||
fields: ['id', 'grade', 'created'],
|
||||
order: 'created DESC'
|
||||
}
|
||||
},
|
||||
where: {finished: null}
|
||||
}
|
||||
}
|
||||
],
|
||||
where: {id: clientId}
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
"model": "Greuge",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"creditClassifications": {
|
||||
"classifications": {
|
||||
"type": "hasMany",
|
||||
"model": "CreditClassification",
|
||||
"foreignKey": "client"
|
||||
|
|
Loading…
Reference in New Issue