Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 3 files rule on rental receipt should exclude guarantor #880

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ private boolean checkAddressWithSalary(Document document) {
*/
}

private boolean checkNumberOfPage(Document document) {
return document.getGuarantor() != null || document.getFiles().stream().mapToInt(File::getNumberOfPages).sum() >= MIN_NUMBER_OF_RECEIPT;
}

@Override
public DocumentAnalysisReport process(Document document, DocumentAnalysisReport report) {
report.setAnalysisStatus(DocumentAnalysisStatus.UNDEFINED);
Expand All @@ -120,7 +124,7 @@ public DocumentAnalysisReport process(Document document, DocumentAnalysisReport
return report;
}

if (document.getFiles().stream().mapToInt(File::getNumberOfPages).sum() < MIN_NUMBER_OF_RECEIPT) {
if (!checkNumberOfPage(document)) {
log.error("Document number of pages mismatches :{}", document.getId());
report.getBrokenRules().add(DocumentBrokenRule.builder()
.rule(DocumentRule.R_RENT_RECEIPT_NB_DOCUMENTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ void when_only_one_month_then_report_error() throws Exception {

Assertions.assertThat(report.getAnalysisStatus()).isEqualTo(DocumentAnalysisStatus.DENIED);
Assertions.assertThat(report.getBrokenRules()).hasSize(2);
Assertions.assertThat(report.getBrokenRules().getFirst()).matches(docRule -> docRule.getRule() == DocumentRule.R_RENT_RECEIPT_NB_DOCUMENTS);
Assertions.assertThat( report.getBrokenRules().stream().anyMatch(docRule -> docRule.getRule() == DocumentRule.R_RENT_RECEIPT_NB_DOCUMENTS)).isTrue();
}
}
Loading