Skip to content

Commit

Permalink
fix: IVA oltre 100% non deve passare la convalida
Browse files Browse the repository at this point in the history
Closes #424
  • Loading branch information
nicolaiarocci committed Jan 7, 2025
1 parent c215d0a commit 6f432b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## In Development

- fix: IVA oltre 100% non deve passare la convalida ([#424][424])
- fix: CVE 2024 30105 ([#423][423])
- fix: rimuovere reference a BouncyCastle nella documentazione ([#422][422])

[424]: https://github.com/FatturaElettronica/FatturaElettronica.NET/pull/424
[423]: https://github.com/FatturaElettronica/FatturaElettronica.NET/pull/423
[422]: https://github.com/FatturaElettronica/FatturaElettronica.NET/pull/422

Expand Down
12 changes: 12 additions & 0 deletions Test/Ordinaria/DettaglioLineeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,17 @@ public void PrezzoUnitario()
{
AssertDecimalType(x => x.PrezzoUnitario, 8, 19);
}

[TestMethod]
public void AliquotaIvaShouldBeLessOrEqualTo100()
{
Challenge.AliquotaIVA = 101;
var result = Validator.TestValidate(Challenge);
result.ShouldHaveValidationErrorFor(x => x.AliquotaIVA);

Challenge.AliquotaIVA = 100;
result = Validator.TestValidate(Challenge);
result.ShouldNotHaveValidationErrorFor(x => x.AliquotaIVA);
}
}
}
14 changes: 14 additions & 0 deletions Test/Semplificata/DatiIVAValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,19 @@ public void AliquotaOImportoRequired()
result.ShouldNotHaveValidationErrorFor(x => x.Imposta);
result.ShouldNotHaveValidationErrorFor(x => x.Aliquota);
}

[TestMethod]
public void AliquotaShouldBeLessOrEqualTo100()
{
Challenge.Imposta = null;
Challenge.Aliquota = 101;
var result = Validator.TestValidate(Challenge);
result.ShouldHaveValidationErrorFor(x => x.Aliquota);

Challenge.Imposta = null;
Challenge.Aliquota = 100;
result = Validator.TestValidate(Challenge);
result.ShouldNotHaveValidationErrorFor(x => x.Aliquota);
}
}
}
2 changes: 2 additions & 0 deletions Validators/DettaglioLineeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public DettaglioLineeValidator()
.ScalePrecision8DecimalType();
RuleFor(x => x.PrezzoTotale)
.ScalePrecision8DecimalType();
RuleFor(x => x.AliquotaIVA)
.LessThanOrEqualTo(100);
}

private static bool PrezzoTotaleValidateAgainstError00423(DettaglioLinee challenge)
Expand Down
1 change: 1 addition & 0 deletions Validators/Semplificata/DatiIVAValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public DatiIVAValidator()
.When(x => x.Aliquota == null);
RuleFor(x => x.Aliquota)
.NotNull()
.LessThanOrEqualTo(100)
.When(x => x.Imposta == null);
}
}
Expand Down

0 comments on commit 6f432b6

Please # to comment.