Skip to content
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
1 change: 1 addition & 0 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ module.exports = {
[this.RECEIVED]: 'Reçu',
[this.XML_GENERATED]: 'Fichier XML associé',
[this.PAID]: 'Réglé',
[this.CANCELLED]: 'Annulé',
};
},
NOT_INVOICED: 'not_invoiced',
Expand Down
1 change: 1 addition & 0 deletions tests/integration/exports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ const vendorHistoryExportTypes = [
`"Paiement";"REG-00001";"09/03/2022";"FACT-00001";${authCompany._id};1;"Prélèvement";"1100,00";"Fichier XML associé";"Prélèvements Septembre 2025";"14/03/2022";`,
`"Paiement";"REG-00003";"09/03/2022";"FACT-00005";${courseFundingOrganisation._id};1;"Espèces";"300,00";"Reçu";;;`,
`"Paiement";"REG-00006";"01/04/2022";"FACT-00001";${authCompany._id};2;"Prélèvement";"50,00";"En attente";;;`,
`"Paiement";"REG-00007";"10/03/2022";"FACT-00002";${courseFundingOrganisation._id};1;"Prélèvement";"1200,00";"Annulé";;;`,
`"Remboursement";"REMB-00001";"11/03/2022";"FACT-00005";${courseFundingOrganisation._id};2;"Chèque";"200,00";"Reçu";;;`,
],
query: 'startDate=2022-03-01T10:00:00.000Z&endDate=2022-04-20T10:00:00.000Z',
Expand Down
13 changes: 12 additions & 1 deletion tests/integration/seed/exportsSeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const {
PENDING,
RECEIVED,
XML_GENERATED,
CANCELLED,
BANK_TRANSFER,
PRESENT,
MISSING,
Expand Down Expand Up @@ -1462,7 +1463,7 @@ const courseFundingOrganisation = {
const courseBillNumber = { _id: new ObjectId(), seq: 8 };
const courseCreditNoteNumber = { _id: new ObjectId(), seq: 2 };
const coursePaymentNumber = [
{ _id: new ObjectId(), seq: 6, nature: PAYMENT },
{ _id: new ObjectId(), seq: 7, nature: PAYMENT },
{ _id: new ObjectId(), seq: 4, nature: REFUND },
];

Expand Down Expand Up @@ -1664,6 +1665,16 @@ const coursePaymentList = [
type: DIRECT_DEBIT,
status: PENDING,
},
{ // 10 cancelled because of creditNote
number: 'REG-00007',
date: '2022-03-10T00:00:00.000Z',
companies: [authCompany._id],
courseBill: courseBillList[1]._id,
netInclTaxes: 1200,
nature: PAYMENT,
type: DIRECT_DEBIT,
status: CANCELLED,
},
];

const xmlSEPAFileInfos = {
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/helpers/vendorHistoryExport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
VENDOR_ADMIN,
NO_DATA,
CHECK,
DIRECT_DEBIT,
REFUND,
ESTIMATED_START_DATE_EDITION,
WEBAPP,
Expand All @@ -32,6 +33,7 @@ const {
RECEIVED,
PENDING,
PAID,
CANCELLED,
PRESENT,
MISSING,
DRAFT,
Expand Down Expand Up @@ -2918,7 +2920,7 @@ describe('exportCoursePaymentHistory', () => {
});

it('should return an array with the header and 3 rows', async () => {
const courseBillIds = [new ObjectId(), new ObjectId()];
const courseBillIds = [new ObjectId(), new ObjectId(), new ObjectId()];
const payerId = new ObjectId();
const coursePaymentList = [
{
Expand Down Expand Up @@ -2967,6 +2969,21 @@ describe('exportCoursePaymentHistory', () => {
netInclTaxes: 200,
status: RECEIVED,
},
{
_id: new ObjectId(),
nature: PAYMENT,
number: 'REG-5',
date: '2022-01-15T23:00:00.000Z',
courseBill: {
_id: courseBillIds[2],
number: 'FACT-3',
payer: { _id: payerId },
course: { type: INTRA, trainees: [{ _id: new ObjectId(), identity: { firstname: 'Archie', lastname: 'Pelle' } }] },
},
type: DIRECT_DEBIT,
netInclTaxes: 50,
status: CANCELLED,
},
];
findCoursePayment
.onCall(0)
Expand All @@ -2975,6 +2992,7 @@ describe('exportCoursePaymentHistory', () => {
[
{ _id: coursePaymentList[0], courseBill: courseBillIds[0] },
{ _id: coursePaymentList[2], courseBill: courseBillIds[1] },
{ _id: coursePaymentList[3], courseBill: courseBillIds[2] },
],
['setOptions', 'lean'])
);
Expand All @@ -2986,6 +3004,7 @@ describe('exportCoursePaymentHistory', () => {
['Nature', 'Identifiant', 'Date', 'Facture associée', 'Id payeur facture', 'Numéro du paiement (parmi ceux de la même facture)', 'Moyen de paiement', 'Montant', 'Statut', 'Nom de lot fichier XML', 'Date d\'effet du prélèvement', 'Apprenant'],
['Remboursement', 'REG-2', '23/01/2022', 'FACT-2', payerId, 2, 'Chèque', '22,00', 'Reçu', 'LOT-002', '22/01/2022', 'Archie PELLE'],
['Remboursement', 'REG-4', '11/01/2022', 'FACT-1', payerId, 1, 'Chèque', '200,00', 'Reçu', '', '', ''],
['Paiement', 'REG-5', '16/01/2022', 'FACT-3', payerId, 1, 'Prélèvement', '50,00', 'Annulé', '', '', ''],
]);
SinonMongoose.calledWithExactly(
findCoursePayment,
Expand Down
Loading