use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BankOrderManagementRepository method copy.
@Override
public BankOrder copy(BankOrder entity, boolean deep) {
BankOrder copy = super.copy(entity, deep);
copy.setStatusSelect(STATUS_DRAFT);
copy.setGeneratedMetaFile(null);
copy.setSignedMetaFile(null);
copy.setConfirmationDateTime(null);
copy.setFileGenerationDateTime(null);
copy.setValidationDateTime(null);
copy.setSendingDateTime(null);
copy.setBankOrderSeq(null);
return copy;
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BatchCreditTransferExpensePaymentHR method mergeBankOrders.
/**
* Merge bank orders.
*
* @param doneList
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
protected void mergeBankOrders(List<Expense> doneList) throws AxelorException {
List<Expense> expenseList = new ArrayList<>();
List<BankOrder> bankOrderList = new ArrayList<>();
for (Expense expense : doneList) {
BankOrder bankOrder = expense.getBankOrder();
if (bankOrder != null) {
expenseList.add(expense);
bankOrderList.add(bankOrder);
}
}
if (bankOrderList.size() > 1) {
BankOrder mergedBankOrder = bankOrderMergeService.mergeBankOrders(bankOrderList);
for (Expense expense : expenseList) {
expense.setBankOrder(mergedBankOrder);
}
}
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class ExpenseServiceImpl method addPayment.
@Override
@Transactional(rollbackOn = { Exception.class })
public void addPayment(Expense expense, BankDetails bankDetails) throws AxelorException {
expense.setPaymentDate(appAccountService.getTodayDate(expense.getCompany()));
PaymentMode paymentMode = expense.getPaymentMode();
if (paymentMode == null) {
paymentMode = expense.getUser().getPartner().getOutPaymentMode();
if (paymentMode == null) {
throw new AxelorException(expense, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EXPENSE_MISSING_PAYMENT_MODE));
}
expense.setPaymentMode(paymentMode);
}
if (paymentMode.getGenerateBankOrder()) {
BankOrder bankOrder = Beans.get(BankOrderCreateServiceHr.class).createBankOrder(expense, bankDetails);
expense.setBankOrder(bankOrder);
Beans.get(BankOrderRepository.class).save(bankOrder);
expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_PENDING);
} else {
if (accountConfigService.getAccountConfig(expense.getCompany()).getGenerateMoveForInvoicePayment()) {
this.createMoveForExpensePayment(expense);
}
if (paymentMode.getAutomaticTransmission()) {
expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_PENDING);
} else {
expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_VALIDATED);
expense.setStatusSelect(ExpenseRepository.STATUS_REIMBURSED);
}
}
expense.setPaymentAmount(expense.getInTaxTotal().subtract(expense.getAdvanceAmount()).subtract(expense.getWithdrawnCash()).subtract(expense.getPersonalExpenseAmount()));
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BankOrderMergeServiceImpl method mergeBankOrders.
@Transactional(rollbackOn = { Exception.class })
public BankOrder mergeBankOrders(Collection<BankOrder> bankOrders) throws AxelorException {
if (bankOrders == null || bankOrders.size() <= 1) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, IExceptionMessage.BANK_ORDER_MERGE_AT_LEAST_TWO_BANK_ORDERS);
}
this.checkSameElements(bankOrders);
BankOrder bankOrder = bankOrders.iterator().next();
bankOrders.remove(bankOrder);
bankOrder.setSenderLabel(null);
bankOrder.setSenderReference(null);
bankOrder.setBankOrderDate(Beans.get(AppBaseService.class).getTodayDate(bankOrder.getSenderCompany()));
bankOrder.setSignatoryUser(null);
bankOrder.setSignatoryEbicsUser(null);
PaymentMode paymentMode = bankOrder.getPaymentMode();
for (BankOrderLine bankOrderLine : this.getAllBankOrderLineList(bankOrders)) {
bankOrder.addBankOrderLineListItem(bankOrderLine);
}
bankOrderRepo.save(bankOrder);
for (BankOrder bankOrderToRemove : bankOrders) {
bankOrderToRemove = bankOrderRepo.find(bankOrderToRemove.getId());
List<InvoicePayment> invoicePaymentList = invoicePaymentRepo.findByBankOrder(bankOrderToRemove).fetch();
for (InvoicePayment invoicePayment : invoicePaymentList) {
invoicePayment.setBankOrder(bankOrder);
}
bankOrderRepo.remove(bankOrderToRemove);
}
if (paymentMode.getConsoBankOrderLinePerPartner()) {
consolidatePerPartner(bankOrder);
}
bankOrderService.updateTotalAmounts(bankOrder);
return bankOrderRepo.save(bankOrder);
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BatchBankPaymentServiceImpl method createBankOrderFromPaymentScheduleLines.
@Override
@Transactional(rollbackOn = { Exception.class })
public BankOrder createBankOrderFromPaymentScheduleLines(Batch batch) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
List<PaymentScheduleLine> paymentScheduleLineList;
int offset = 0;
while (!(paymentScheduleLineList = fetchPaymentScheduleLineDoneList(batch, offset)).isEmpty()) {
createBankOrders(batch, paymentScheduleLineList);
offset += paymentScheduleLineList.size();
JPA.clear();
batch = batchRepo.find(batch.getId());
}
List<BankOrder> bankOrderList;
while ((bankOrderList = fetchLimitedBankOrderList(batch)).size() > 1) {
bankOrderMergeService.mergeBankOrders(bankOrderList);
JPA.clear();
batch = batchRepo.find(batch.getId());
}
if (bankOrderList.isEmpty()) {
throw new AxelorException(batch, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_MERGE_NO_BANK_ORDERS));
}
BankOrder bankOrder = bankOrderRepo.find(bankOrderList.iterator().next().getId());
batch.setBankOrder(bankOrder);
return bankOrder;
}
Aggregations