Search in sources :

Example 1 with I_C_BankStatementLine

use of org.compiere.model.I_C_BankStatementLine in project metasfresh-webui-api by metasfresh.

the class BankStatementBasedProcess method checkSingleLineSelectedWhichIsNotReconciled.

protected final ProcessPreconditionsResolution checkSingleLineSelectedWhichIsNotReconciled(@NonNull final IProcessPreconditionsContext context) {
    // there should be a single line selected
    final Set<TableRecordReference> bankStatemementLineRefs = context.getSelectedIncludedRecords();
    if (bankStatemementLineRefs.size() != 1) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final TableRecordReference bankStatemementLineRef = bankStatemementLineRefs.iterator().next();
    final BankStatementLineId bankStatementLineId = BankStatementLineId.ofRepoId(bankStatemementLineRef.getRecord_ID());
    final I_C_BankStatementLine line = bankStatementBL.getLineById(bankStatementLineId);
    if (line.isReconciled()) {
        return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText(MSG_LineIsAlreadyReconciled));
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) I_C_BankStatementLine(org.compiere.model.I_C_BankStatementLine) BankStatementLineId(de.metas.banking.BankStatementLineId)

Example 2 with I_C_BankStatementLine

use of org.compiere.model.I_C_BankStatementLine in project metasfresh-webui-api by metasfresh.

the class C_BankStatement_ReconcileWithSinglePayment method getParameterDefaultValue.

@Override
public Object getParameterDefaultValue(final IProcessDefaultParameter parameter) {
    if (PARAM_C_BPartner_ID.contentEquals(parameter.getColumnName())) {
        final I_C_BankStatementLine bankStatementLine = getSingleSelectedBankStatementLine();
        final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(bankStatementLine.getC_BPartner_ID());
        if (bpartnerId != null) {
            return bpartnerId;
        }
    }
    return DEFAULT_VALUE_NOTAVAILABLE;
}
Also used : I_C_BankStatementLine(org.compiere.model.I_C_BankStatementLine) BPartnerId(de.metas.bpartner.BPartnerId)

Example 3 with I_C_BankStatementLine

use of org.compiere.model.I_C_BankStatementLine 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 4 with I_C_BankStatementLine

use of org.compiere.model.I_C_BankStatementLine in project metasfresh-webui-api by metasfresh.

the class C_BankStatement_UnReconcileLine method doIt.

@Override
protected String doIt() {
    final I_C_BankStatement bankStatement = getSelectedBankStatement();
    final DocStatus docStatus = DocStatus.ofCode(bankStatement.getDocStatus());
    if (!docStatus.isDraftedInProgressOrCompleted()) {
        throw new AdempiereException(msgBL.getTranslatableMsgText(MSG_BankStatement_MustBe_Draft_InProgress_Or_Completed));
    }
    final I_C_BankStatementLine bankStatementLine = getSingleSelectedBankStatementLine();
    bankStatementBL.unlinkPaymentsAndDeleteReferences(ImmutableList.of(bankStatementLine));
    bankStatementBL.unpost(bankStatement);
    return MSG_OK;
}
Also used : DocStatus(de.metas.document.engine.DocStatus) I_C_BankStatement(org.compiere.model.I_C_BankStatement) AdempiereException(org.adempiere.exceptions.AdempiereException) I_C_BankStatementLine(org.compiere.model.I_C_BankStatementLine)

Example 5 with I_C_BankStatementLine

use of org.compiere.model.I_C_BankStatementLine in project metasfresh-webui-api by metasfresh.

the class ReconcilePaymentsCommandTest method assertMultiplePayments.

private void assertMultiplePayments(final BankStatementLineId bankStatementLineId) {
    final I_C_BankStatementLine bankStatementLine = bankStatementDAO.getLineById(bankStatementLineId);
    assertThat(bankStatementLine.isMultiplePaymentOrInvoice()).isTrue();
    assertThat(bankStatementLine.isMultiplePayment()).isTrue();
    assertThat(bankStatementLine.getC_Payment_ID()).isLessThanOrEqualTo(0);
}
Also used : I_C_BankStatementLine(org.compiere.model.I_C_BankStatementLine)

Aggregations

I_C_BankStatementLine (org.compiere.model.I_C_BankStatementLine)7 BankStatementLineId (de.metas.banking.BankStatementLineId)2 PaymentId (de.metas.payment.PaymentId)2 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)2 I_C_BankStatement (org.compiere.model.I_C_BankStatement)2 BPartnerId (de.metas.bpartner.BPartnerId)1 DocStatus (de.metas.document.engine.DocStatus)1 ProcessParamLookupValuesProvider (de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)1