use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveController method filterPartner.
public void filterPartner(ActionRequest request, ActionResponse response) {
Move move = request.getContext().asType(Move.class);
if (move != null) {
String domain = Beans.get(MoveService.class).filterPartner(move);
response.setAttr("partner", "domain", domain);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveServiceImpl method createMoveUseInvoiceDue.
/**
* Méthode permettant d'employer les dûs sur l'avoir On récupère prioritairement les dûs
* (factures) selectionné sur l'avoir, puis les autres dûs du tiers
*
* <p>2 cas : - le compte des dûs est le même que celui de l'avoir : alors on lettre directement -
* le compte n'est pas le même : on créée une O.D. de passage sur le bon compte
*
* @param invoice
* @return
* @throws AxelorException
*/
@Override
public Move createMoveUseInvoiceDue(Invoice invoice) throws AxelorException {
Company company = invoice.getCompany();
Move move = null;
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
// Récupération des dûs
List<MoveLine> debitMoveLines = moveDueService.getInvoiceDue(invoice, accountConfig.getAutoReconcileOnInvoice());
if (!debitMoveLines.isEmpty()) {
MoveLine invoiceCustomerMoveLine = moveToolService.getCustomerMoveLineByLoop(invoice);
// Si c'est le même compte sur les trop-perçus et sur la facture, alors on lettre directement
if (moveToolService.isSameAccount(debitMoveLines, invoiceCustomerMoveLine.getAccount())) {
List<MoveLine> creditMoveLineList = new ArrayList<MoveLine>();
creditMoveLineList.add(invoiceCustomerMoveLine);
paymentService.useExcessPaymentOnMoveLines(debitMoveLines, creditMoveLineList);
} else // Sinon on créée une O.D. pour passer du compte de la facture à un autre compte sur les
// trop-perçus
{
this.createMoveUseDebit(invoice, debitMoveLines, invoiceCustomerMoveLine);
}
// Gestion du passage en 580
reconcileService.balanceCredit(invoiceCustomerMoveLine);
invoice.setCompanyInTaxTotalRemaining(moveToolService.getInTaxTotalRemaining(invoice));
}
return move;
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveValidateService method validateMultiple.
public boolean validateMultiple(List<? extends Move> moveList) {
boolean error = false;
if (moveList == null) {
return error;
}
try {
for (Move move : moveList) {
validate(moveRepository.find(move.getId()));
JPA.clear();
}
} catch (Exception e) {
TraceBackService.trace(e);
error = true;
JPA.clear();
}
return error;
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class InvoicePaymentCancelServiceImpl method cancel.
/**
* Method to cancel an invoice Payment
*
* <p>Cancel the eventual Move and Reconcile Compute the total amount paid on the linked invoice
* Change the status to cancel
*
* @param invoicePayment An invoice payment
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void cancel(InvoicePayment invoicePayment) throws AxelorException {
Move paymentMove = invoicePayment.getMove();
Reconcile reconcile = invoicePayment.getReconcile();
log.debug("cancel : reconcile : {}", reconcile);
if (reconcile != null && reconcile.getStatusSelect() == ReconcileRepository.STATUS_CONFIRMED) {
reconcileService.unreconcile(reconcile);
}
if (paymentMove != null && invoicePayment.getTypeSelect() == InvoicePaymentRepository.TYPE_PAYMENT) {
invoicePayment.setMove(null);
moveCancelService.cancel(paymentMove);
} else {
this.updateCancelStatus(invoicePayment);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class InvoicePaymentValidateServiceImpl method createMoveForInvoicePayment.
/**
* Method to create a payment move for an invoice Payment
*
* <p>Create a move and reconcile it with the invoice move
*
* @param invoicePayment An invoice payment
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public InvoicePayment createMoveForInvoicePayment(InvoicePayment invoicePayment) throws AxelorException {
Invoice invoice = invoicePayment.getInvoice();
Company company = invoice.getCompany();
PaymentMode paymentMode = invoicePayment.getPaymentMode();
Partner partner = invoice.getPartner();
LocalDate paymentDate = invoicePayment.getPaymentDate();
BigDecimal paymentAmount = invoicePayment.getAmount();
BankDetails companyBankDetails = invoicePayment.getCompanyBankDetails();
Account customerAccount;
Journal journal = paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails);
boolean isDebitInvoice = moveService.getMoveToolService().isDebitCustomer(invoice, true);
MoveLine invoiceMoveLine = moveService.getMoveToolService().getInvoiceCustomerMoveLineByLoop(invoice);
if (invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) {
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
customerAccount = accountConfigService.getAdvancePaymentAccount(accountConfig);
} else {
if (invoiceMoveLine == null) {
return null;
}
customerAccount = invoiceMoveLine.getAccount();
}
String origin = invoicePayment.getInvoice().getInvoiceId();
if (invoicePayment.getPaymentMode().getTypeSelect() == PaymentModeRepository.TYPE_CHEQUE || invoicePayment.getPaymentMode().getTypeSelect() == PaymentModeRepository.TYPE_IPO_CHEQUE) {
origin = invoicePayment.getChequeNumber() != null ? invoicePayment.getChequeNumber() : origin;
} else if (invoicePayment.getPaymentMode().getTypeSelect() == PaymentModeRepository.TYPE_BANK_CARD) {
origin = invoicePayment.getInvoicePaymentRef() != null ? invoicePayment.getInvoicePaymentRef() : origin;
}
if (invoicePayment.getInvoice().getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE || invoicePayment.getInvoice().getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND) {
origin = invoicePayment.getInvoice().getSupplierInvoiceNb();
}
Move move = moveService.getMoveCreateService().createMove(journal, company, invoicePayment.getCurrency(), partner, paymentDate, paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
move.setTradingName(invoice.getTradingName());
move.addMoveLineListItem(moveLineService.createMoveLine(move, partner, paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails), paymentAmount, isDebitInvoice, paymentDate, null, 1, origin, invoicePayment.getDescription()));
MoveLine customerMoveLine = moveLineService.createMoveLine(move, partner, customerAccount, paymentAmount, !isDebitInvoice, paymentDate, null, 2, origin, invoicePayment.getDescription());
move.addMoveLineListItem(customerMoveLine);
moveService.getMoveValidateService().validate(move);
if (invoice.getOperationSubTypeSelect() != InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) {
Reconcile reconcile = reconcileService.reconcile(invoiceMoveLine, customerMoveLine, true, false);
invoicePayment.setReconcile(reconcile);
}
invoicePayment.setMove(move);
invoicePaymentRepository.save(invoicePayment);
return invoicePayment;
}
Aggregations