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