Merge branch 'master' of ssh://git.verdnatura.es:/var/lib/git/salix

This commit is contained in:
Juan Ferrer Toribio 2017-01-24 16:06:15 +01:00
commit 278d764575
8 changed files with 51 additions and 37 deletions

View File

@ -35,8 +35,7 @@ export const COMPONENT = {
if (!equalsObject(this.client, this.clientOld)) { if (!equalsObject(this.client, this.clientOld)) {
var newClient = modified(this.client, this.clientOld); var newClient = modified(this.client, this.clientOld);
newClient.modify = "BasicData"; newClient.modify = "BasicData";
newClient.id = this.clientOld.id; $http.put(`/client/api/Clients/${this.clientOld.id}`, newClient).then(
$http.put('/client/api/Clients', newClient).then(
json => { json => {
copyObject(json.data, this.client); copyObject(json.data, this.client);
this.copyClient(); this.copyClient();

View File

@ -10,7 +10,7 @@ export const COMPONENT = {
controllerAs: 'card', controllerAs: 'card',
controller: function($http, $stateParams) { controller: function($http, $stateParams) {
this.client = null; this.client = null;
$http.get(`/client/api/Clients/${$stateParams.id}`).then( $http.get(`/client/api/Clients/${$stateParams.id}?filter[include][account]`).then(
json => this.client = json.data json => this.client = json.data
); );

View File

@ -19,8 +19,8 @@ export const COMPONENT = {
$scope.$watch('descriptor.client.active', function(newValue, oldValue) { $scope.$watch('descriptor.client.active', function(newValue, oldValue) {
if (self.client && self.clientOld && self.client.active !== self.clientOld.active) { if (self.client && self.clientOld && self.client.active !== self.clientOld.active) {
self.client.modify = "Active"; var newClient = {id: self.client.id, active: self.client.active, modify: "Active"};
$http.put('/client/api/Clients', self.client).then( $http.put('/client/api/Clients', newClient).then(
json => { json => {
self.client = json.data; self.client = json.data;
self.copyClient(); self.copyClient();

View File

@ -16,8 +16,7 @@ export const COMPONENT = {
if (!equalsObject(this.client, this.clientOld)) { if (!equalsObject(this.client, this.clientOld)) {
var newClient = modified(this.client, this.clientOld); var newClient = modified(this.client, this.clientOld);
newClient.modify = "FiscalData"; newClient.modify = "FiscalData";
newClient.id = this.clientOld.id; $http.put(`/client/api/Clients/${this.clientOld.id}`, newClient).then(
$http.put('/client/api/Clients', this.client).then(
json => { json => {
this.client = json.data; this.client = json.data;
this.copyClient(); this.copyClient();

View File

@ -14,7 +14,7 @@ module.exports = function(Client) {
} }
// Hooks // Hooks
Client.observe('before save', function (ctx, next) { Client.observe('before save', function (ctx, next) {
if (ctx.instance) { if (ctx.instance) {
if (!ctx.instance.dueDay){ if (!ctx.instance.dueDay){
ctx.instance.dueDay = 5; ctx.instance.dueDay = 5;
@ -27,6 +27,8 @@ module.exports = function(Client) {
if (item.payMethod != ctx.data.payMethod && item.dueDay == ctx.data.dueDay) { if (item.payMethod != ctx.data.payMethod && item.dueDay == ctx.data.dueDay) {
ctx.data.dueDay = 5; ctx.data.dueDay = 5;
} }
if(!ctx.data.name)
ctx.data.name = item.name;
} }
next(); next();
} }

View File

@ -11,7 +11,7 @@
"name": { "name": {
"type": "string", "type": "string",
"required": true "required": true
}, },
"fi": { "fi": {
"type": "string", "type": "string",
"description": "Fiscal indetifier" "description": "Fiscal indetifier"
@ -64,8 +64,8 @@
"dueDay": { "dueDay": {
"type": "Number" "type": "Number"
}, },
"gestdoc":{ "gestdoc": {
"type":"Number" "type": "Number"
}, },
"surcharge": { "surcharge": {
"type": "boolean", "type": "boolean",
@ -80,26 +80,38 @@
"description": "Send invoices by email" "description": "Send invoices by email"
}, },
"relations": { "relations": {
"salesPerson": { "type": {
"type": "belongsTo", "salesPerson": {
"model": "SalesPerson", "type": "belongsTo",
"foreignKey": "salePersonId" "model": "SalesPerson",
}, "foreignKey": "salePersonId"
"paymentMethod":{ },
"type": "belongsTo", "paymentMethod": {
"model": "PaymentMethod", "type": "belongsTo",
"foreingKey": "payId" "model": "PaymentMethod",
}, "foreingKey": "payId"
"country":{ },
"type": "belongsTo", "country": {
"model": "Country", "type": "belongsTo",
"foreignKey": "countryId" "model": "Country",
}, "foreignKey": "countryId"
"province":{ },
"type": "belongsTo", "province": {
"model": "Province", "type": "belongsTo",
"foreignKey": "provinceId" "model": "Province",
"foreignKey": "provinceId"
}
} }
} }
} },
"validations": [],
"relations": {
"account": {
"type": "hasOne",
"model": "Account",
"foreignKey": "id"
}
},
"acls": [],
"methods": {}
} }

View File

@ -6,7 +6,6 @@ module.exports = function(ClientObservation) {
} }
ClientObservation.observe('before save', function (ctx, next) { ClientObservation.observe('before save', function (ctx, next) {
var loopback = require('loopback');
ctx.instance.creationDate = Date(); ctx.instance.creationDate = Date();
next(); next();
}); });

View File

@ -4,16 +4,19 @@
"validateUpsert": true, "validateUpsert": true,
"properties": { "properties": {
"id": { "id": {
"type": "Number", "type": "number",
"id": true, "required": true
"description": "Identifier"
}, },
"name": { "name": {
"type": "string", "type": "string",
"required": true "required": true
}, },
"active": { "active": {
"type": "boolean" "type": "boolean"
} }
} },
"validations": [],
"relations": {},
"acls": [],
"methods": {}
} }