Search in sources :

Example 1 with MiraklGetInvoicesRequest

use of com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklCreditNotesExtractServiceImplTest method createAccountingDocumentRequest_shouldReturnRequestWithInvoiceType.

@Test
void createAccountingDocumentRequest_shouldReturnRequestWithInvoiceType() {
    final Date date = new Date();
    final MiraklGetInvoicesRequest result = testObj.createAccountingDocumentRequest(date, InvoiceTypeEnum.MANUAL_CREDIT);
    assertThat(result.getMax()).isEqualTo(100);
    assertThat(result.getStartDate()).isEqualTo(date);
    assertThat(result.getType()).isEqualTo(MANUAL_CREDIT);
    assertThat(result.getPaymentStatus()).isEqualTo(PENDING);
    assertThat(result.getStates()).containsExactly(COMPLETE);
}
Also used : MiraklGetInvoicesRequest(com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 2 with MiraklGetInvoicesRequest

use of com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklInvoicesExtractServiceImplTest method getInvoices_shouldReturnListOfInvoiceModels.

@Test
void getInvoices_shouldReturnListOfInvoiceModels() {
    TimeMachine.useFixedClockAt(LocalDateTime.of(2020, 11, 10, 20, 0, 55));
    final Date now = DateUtil.convertToDate(TimeMachine.now(), ZoneId.systemDefault());
    when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(any())).thenReturn(miraklInvoicesOneMock);
    when(miraklInvoicesOneMock.getHmcInvoices()).thenReturn(List.of(miraklInvoiceOneMock, miraklInvoiceTwoMock));
    when(miraklInvoicesOneMock.getTotalCount()).thenReturn(2L);
    when(miraklInvoiceToInvoiceModelConverterMock.convert(miraklInvoiceOneMock)).thenReturn(invoiceModelOneMock);
    when(miraklInvoiceToInvoiceModelConverterMock.convert(miraklInvoiceTwoMock)).thenReturn(invoiceModelTwoMock);
    final List<InvoiceModel> invoices = testObj.getAccountingDocuments(now);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getInvoices(miraklGetInvoicesRequestArgumentCaptor.capture());
    final MiraklGetInvoicesRequest miraklGetInvoicesRequest = miraklGetInvoicesRequestArgumentCaptor.getValue();
    assertThat(miraklGetInvoicesRequest.getStartDate()).isEqualTo(now);
    assertThat(miraklGetInvoicesRequest.getStates()).isEqualTo(List.of(MiraklAccountingDocumentState.COMPLETE));
    assertThat(miraklGetInvoicesRequest.getPaymentStatus()).isEqualTo(MiraklAccountingDocumentPaymentStatus.PENDING);
    assertThat(invoices).containsExactlyInAnyOrder(invoiceModelOneMock, invoiceModelTwoMock);
}
Also used : MiraklGetInvoicesRequest(com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest) Date(java.util.Date) InvoiceModel(com.paypal.invoices.invoicesextract.model.InvoiceModel) Test(org.junit.jupiter.api.Test)

Example 3 with MiraklGetInvoicesRequest

use of com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklCreditNotesExtractServiceImplTest method getAccountingDocuments_shouldReturnListOfCreditNoteModels.

@Test
void getAccountingDocuments_shouldReturnListOfCreditNoteModels() {
    TimeMachine.useFixedClockAt(LocalDateTime.of(2020, 11, 10, 20, 0, 55));
    final Date now = DateUtil.convertToDate(TimeMachine.now(), ZoneId.systemDefault());
    when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(any())).thenReturn(miraklInvoicesOneMock);
    when(miraklInvoicesOneMock.getHmcInvoices()).thenReturn(List.of(miraklInvoiceOneMock, miraklInvoiceTwoMock));
    when(miraklInvoiceToCreditNoteModelConverter.convert(miraklInvoiceOneMock)).thenReturn(creditNoteOneMock);
    when(miraklInvoiceToCreditNoteModelConverter.convert(miraklInvoiceTwoMock)).thenReturn(creditNoteTwoMock);
    final List<CreditNoteModel> creditNoteList = testObj.getAccountingDocuments(now);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getInvoices(miraklGetInvoicesRequestArgumentCaptor.capture());
    final MiraklGetInvoicesRequest miraklGetInvoicesRequest = miraklGetInvoicesRequestArgumentCaptor.getValue();
    assertThat(miraklGetInvoicesRequest.getStartDate()).isEqualTo(now);
    assertThat(miraklGetInvoicesRequest.getStates()).isEqualTo(List.of(COMPLETE));
    assertThat(miraklGetInvoicesRequest.getPaymentStatus()).isEqualTo(PENDING);
    assertThat(creditNoteList).containsExactlyInAnyOrder(creditNoteOneMock, creditNoteTwoMock);
}
Also used : MiraklGetInvoicesRequest(com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest) CreditNoteModel(com.paypal.invoices.invoicesextract.model.CreditNoteModel) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 4 with MiraklGetInvoicesRequest

use of com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklInvoicesExtractServiceImplTest method createAccountingDocumentRequest_shouldReturnRequestWithInvoiceType.

@Test
void createAccountingDocumentRequest_shouldReturnRequestWithInvoiceType() {
    final Date date = new Date();
    final MiraklGetInvoicesRequest result = testObj.createAccountingDocumentRequest(date, InvoiceTypeEnum.AUTO_INVOICE);
    assertThat(result.getMax()).isEqualTo(100);
    assertThat(result.getStartDate()).isEqualTo(date);
    assertThat(result.getType()).isEqualTo(AUTO_INVOICE);
    assertThat(result.getPaymentStatus()).isEqualTo(PENDING);
    assertThat(result.getStates()).containsExactly(COMPLETE);
}
Also used : MiraklGetInvoicesRequest(com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 5 with MiraklGetInvoicesRequest

use of com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest in project mirakl-hyperwallet-connector by paypal.

the class AbstractAccountingDocumentsExtractServiceImpl method createAccountingDocumentRequest.

@NonNull
protected MiraklGetInvoicesRequest createAccountingDocumentRequest(final Date delta, final InvoiceTypeEnum invoiceType) {
    final MiraklGetInvoicesRequest miraklGetInvoicesRequest = new MiraklGetInvoicesRequest();
    miraklGetInvoicesRequest.setStartDate(delta);
    miraklGetInvoicesRequest.setPaymentStatus(MiraklAccountingDocumentPaymentStatus.PENDING);
    miraklGetInvoicesRequest.addState(MiraklAccountingDocumentState.COMPLETE);
    miraklGetInvoicesRequest.setType(EnumUtils.getEnum(MiraklAccountingDocumentType.class, invoiceType.name()));
    miraklGetInvoicesRequest.setMax(MIRAKL_MAX_RESULTS_PER_PAGE);
    return miraklGetInvoicesRequest;
}
Also used : MiraklGetInvoicesRequest(com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest) MiraklAccountingDocumentType(com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentType) NonNull(org.springframework.lang.NonNull)

Aggregations

MiraklGetInvoicesRequest (com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest)6 Date (java.util.Date)4 Test (org.junit.jupiter.api.Test)4 MiraklAccountingDocumentType (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentType)1 HMCMiraklInvoice (com.paypal.infrastructure.sdk.mirakl.domain.invoice.HMCMiraklInvoice)1 HMCMiraklInvoices (com.paypal.infrastructure.sdk.mirakl.domain.invoice.HMCMiraklInvoices)1 CreditNoteModel (com.paypal.invoices.invoicesextract.model.CreditNoteModel)1 InvoiceModel (com.paypal.invoices.invoicesextract.model.InvoiceModel)1 NonNull (org.springframework.lang.NonNull)1