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();
}
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;
}
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;
}
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);
}
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);
}
Aggregations