address data changes

This commit is contained in:
Daniel Herrero 2017-11-09 14:27:01 +01:00
parent b77395762c
commit 17143883f8
1 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ module.exports = function(Self) {
function create(data, next) { function create(data, next) {
if (data.isDefaultAddress) { if (data.isDefaultAddress) {
removeAllDefault({id: data.clientFk}, next); removeAllDefault(data, next);
} else { } else {
next(); next();
} }
@ -52,8 +52,8 @@ module.exports = function(Self) {
} }
function removeAllDefault(client, next) { function removeAllDefault(client, next) {
if (client && client.id) if (client && client.clientFk)
Self.updateAll({clientFk: client.id, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next); Self.updateAll({clientFk: client.clientFk, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next);
else else
next(); next();
} }