Merge branch 'dev'

This commit is contained in:
Daniel Herrero 2017-11-15 13:12:01 +01:00
commit 31a22cf4e3
17 changed files with 155 additions and 106 deletions

View File

@ -48,7 +48,7 @@
"client": "$ctrl.client" "client": "$ctrl.client"
}, },
"menu": { "menu": {
"description": "Datos facturación", "description": "Pay method",
"icon": "assignment" "icon": "assignment"
} }
}, { }, {

View File

@ -36,6 +36,7 @@
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-one <vn-autocomplete vn-one
initial-data="$ctrl.address.defaultAgency"
field="$ctrl.address.defaultAgencyFk" field="$ctrl.address.defaultAgencyFk"
url="/client/api/AgencyModes" url="/client/api/AgencyModes"
show-field="name" show-field="name"

View File

@ -10,17 +10,20 @@
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Basic data</vn-title> <vn-title>Basic data</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Name" field="$ctrl.client.name" vn-focus></vn-textfield> <vn-textfield vn-one label="Comercial Name" field="$ctrl.client.name" vn-focus></vn-textfield>
<vn-textfield vn-one label="Tax number" field="$ctrl.client.fi"></vn-textfield> <vn-textfield vn-one label="Contact" field="$ctrl.client.contact"></vn-textfield>
<vn-textfield autofocus vn-one label="Social name" field="$ctrl.client.socialName"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Phone" field="$ctrl.client.phone"></vn-textfield> <vn-textfield vn-one label="Phone" field="$ctrl.client.phone"></vn-textfield>
<vn-textfield vn-one label="Mobile" field="$ctrl.client.mobile"></vn-textfield> <vn-textfield vn-one label="Mobile" field="$ctrl.client.mobile"></vn-textfield>
<vn-textfield vn-one label="Fax" field="$ctrl.client.fax"></vn-textfield> <vn-textfield vn-one
label="Email"
field="$ctrl.client.email"
info="You can save multiple emails by chaining them using comma without spaces, example: user@domain.com,user2@domain.com the first email will be considered as the main"
>
</vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Email" field="$ctrl.client.email" info="You can save multiple emails by chaining them using comma without spaces, example: user@domain.com,user2@domain.com the first email will be considered as the main"></vn-textfield>
<vn-autocomplete vn-one <vn-autocomplete vn-one
initial-data="$ctrl.client.salesPerson" initial-data="$ctrl.client.salesPerson"
field="$ctrl.client.salesPersonFk" field="$ctrl.client.salesPersonFk"

View File

@ -1,6 +1,6 @@
{ {
"Basic data": "Datos básicos", "Basic data": "Datos básicos",
"Name": "Nombre", "Comercial Name": "Nombre comercial",
"Tax number": "NIF/CIF", "Tax number": "NIF/CIF",
"Social name": "Razón social", "Social name": "Razón social",
"Phone": "Teléfono", "Phone": "Teléfono",
@ -9,5 +9,6 @@
"Email": "Correo electrónico", "Email": "Correo electrónico",
"Salesperson": "Comercial", "Salesperson": "Comercial",
"Channel": "Canal", "Channel": "Canal",
"You can save multiple emails by chaining them using comma without spaces, example: user@domain.com,user2@domain.com the first email will be considered as the main": "Puede guardar varios correos electrónicos encadenándolos mediante comas sin espacios, ejemplo: user@dominio.com,user2@dominio.com siendo el primer correo electrónico el principal" "You can save multiple emails by chaining them using comma without spaces, example: user@domain.com,user2@domain.com the first email will be considered as the main": "Puede guardar varios correos electrónicos encadenándolos mediante comas sin espacios, ejemplo: user@dominio.com,user2@dominio.com siendo el primer correo electrónico el principal",
"Contact": "Contacto"
} }

View File

@ -8,7 +8,7 @@
<form name="form" ng-submit="$ctrl.submit()" pad-medium> <form name="form" ng-submit="$ctrl.submit()" pad-medium>
<vn-card margin-small-bottom> <vn-card margin-small-bottom>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Billing information</vn-title> <vn-title>Pay method</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-two <vn-autocomplete vn-two
vn-acl="administrative" vn-acl="administrative"
@ -16,33 +16,16 @@
url="/client/api/PayMethods" url="/client/api/PayMethods"
select-fields="ibanRequired" select-fields="ibanRequired"
initial-data="$ctrl.client.payMethod" initial-data="$ctrl.client.payMethod"
label="Forma de pago"> label="Pay method">
</vn-autocomplete> </vn-autocomplete>
<vn-textfield vn-two label="IBAN" field="$ctrl.client.iban" vn-acl="administrative"></vn-textfield> <vn-textfield vn-two label="IBAN" field="$ctrl.client.iban" vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="Vencimiento" field="$ctrl.client.dueDay" vn-acl="administrative"></vn-textfield> <vn-textfield vn-one label="Vencimiento" field="$ctrl.client.dueDay" vn-acl="administrative"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Descuento" field="$ctrl.client.discount" vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="Crédito" field="$ctrl.client.credit" vn-acl="administrative"></vn-textfield> <vn-textfield vn-one label="Crédito" field="$ctrl.client.credit" vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="Crédito asegurado" field="$ctrl.client.creditInsurance" vn-acl="administrative"></vn-textfield> <vn-textfield vn-one label="Crédito asegurado" field="$ctrl.client.creditInsurance" vn-acl="administrative"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal margin-medium-bottom>
<vn-one>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Invoice by address" field="$ctrl.client.hasToInvoiceByAddress" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Documentación</vn-title>
<vn-horizontal>
<vn-one> <vn-one>
<vn-check label="Recibido core VNH" field="$ctrl.client.coreVnh" vn-acl="administrative"></vn-check> <vn-check label="Recibido core VNH" field="$ctrl.client.coreVnh" vn-acl="administrative"></vn-check>
</vn-one> </vn-one>
@ -55,6 +38,7 @@
</vn-horizontal> </vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Guardar" vn-acl="administrative"></vn-submit> <vn-submit label="Guardar" vn-acl="administrative"></vn-submit>
</vn-button-bar> </vn-button-bar>
@ -73,17 +57,3 @@
<button response="ACCEPT" translate>Yes, notify</button> <button response="ACCEPT" translate>Yes, notify</button>
</tpl-buttons> </tpl-buttons>
</vn-dialog> </vn-dialog>
<vn-dialog
vn-id="propagate-equalizationTax"
on-response="$ctrl.returnDialogEt(response)">
<tpl-body>
<vn-vertical>
<vn-one text-center translate>You changes the equivalent tax</vn-one>
<vn-one text-center translate>Do you want to spread the change to their consignees?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, propagate</button>
</tpl-buttons>
</vn-dialog>

View File

@ -9,11 +9,9 @@ export default class Controller {
this.billData = {}; this.billData = {};
this.copyData(); this.copyData();
} }
$onChanges() { $onChanges() {
this.copyData(); this.copyData();
} }
copyData() { copyData() {
if (this.client) { if (this.client) {
this.billData.payMethodFk = this.client.payMethodFk; this.billData.payMethodFk = this.client.payMethodFk;
@ -22,15 +20,12 @@ export default class Controller {
this.billData.discount = this.client.discount; this.billData.discount = this.client.discount;
this.billData.credit = this.client.credit; this.billData.credit = this.client.credit;
this.billData.creditInsurance = this.client.creditInsurance; this.billData.creditInsurance = this.client.creditInsurance;
this.equalizationTax = this.client.equalizationTax;
} }
} }
submit() { submit() {
return this.$.watcher.submit().then( return this.$.watcher.submit().then(
() => this.checkPaymentChanges()); () => this.checkPaymentChanges());
} }
checkPaymentChanges() { checkPaymentChanges() {
let equals = true; let equals = true;
Object.keys(this.billData).forEach( Object.keys(this.billData).forEach(
@ -42,40 +37,15 @@ export default class Controller {
} }
); );
if (equals) { if (!equals) {
this.checkEtChanges();
} else {
this.$.sendMail.show(); this.$.sendMail.show();
} }
} }
returnDialog(response) { returnDialog(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
this.$http.post(`/mailer/manuscript/payment-update/${this.client.id}`).then( this.$http.post(`/mailer/manuscript/payment-update/${this.client.id}`).then(
() => { () => {
this.vnApp.showMessage(this.translate.instant('Notification sent!')); this.vnApp.showMessage(this.translate.instant('Notification sent!'));
this.checkEtChanges();
}
);
} else {
this.checkEtChanges();
}
}
checkEtChanges() {
let equals = this.equalizationTax == this.client.equalizationTax;
this.equalizationTax = this.client.equalizationTax;
if (!equals)
this.$.propagateEqualizationTax.show();
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
this.$http.patch(`/client/api/Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.equalizationTax}).then(
res => {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
} }
); );
} }

View File

@ -5,31 +5,29 @@
form="form" form="form"
save="patch"> save="patch">
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="watcher.submit()" pad-medium> <form name="form" ng-submit="$ctrl.submit()" pad-medium>
<vn-card margin-small-bottom> <vn-card margin-small-bottom>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Fiscal data</vn-title> <vn-title>Fiscal data</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-one> <vn-textfield autofocus vn-two label="Social name" field="$ctrl.client.socialName" vn-acl="administrative"></vn-textfield>
<vn-check label="Has to invoice" field="$ctrl.client.hasToInvoice"></vn-check> <vn-textfield vn-one label="Tax number" field="$ctrl.client.fi" vn-acl="administrative"></vn-textfield>
</vn-one>
<vn-one>
<vn-check label="Invoice by mail" field="$ctrl.client.invoiceByEmail"></vn-check>
</vn-one>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-two label="Street" field="$ctrl.client.street" vn-focus></vn-textfield> <vn-textfield vn-two label="Street" field="$ctrl.client.street" vn-focus vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="City" field="$ctrl.client.city"></vn-textfield> <vn-textfield vn-one label="City" field="$ctrl.client.city" vn-acl="administrative"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Postcode" field="$ctrl.client.postcode"></vn-textfield> <vn-textfield vn-one label="Postcode" field="$ctrl.client.postcode" vn-acl="administrative"></vn-textfield>
<vn-autocomplete vn-one <vn-autocomplete vn-one
initial-data="$ctrl.client.province" initial-data="$ctrl.client.province"
field="$ctrl.client.provinceFk" field="$ctrl.client.provinceFk"
url="/client/api/Provinces" url="/client/api/Provinces"
show-field="name" show-field="name"
value-field="id" value-field="id"
label="Province"> label="Province"
vn-acl="administrative"
>
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-one <vn-autocomplete vn-one
initial-data="$ctrl.client.country" initial-data="$ctrl.client.country"
@ -37,13 +35,52 @@
url="/client/api/Countries" url="/client/api/Countries"
show-field="name" show-field="name"
value-field="id" value-field="id"
label="Country"> label="Country"
vn-acl="administrative"
>
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal margin-small-bottom>
<vn-one>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Invoice by address" field="$ctrl.client.hasToInvoiceByAddress" vn-acl="administrative" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one></vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<vn-check label="Has to invoice" field="$ctrl.client.hasToInvoice" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Invoice by mail" field="$ctrl.client.invoiceByEmail" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"></vn-submit> <vn-submit label="Save"></vn-submit>
</vn-button-bar> </vn-button-bar>
</form> </form>
<vn-dialog
vn-id="propagate-equalizationTax"
on-response="$ctrl.returnDialogEt(response)"
>
<tpl-body>
<vn-vertical>
<vn-one text-center translate>You changes the equivalent tax</vn-one>
<vn-one text-center translate>Do you want to spread the change to their consignees?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, propagate</button>
</tpl-buttons>
</vn-dialog>

View File

@ -1,7 +1,54 @@
import ngModule from '../module'; import ngModule from '../module';
export default class ClientFiscalData {
constructor($scope, $http, vnApp, $translate) {
this.$ = $scope;
this.$http = $http;
this.vnApp = vnApp;
this.translate = $translate;
this.equalizationTax = undefined;
this.copyData();
}
$onChanges() {
this.copyData();
}
copyData() {
if (this.client) {
this.equalizationTax = this.client.equalizationTax;
}
}
submit() {
return this.$.watcher.submit().then(
() => this.checkEtChanges());
}
checkEtChanges() {
let equals = this.equalizationTax == this.client.equalizationTax;
this.equalizationTax = this.client.equalizationTax;
if (!equals)
this.$.propagateEqualizationTax.show();
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
this.$http.patch(`/client/api/Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.equalizationTax}).then(
res => {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
}
);
}
}
}
ClientFiscalData.$inject = ['$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnClientFiscalData', { ngModule.component('vnClientFiscalData', {
template: require('./fiscal-data.html'), template: require('./fiscal-data.html'),
controller: ClientFiscalData,
bindings: { bindings: {
client: '<' client: '<'
} }

View File

@ -9,5 +9,6 @@
"City": "Municipio", "City": "Municipio",
"Postcode": "Código postal", "Postcode": "Código postal",
"Province": "Provincia", "Province": "Provincia",
"Save": "Guardar" "Save": "Guardar",
"Pay method" : "Forma de pago"
} }

View File

@ -1,8 +1,8 @@
import ngModule from '../module'; import ngModule from '../module';
export default class Controller { export default class Controller {
constructor($window) { constructor(sessionStorage) {
this.$window = $window; this.sessionStorage = sessionStorage;
// onSubmit() is defined by @vnSearchbar // onSubmit() is defined by @vnSearchbar
this.onSubmit = () => {}; this.onSubmit = () => {};
} }
@ -13,16 +13,16 @@ export default class Controller {
} }
$onChanges() { $onChanges() {
var value = JSON.parse(this.$window.sessionStorage.getItem('filter')); var value = this.sessionStorage.get('filter');
if (value !== undefined) if (value !== undefined)
this.filter = value; this.filter = value;
} }
setStorageValue() { setStorageValue() {
this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); this.sessionStorage.set('filter', this.filter);
} }
} }
Controller.$inject = ['$window']; Controller.$inject = ['sessionStorage'];
ngModule.component('vnClientSearchPanel', { ngModule.component('vnClientSearchPanel', {
template: require('./search-panel.html'), template: require('./search-panel.html'),

View File

@ -3,17 +3,17 @@ import './search-panel.js';
describe('Client', () => { describe('Client', () => {
describe('Component vnClientSearchPanel', () => { describe('Component vnClientSearchPanel', () => {
let $componentController; let $componentController;
let $window; let sessionStorage;
let controller; let controller;
beforeEach(() => { beforeEach(() => {
angular.mock.module('client'); angular.mock.module('client');
}); });
beforeEach(angular.mock.inject((_$componentController_, _$window_) => { beforeEach(angular.mock.inject((_$componentController_, _sessionStorage_) => {
$componentController = _$componentController_; $componentController = _$componentController_;
$window = _$window_; sessionStorage = _sessionStorage_;
controller = $componentController('vnClientSearchPanel', {$window: $window}); controller = $componentController('vnClientSearchPanel', {sessionStorage: sessionStorage});
})); }));
describe('onSearch()', () => { describe('onSearch()', () => {
@ -31,10 +31,10 @@ describe('Client', () => {
describe('$onChanges()', () => { describe('$onChanges()', () => {
it('should set filter properties using the search values', () => { it('should set filter properties using the search values', () => {
expect(controller.filter).not.toBeDefined(); expect(controller.filter).not.toBeDefined();
spyOn(JSON, 'parse').and.returnValue({data: 'data'}); spyOn(sessionStorage, 'get').and.returnValue({data: 'data'});
controller.$onChanges(); controller.$onChanges();
expect(controller.filter).toBe(JSON.parse({data: 'data'})); expect(controller.filter).toBe(sessionStorage.get({data: 'data'}));
}); });
}); });
}); });

View File

@ -39,6 +39,11 @@ export default class Paging {
this.pageChange(); this.pageChange();
} }
} }
$doCheck() {
if (this.index && this.index.filter && this.index.filter.page && this.index.filter.page != this.currentPage) {
this.currentPage = this.index.filter.page;
}
}
} }
Paging.$inject = ['$http', '$scope']; Paging.$inject = ['$http', '$scope'];

View File

@ -8,7 +8,7 @@
"url": "/production", "url": "/production",
"state": "production", "state": "production",
"component": "vn-production-index", "component": "vn-production-index",
"acl": ["employee"] "acl": ["developer"]
} }
] ]
} }

View File

@ -9,6 +9,6 @@
style="cursor: pointer;"> style="cursor: pointer;">
</vn-icon> </vn-icon>
<vn-button ng-if="$ctrl.label" vn-none label="{{$ctrl.label}}"></vn-button> <vn-button ng-if="$ctrl.label" vn-none label="{{$ctrl.label}}"></vn-button>
<vn-icon-button ng-if="!$ctrl.label" icon="search"></vn-icon-button> <vn-icon-button ng-if="!$ctrl.label" icon="search" ng-click="$ctrl.clearFilter()"></vn-icon-button>
</vn-horizontal> </vn-horizontal>
</form> </form>

View File

@ -1,15 +1,22 @@
import ngModule from '../../module'; import ngModule from '../../module';
export default class Controller { export default class Controller {
constructor($element, $scope, $document, $compile, vnPopover, $window) { constructor($element, $scope, $document, $compile, vnPopover, sessionStorage, $timeout) {
this.element = $element[0]; this.element = $element[0];
this.$scope = $scope; this.$scope = $scope;
this.$document = $document; this.$document = $document;
this.$compile = $compile; this.$compile = $compile;
this.vnPopover = vnPopover; this.vnPopover = vnPopover;
this.$window = $window; this.sessionStorage = sessionStorage;
this.$timeout = $timeout;
}
clearFilter() {
this.index.filter = {};
this.sessionStorage.remove('filter');
} }
onClick(event) { onClick(event) {
this.search = null;
this.child = this.vnPopover.showComponent(this.popover, this.$scope, this.element); this.child = this.vnPopover.showComponent(this.popover, this.$scope, this.element);
// XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente? // XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente?
@ -37,10 +44,10 @@ export default class Controller {
delete this.child; delete this.child;
} }
$onDestroy() { $onDestroy() {
this.$window.sessionStorage.removeItem('filter'); this.clearFilter();
} }
} }
Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', '$window']; Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', 'sessionStorage', '$timeout'];
ngModule.component('vnSearchbar', { ngModule.component('vnSearchbar', {
template: require('./searchbar.html'), template: require('./searchbar.html'),

View File

@ -25,12 +25,19 @@ module.exports = function(Self) {
Self.beforeRemote('findById', function(ctx, modelInstance, next) { Self.beforeRemote('findById', function(ctx, modelInstance, next) {
ctx.args.filter = { ctx.args.filter = {
include: { include: [{
relation: "province", relation: "province",
scope: { scope: {
fields: ["id", "name"] fields: ["id", "name"]
} }
},
{
relation: "defaultAgency",
scope: {
fields: ["id", "name"]
} }
}
]
}; };
next(); next();
}); });

View File

@ -58,7 +58,7 @@
}, },
"defaultAgency": { "defaultAgency": {
"type": "belongsTo", "type": "belongsTo",
"model": "Agency", "model": "AgencyMode",
"foreignKey": "defaultAgencyFk" "foreignKey": "defaultAgencyFk"
} }
} }