Search in sources :

Example 1 with PaymentId

use of de.metas.payment.PaymentId in project metasfresh-webui-api by metasfresh.

the class BankStatementLineAndPaymentsToReconcileRepository method toPaymentToReconcileRow.

private PaymentToReconcileRow toPaymentToReconcileRow(@NonNull final I_C_Payment record, @NonNull final ImmutableSetMultimap<PaymentId, String> invoiceDocumentNosByPaymentId) {
    final CurrencyId currencyId = CurrencyId.ofRepoId(record.getC_Currency_ID());
    final CurrencyCode currencyCode = currencyRepository.getCurrencyCodeById(currencyId);
    final Amount payAmt = Amount.of(record.getPayAmt(), currencyCode);
    final PaymentId paymentId = PaymentId.ofRepoId(record.getC_Payment_ID());
    String invoiceDocumentNos = joinInvoiceDocumentNos(invoiceDocumentNosByPaymentId.get(paymentId));
    return PaymentToReconcileRow.builder().paymentId(paymentId).inboundPayment(record.isReceipt()).documentNo(record.getDocumentNo()).dateTrx(TimeUtil.asLocalDate(record.getDateTrx())).bpartner(bpartnerLookup.findById(record.getC_BPartner_ID())).invoiceDocumentNos(invoiceDocumentNos).payAmt(payAmt).reconciled(record.isReconciled()).build();
}
Also used : CurrencyCode(de.metas.currency.CurrencyCode) Amount(de.metas.currency.Amount) PaymentId(de.metas.payment.PaymentId) CurrencyId(de.metas.money.CurrencyId)

Example 2 with PaymentId

use of de.metas.payment.PaymentId in project metasfresh-webui-api by metasfresh.

the class C_BankStatement_ReconcileWithSinglePayment method doIt.

@Override
protected String doIt() {
    final I_C_BankStatement bankStatement = getSelectedBankStatement();
    final I_C_BankStatementLine bankStatementLine = getSingleSelectedBankStatementLine();
    bankStatementLine.setC_BPartner_ID(bpartnerId.getRepoId());
    if (paymentId != null) {
        bankStatementPaymentBL.linkSinglePayment(bankStatement, bankStatementLine, paymentId);
    } else {
        final Set<PaymentId> eligiblePaymentIds = bankStatementPaymentBL.findEligiblePaymentIds(bankStatementLine, bpartnerId, 2);
        if (eligiblePaymentIds.isEmpty()) {
            bankStatementPaymentBL.createSinglePaymentAndLink(bankStatement, bankStatementLine);
        } else if (eligiblePaymentIds.size() == 1) {
            PaymentId eligiblePaymentId = eligiblePaymentIds.iterator().next();
            bankStatementPaymentBL.linkSinglePayment(bankStatement, bankStatementLine, eligiblePaymentId);
        } else {
            throw new FillMandatoryException(PARAM_C_Payment_ID);
        }
    }
    return MSG_OK;
}
Also used : I_C_BankStatement(org.compiere.model.I_C_BankStatement) PaymentId(de.metas.payment.PaymentId) I_C_BankStatementLine(org.compiere.model.I_C_BankStatementLine) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException)

Example 3 with PaymentId

use of de.metas.payment.PaymentId in project metasfresh-webui-api by metasfresh.

the class PaymentView_Launcher_From_BPartnerSingleDocument method doIt.

@Override
protected String doIt() {
    final ImmutableSet<PaymentId> paymentIds = retrievePaymentIds();
    if (paymentIds.isEmpty()) {
        throw new AdempiereException("@NoOpenPayments@").markAsUserValidationError();
    }
    final ViewId viewId = viewsFactory.createView(CreateViewRequest.builder(PaymentsViewFactory.WINDOW_ID).setFilterOnlyIds(PaymentId.toIntSet(paymentIds)).build()).getViewId();
    getResult().setWebuiViewToOpen(WebuiViewToOpen.builder().viewId(viewId.getViewId()).target(ViewOpenTarget.ModalOverlay).build());
    return MSG_OK;
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) PaymentId(de.metas.payment.PaymentId) ViewId(de.metas.ui.web.view.ViewId)

Example 4 with PaymentId

use of de.metas.payment.PaymentId in project metasfresh-webui-api by metasfresh.

the class ReconcilePaymentsCommandTest method bankStatementLineIsLinkedToESRImportLine.

@Test
public void bankStatementLineIsLinkedToESRImportLine() {
    final BankStatementLineRow bankStatementLineRow = bankStatementLineRow().docStatus(DocStatus.Drafted).statementAmt(euro("1000")).build();
    final PaymentToReconcileRow paymentRow = paymentRow().inboundPayment(true).customerId(customerId).paymentAmt(euro("1000")).build();
    final PaymentId paymentId = paymentRow.getPaymentId();
    final I_ESR_ImportLine esrImportLine = createESRImportLine(paymentId);
    assertThat(esrImportLine.getC_Payment_ID()).isEqualTo(paymentId.getRepoId());
    assertThat(esrImportLine.getC_BankStatement_ID()).isLessThanOrEqualTo(0);
    assertThat(esrImportLine.getC_BankStatementLine_ID()).isLessThanOrEqualTo(0);
    assertThat(esrImportLine.getC_BankStatementLine_Ref_ID()).isLessThanOrEqualTo(0);
    executeReconcilePaymentsCommand(ReconcilePaymentsRequest.builder().selectedBankStatementLine(bankStatementLineRow).selectedPaymentToReconcile(paymentRow).build());
    InterfaceWrapperHelper.refresh(esrImportLine);
    assertThat(esrImportLine.getC_BankStatement_ID()).isGreaterThan(0);
    assertThat(esrImportLine.getC_BankStatementLine_ID()).isEqualTo(bankStatementLineRow.getBankStatementLineId().getRepoId());
    assertThat(esrImportLine.getC_BankStatementLine_Ref_ID()).isGreaterThan(0);
}
Also used : PaymentId(de.metas.payment.PaymentId) BankStatementLineRow(de.metas.ui.web.bankstatement_reconciliation.BankStatementLineRow) PaymentToReconcileRow(de.metas.ui.web.bankstatement_reconciliation.PaymentToReconcileRow) I_ESR_ImportLine(de.metas.payment.esr.model.I_ESR_ImportLine) Test(org.junit.jupiter.api.Test)

Example 5 with PaymentId

use of de.metas.payment.PaymentId in project metasfresh-webui-api by metasfresh.

the class ReconcilePaymentsCommandTest method createPaymentRow.

@Builder(builderMethodName = "paymentRow", builderClassName = "PaymentRowBuilder")
private PaymentToReconcileRow createPaymentRow(@NonNull final Boolean inboundPayment, @NonNull final BPartnerId customerId, @NonNull final Money paymentAmt, final boolean reconciled) {
    final DefaultPaymentBuilder builder = inboundPayment ? paymentBL.newInboundReceiptBuilder() : paymentBL.newOutboundPaymentBuilder();
    final I_C_Payment payment = builder.adOrgId(OrgId.ANY).bpartnerId(customerId).orgBankAccountId(euroOrgBankAccountId).currencyId(paymentAmt.getCurrencyId()).payAmt(paymentAmt.toBigDecimal()).dateAcct(paymentDate).dateTrx(paymentDate).tenderType(TenderType.Check).createAndProcess();
    payment.setDocumentNo("documentNo-" + payment.getC_Payment_ID());
    paymentDAO.save(payment);
    if (reconciled) {
        paymentBL.markReconciledAndSave(payment);
    }
    final PaymentId paymentId = PaymentId.ofRepoId(payment.getC_Payment_ID());
    return rowsRepo.getPaymentToReconcileRowsByIds(ImmutableSet.of(paymentId)).get(0);
}
Also used : I_C_Payment(org.compiere.model.I_C_Payment) DefaultPaymentBuilder(de.metas.payment.api.DefaultPaymentBuilder) PaymentId(de.metas.payment.PaymentId) Builder(lombok.Builder) DefaultPaymentBuilder(de.metas.payment.api.DefaultPaymentBuilder)

Aggregations

PaymentId (de.metas.payment.PaymentId)12 ViewId (de.metas.ui.web.view.ViewId)5 AdempiereException (org.adempiere.exceptions.AdempiereException)5 BankStatementLineRow (de.metas.ui.web.bankstatement_reconciliation.BankStatementLineRow)2 PaymentToReconcileRow (de.metas.ui.web.bankstatement_reconciliation.PaymentToReconcileRow)2 Builder (lombok.Builder)2 I_C_BankStatementLine (org.compiere.model.I_C_BankStatementLine)2 I_C_Payment (org.compiere.model.I_C_Payment)2 Test (org.junit.jupiter.api.Test)2 PaySelectionId (de.metas.banking.PaySelectionId)1 Amount (de.metas.currency.Amount)1 CurrencyCode (de.metas.currency.CurrencyCode)1 CurrencyId (de.metas.money.CurrencyId)1 DefaultPaymentBuilder (de.metas.payment.api.DefaultPaymentBuilder)1 I_ESR_ImportLine (de.metas.payment.esr.model.I_ESR_ImportLine)1 ProcessParamLookupValuesProvider (de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)1 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)1 I_C_BankStatement (org.compiere.model.I_C_BankStatement)1 I_C_PaySelectionLine (org.compiere.model.I_C_PaySelectionLine)1