Search in sources :

Example 61 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class MoveValidateService method completeMoveLines.

/**
 * In move lines, fill the dates field and the partner if they are missing, and fill the counter.
 *
 * @param move
 */
public void completeMoveLines(Move move) {
    LocalDate date = move.getDate();
    Partner partner = move.getPartner();
    int counter = 1;
    for (MoveLine moveLine : move.getMoveLineList()) {
        if (moveLine.getDate() == null) {
            moveLine.setDate(date);
        }
        if (moveLine.getAccount() != null && moveLine.getAccount().getUseForPartnerBalance() && moveLine.getDueDate() == null) {
            moveLine.setDueDate(date);
        }
        if (moveLine.getOriginDate() == null) {
            moveLine.setOriginDate(date);
        }
        if (partner != null) {
            moveLine.setPartner(partner);
        }
        moveLine.setCounter(counter);
        counter++;
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) LocalDate(java.time.LocalDate) Partner(com.axelor.apps.base.db.Partner)

Example 62 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class MoveAdjustementService method createAdjustmentDebitMove.

/**
 * Creating move of passage in gap regulation (on debit)
 *
 * @param debitMoveLine
 * @return
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public void createAdjustmentDebitMove(MoveLine debitMoveLine) throws AxelorException {
    Partner partner = debitMoveLine.getPartner();
    Account account = debitMoveLine.getAccount();
    Move debitMove = debitMoveLine.getMove();
    Company company = debitMove.getCompany();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
    Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    Move adjustmentMove = moveCreateService.createMove(miscOperationJournal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMove.getFunctionalOriginSelect());
    // Création de la ligne au crédit
    MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, account, debitAmountRemaining, false, appAccountService.getTodayDate(company), 1, null, null);
    // Création de la ligne au debit
    MoveLine debitAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, true, appAccountService.getTodayDate(company), 2, null, null);
    adjustmentMove.addMoveLineListItem(creditAdjustmentMoveLine);
    adjustmentMove.addMoveLineListItem(debitAdjustmentMoveLine);
    moveValidateService.validate(adjustmentMove);
    moveRepository.save(adjustmentMove);
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 63 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class MoveDueService method getInvoiceDue.

public List<MoveLine> getInvoiceDue(Invoice invoice, boolean useOthersInvoiceDue) throws AxelorException {
    Company company = invoice.getCompany();
    Partner partner = invoice.getPartner();
    List<MoveLine> debitMoveLines = Lists.newArrayList();
    // Ajout de la facture d'origine
    MoveLine originalInvoice = this.getOrignalInvoiceFromRefund(invoice);
    if (originalInvoice != null) {
        debitMoveLines.add(originalInvoice);
    }
    // Récupérer les dûs du tiers pour le même compte que celui de l'avoir
    List<? extends MoveLine> othersDebitMoveLines = null;
    if (useOthersInvoiceDue) {
        if (debitMoveLines != null && debitMoveLines.size() != 0) {
            othersDebitMoveLines = moveLineRepository.all().filter("self.move.company = ?1 AND (self.move.statusSelect = ?2 OR self.move.statusSelect = ?3) AND self.move.ignoreInAccountingOk IN (false,null)" + " AND self.account.useForPartnerBalance = ?4 AND self.debit > 0 AND self.amountRemaining > 0 " + " AND self.partner = ?5 AND self NOT IN (?6) ORDER BY self.date ASC ", company, MoveRepository.STATUS_VALIDATED, MoveRepository.STATUS_ACCOUNTED, true, partner, debitMoveLines).fetch();
        } else {
            othersDebitMoveLines = moveLineRepository.all().filter("self.move.company = ?1 AND (self.move.statusSelect = ?2 OR self.move.statusSelect = ?3) AND self.move.ignoreInAccountingOk IN (false,null)" + " AND self.account.useForPartnerBalance = ?4 AND self.debit > 0 AND self.amountRemaining > 0 " + " AND self.partner = ?5 ORDER BY self.date ASC ", company, MoveRepository.STATUS_VALIDATED, MoveRepository.STATUS_ACCOUNTED, true, partner).fetch();
        }
        debitMoveLines.addAll(othersDebitMoveLines);
    }
    log.debug("Nombre de ligne à payer avec l'avoir récupéré : {}", debitMoveLines.size());
    return debitMoveLines;
}
Also used : Company(com.axelor.apps.base.db.Company) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner)

Example 64 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class ImportPartner method updateContacts.

public Object updateContacts(Object bean, Map<String, Object> values) {
    assert bean instanceof Partner;
    Partner partner = (Partner) bean;
    partner.setContactPartnerSet(new HashSet<Partner>());
    List<? extends Partner> partnerList = partnerRepo.all().filter("self.mainPartner.id = ?1", partner.getId()).fetch();
    for (Partner pt : partnerList) partner.getContactPartnerSet().add(pt);
    return partner;
}
Also used : Partner(com.axelor.apps.base.db.Partner)

Example 65 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class ImportPartner method importPartner.

public Object importPartner(Object bean, Map<String, Object> values) {
    assert bean instanceof Partner;
    Partner partner = (Partner) bean;
    partnerService.setPartnerFullName(partner);
    final Path path = (Path) values.get("__path__");
    String fileName = (String) values.get("picture_fileName");
    if (Strings.isNullOrEmpty((fileName))) {
        return bean;
    }
    final File image = path.resolve(fileName).toFile();
    try {
        final MetaFile metaFile = metaFiles.upload(image);
        partner.setPicture(metaFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bean;
}
Also used : Path(java.nio.file.Path) MetaFile(com.axelor.meta.db.MetaFile) IOException(java.io.IOException) Partner(com.axelor.apps.base.db.Partner) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile)

Aggregations

Partner (com.axelor.apps.base.db.Partner)199 AxelorException (com.axelor.exception.AxelorException)68 Company (com.axelor.apps.base.db.Company)67 Transactional (com.google.inject.persist.Transactional)54 BigDecimal (java.math.BigDecimal)43 ArrayList (java.util.ArrayList)34 MoveLine (com.axelor.apps.account.db.MoveLine)32 Move (com.axelor.apps.account.db.Move)30 PaymentMode (com.axelor.apps.account.db.PaymentMode)26 LocalDate (java.time.LocalDate)26 Account (com.axelor.apps.account.db.Account)25 Invoice (com.axelor.apps.account.db.Invoice)24 BankDetails (com.axelor.apps.base.db.BankDetails)24 List (java.util.List)22 PartnerService (com.axelor.apps.base.service.PartnerService)18 Map (java.util.Map)18 Journal (com.axelor.apps.account.db.Journal)17 Address (com.axelor.apps.base.db.Address)14 Currency (com.axelor.apps.base.db.Currency)14 AccountConfig (com.axelor.apps.account.db.AccountConfig)13