Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("EcritureComptable")
|
||||
class EcritureComptableTest {
|
||||
|
||||
private static JournalComptable newJournal() {
|
||||
JournalComptable j = new JournalComptable();
|
||||
j.setId(UUID.randomUUID());
|
||||
j.setCode("BQ");
|
||||
j.setLibelle("Banque");
|
||||
j.setTypeJournal(TypeJournalComptable.BANQUE);
|
||||
return j;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("getters/setters")
|
||||
void gettersSetters() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setNumeroPiece("ECR-001");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("Virement");
|
||||
e.setReference("REF-1");
|
||||
e.setLettrage("L1");
|
||||
e.setPointe(true);
|
||||
e.setMontantDebit(new BigDecimal("100.00"));
|
||||
e.setMontantCredit(new BigDecimal("100.00"));
|
||||
e.setJournal(newJournal());
|
||||
|
||||
assertThat(e.getNumeroPiece()).isEqualTo("ECR-001");
|
||||
assertThat(e.getLibelle()).isEqualTo("Virement");
|
||||
assertThat(e.getMontantDebit()).isEqualByComparingTo("100.00");
|
||||
assertThat(e.getMontantCredit()).isEqualByComparingTo("100.00");
|
||||
assertThat(e.getPointe()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("isEquilibree: true si débit = crédit")
|
||||
void isEquilibree() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setJournal(newJournal());
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setMontantDebit(new BigDecimal("50.00"));
|
||||
e.setMontantCredit(new BigDecimal("50.00"));
|
||||
assertThat(e.isEquilibree()).isTrue();
|
||||
e.setMontantCredit(new BigDecimal("60.00"));
|
||||
assertThat(e.isEquilibree()).isFalse();
|
||||
e.setMontantDebit(null);
|
||||
assertThat(e.isEquilibree()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("calculerTotaux: à partir des lignes")
|
||||
void calculerTotaux() {
|
||||
JournalComptable j = newJournal();
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setJournal(j);
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setMontantDebit(BigDecimal.ZERO);
|
||||
e.setMontantCredit(BigDecimal.ZERO);
|
||||
LigneEcriture l1 = new LigneEcriture();
|
||||
l1.setMontantDebit(new BigDecimal("100"));
|
||||
l1.setMontantCredit(BigDecimal.ZERO);
|
||||
LigneEcriture l2 = new LigneEcriture();
|
||||
l2.setMontantDebit(BigDecimal.ZERO);
|
||||
l2.setMontantCredit(new BigDecimal("100"));
|
||||
e.getLignes().add(l1);
|
||||
e.getLignes().add(l2);
|
||||
e.calculerTotaux();
|
||||
assertThat(e.getMontantDebit()).isEqualByComparingTo("100");
|
||||
assertThat(e.getMontantCredit()).isEqualByComparingTo("100");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("genererNumeroPiece")
|
||||
void genererNumeroPiece() {
|
||||
String num = EcritureComptable.genererNumeroPiece("ECR", LocalDate.of(2025, 3, 15));
|
||||
assertThat(num).startsWith("ECR-20250315-");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("equals et hashCode")
|
||||
void equalsHashCode() {
|
||||
UUID id = UUID.randomUUID();
|
||||
JournalComptable j = newJournal();
|
||||
EcritureComptable a = new EcritureComptable();
|
||||
a.setId(id);
|
||||
a.setNumeroPiece("N1");
|
||||
a.setDateEcriture(LocalDate.now());
|
||||
a.setLibelle("L");
|
||||
a.setJournal(j);
|
||||
EcritureComptable b = new EcritureComptable();
|
||||
b.setId(id);
|
||||
b.setNumeroPiece("N1");
|
||||
b.setDateEcriture(a.getDateEcriture());
|
||||
b.setLibelle("L");
|
||||
b.setJournal(j);
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("toString non null")
|
||||
void toString_nonNull() {
|
||||
EcritureComptable e = new EcritureComptable();
|
||||
e.setNumeroPiece("X");
|
||||
e.setDateEcriture(LocalDate.now());
|
||||
e.setLibelle("L");
|
||||
e.setJournal(newJournal());
|
||||
assertThat(e.toString()).isNotNull().isNotEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user