use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method findConsolidateMoveLine.
@Override
public MoveLine findConsolidateMoveLine(Map<List<Object>, MoveLine> map, MoveLine moveLine, List<Object> keys) {
if (map != null && !map.isEmpty()) {
Map<List<Object>, MoveLine> copyMap = new HashMap<List<Object>, MoveLine>(map);
while (!copyMap.isEmpty()) {
if (map.containsKey(keys)) {
MoveLine moveLineIt = map.get(keys);
int count = 0;
if (moveLineIt.getAnalyticMoveLineList() == null && moveLine.getAnalyticMoveLineList() == null) {
return moveLineIt;
} else if (moveLineIt.getAnalyticMoveLineList() == null || moveLine.getAnalyticMoveLineList() == null) {
break;
}
List<AnalyticMoveLine> list1 = moveLineIt.getAnalyticMoveLineList();
List<AnalyticMoveLine> list2 = moveLine.getAnalyticMoveLineList();
List<AnalyticMoveLine> copyList = new ArrayList<AnalyticMoveLine>(list1);
if (list1.size() == list2.size()) {
for (AnalyticMoveLine analyticDistributionLine : list2) {
for (AnalyticMoveLine analyticDistributionLineIt : copyList) {
if (analyticDistributionLine.getAnalyticAxis().equals(analyticDistributionLineIt.getAnalyticAxis()) && analyticDistributionLine.getAnalyticAccount().equals(analyticDistributionLineIt.getAnalyticAccount()) && analyticDistributionLine.getAccount().equals(analyticDistributionLineIt.getAccount()) && analyticDistributionLine.getPercentage().equals(analyticDistributionLineIt.getPercentage()) && ((analyticDistributionLine.getAnalyticJournal() == null && analyticDistributionLineIt.getAnalyticJournal() == null) || analyticDistributionLine.getAnalyticJournal().equals(analyticDistributionLineIt.getAnalyticJournal()))) {
copyList.remove(analyticDistributionLineIt);
count++;
break;
}
}
}
if (count == list1.size()) {
return moveLineIt;
}
}
} else {
return null;
}
}
}
return null;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveRemoveService method checkDaybookMove.
protected void checkDaybookMove(Move move) throws Exception {
String errorMessage = "";
Map<String, String> objectsLinkToMoveMap = archivingToolService.getObjectLinkTo(move, move.getId());
String moveModelError = null;
for (Map.Entry<String, String> entry : objectsLinkToMoveMap.entrySet()) {
String modelName = I18n.get(archivingToolService.getModelTitle(entry.getKey()));
if (!entry.getKey().equals("MoveLine")) {
if (moveModelError == null) {
moveModelError = modelName;
} else {
moveModelError += ", " + modelName;
}
}
}
if (moveModelError != null) {
errorMessage += String.format(I18n.get(IExceptionMessage.MOVE_ARCHIVE_NOT_OK_BECAUSE_OF_LINK_WITH), move.getReference(), moveModelError);
}
for (MoveLine moveLine : move.getMoveLineList()) {
errorMessage += checkDaybookMoveLine(moveLine);
}
if (errorMessage != null && !errorMessage.isEmpty()) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, errorMessage);
}
}
use of com.axelor.apps.account.db.MoveLine 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.MoveLine in project axelor-open-suite by axelor.
the class MoveToolService method getInTaxTotalRemaining.
@Transactional(rollbackOn = { Exception.class })
public BigDecimal getInTaxTotalRemaining(Invoice invoice) throws AxelorException {
BigDecimal inTaxTotalRemaining = BigDecimal.ZERO;
log.debug("Update Remaining amount of invoice : {}", invoice.getInvoiceId());
if (invoice != null) {
boolean isMinus = this.isMinus(invoice);
Beans.get(InvoiceRepository.class).save(invoice);
MoveLine moveLine = this.getCustomerMoveLineByLoop(invoice);
if (moveLine != null) {
inTaxTotalRemaining = inTaxTotalRemaining.add(moveLine.getAmountRemaining());
if (isMinus) {
inTaxTotalRemaining = inTaxTotalRemaining.negate();
}
}
}
return inTaxTotalRemaining;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveValidateService method validateWellBalancedMove.
/**
* Procédure permettant de vérifier qu'une écriture est équilibré, et la validé si c'est le cas
*
* @param move Une écriture
* @throws AxelorException
*/
public void validateWellBalancedMove(Move move) throws AxelorException {
log.debug("Well-balanced validation on account move {}", move.getReference());
if (move.getMoveLineList() != null) {
BigDecimal totalDebit = BigDecimal.ZERO;
BigDecimal totalCredit = BigDecimal.ZERO;
for (MoveLine moveLine : move.getMoveLineList()) {
if (moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0 && moveLine.getCredit().compareTo(BigDecimal.ZERO) > 0) {
throw new AxelorException(move, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.MOVE_6), moveLine.getName());
}
totalDebit = totalDebit.add(moveLine.getDebit());
totalCredit = totalCredit.add(moveLine.getCredit());
}
if (totalDebit.compareTo(totalCredit) != 0) {
throw new AxelorException(move, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.MOVE_7), move.getReference(), totalDebit, totalCredit);
}
}
}
Aggregations