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++;
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations