Skip to content

Commit

Permalink
Merge pull request #294 from fiterlatam/FSAB-7
Browse files Browse the repository at this point in the history
FSAB-7
  • Loading branch information
faheem205 authored Nov 27, 2023
2 parents 4be35e2 + da632de commit 4700caa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private Client(final AppUser currentUser, final ClientStatus status, final Offic
this.clientType = clientType;
this.clientClassification = clientClassification;

this.isVatRequired = isVatRequired;
this.isVatRequired = isVatRequired == null ? false : isVatRequired;
this.vatRate = vatRate;

this.setLegalForm(legalForm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,15 @@ public CommandProcessingResult updateClient(final Long clientId, final JsonComma
clientForUpdate.updateGender(newCodeVal);
}

boolean isVatRequired = false;
if (changes.containsKey(ClientApiConstants.isVatRequiredParamName)) {
final Boolean newValue = command.booleanPrimitiveValueOfParameterNamed(ClientApiConstants.isVatRequiredParamName);
clientForUpdate.setVatRequired(newValue);
isVatRequired = command.booleanPrimitiveValueOfParameterNamed(ClientApiConstants.isVatRequiredParamName);
clientForUpdate.setVatRequired(isVatRequired);
}

if (changes.containsKey(ClientApiConstants.vatRateIdParamName)) {
if (!isVatRequired) {
clientForUpdate.setVatRate(null);
}
if (isVatRequired && changes.containsKey(ClientApiConstants.vatRateIdParamName)) {
final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.vatRateIdParamName);
VatRate vatRate = this.readVatRateService.findById(newValue);
clientForUpdate.setVatRate(vatRate);
Expand Down

0 comments on commit 4700caa

Please sign in to comment.