use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ReimbursementExportService method createReimbursementMove.
/**
* Methode permettant de créer l'écriture de remboursement
*
* @param reimbursement Un objet d'export des prélèvements
* @throws AxelorException
*/
public void createReimbursementMove(Reimbursement reimbursement, Company company) throws AxelorException {
reimbursement = reimbursementRepo.find(reimbursement.getId());
Partner partner = null;
Move newMove = null;
boolean first = true;
AccountConfig accountConfig = company.getAccountConfig();
if (reimbursement.getMoveLineSet() != null && !reimbursement.getMoveLineSet().isEmpty()) {
int seq = 1;
for (MoveLine moveLine : reimbursement.getMoveLineSet()) {
BigDecimal amountRemaining = moveLine.getAmountRemaining();
if (amountRemaining.compareTo(BigDecimal.ZERO) > 0) {
partner = moveLine.getPartner();
// On passe les lignes d'écriture (trop perçu) à l'état 'remboursé'
moveLine.setReimbursementStatusSelect(MoveLineRepository.REIMBURSEMENT_STATUS_REIMBURSED);
if (first) {
newMove = moveService.getMoveCreateService().createMove(accountConfig.getReimbursementJournal(), company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
first = false;
}
// Création d'une ligne au débit
MoveLine newDebitMoveLine = moveLineService.createMoveLine(newMove, partner, moveLine.getAccount(), amountRemaining, true, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
newMove.getMoveLineList().add(newDebitMoveLine);
if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
newDebitMoveLine.setDescription(reimbursement.getDescription());
}
seq++;
// Création de la réconciliation
Reconcile reconcile = reconcileService.createReconcile(newDebitMoveLine, moveLine, amountRemaining, false);
if (reconcile != null) {
reconcileService.confirmReconcile(reconcile, true);
}
}
}
// Création de la ligne au crédit
MoveLine newCreditMoveLine = moveLineService.createMoveLine(newMove, partner, accountConfig.getReimbursementAccount(), reimbursement.getAmountReimbursed(), false, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
newMove.getMoveLineList().add(newCreditMoveLine);
if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
newCreditMoveLine.setDescription(reimbursement.getDescription());
}
moveService.getMoveValidateService().validate(newMove);
moveRepo.save(newMove);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ReimbursementImportService method createReimbursementRejectMove.
public void createReimbursementRejectMove(List<String[]> rejectList, Company company) throws AxelorException {
int seq = 1;
if (rejectList != null && !rejectList.isEmpty()) {
LocalDate rejectDate = rejectImportService.createRejectDate(rejectList.get(0)[0]);
Move move = this.createMoveReject(company, rejectDate);
for (String[] reject : rejectList) {
this.createReimbursementRejectMoveLine(reject, company, seq, move, rejectDate);
seq++;
}
if (move != null) {
// Création d'une ligne au débit
MoveLine debitMoveLine = moveLineService.createMoveLine(move, null, company.getAccountConfig().getReimbursementAccount(), this.getTotalAmount(move), true, rejectDate, seq, null, null);
move.getMoveLineList().add(debitMoveLine);
this.validateMove(move);
}
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method udpatePaymentTax.
protected void udpatePaymentTax(Reconcile reconcile) throws AxelorException {
Move debitMove = reconcile.getDebitMoveLine().getMove();
Move creditMove = reconcile.getCreditMoveLine().getMove();
Invoice debitInvoice = debitMove.getInvoice();
Invoice creditInvoice = creditMove.getInvoice();
if (debitInvoice != null && creditInvoice == null) {
moveLineService.generateTaxPaymentMoveLineList(reconcile.getCreditMoveLine(), debitInvoice, reconcile);
}
if (creditInvoice != null && debitInvoice == null) {
moveLineService.generateTaxPaymentMoveLineList(reconcile.getDebitMoveLine(), creditInvoice, reconcile);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method reverseTaxPaymentMoveLines.
protected void reverseTaxPaymentMoveLines(Reconcile reconcile) throws AxelorException {
Move debitMove = reconcile.getDebitMoveLine().getMove();
Move creditMove = reconcile.getCreditMoveLine().getMove();
Invoice debitInvoice = debitMove.getInvoice();
Invoice creditInvoice = creditMove.getInvoice();
if (debitInvoice == null) {
moveLineService.reverseTaxPaymentMoveLines(reconcile.getDebitMoveLine(), reconcile);
}
if (creditInvoice == null) {
moveLineService.reverseTaxPaymentMoveLines(reconcile.getCreditMoveLine(), reconcile);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method updateInvoicePayments.
public void updateInvoicePayments(Reconcile reconcile) throws AxelorException {
MoveLine debitMoveLine = reconcile.getDebitMoveLine();
MoveLine creditMoveLine = reconcile.getCreditMoveLine();
Move debitMove = debitMoveLine.getMove();
Move creditMove = creditMoveLine.getMove();
Invoice debitInvoice = debitMove.getInvoice();
Invoice creditInvoice = creditMove.getInvoice();
BigDecimal amount = reconcile.getAmount();
if (debitInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
InvoicePayment debitInvoicePayment = invoicePaymentCreateService.createInvoicePayment(debitInvoice, amount, creditMove);
debitInvoicePayment.setReconcile(reconcile);
}
if (creditInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
InvoicePayment creditInvoicePayment = invoicePaymentCreateService.createInvoicePayment(creditInvoice, amount, debitMove);
creditInvoicePayment.setReconcile(reconcile);
}
}
Aggregations