use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class AccountClearanceService method validateAccountClearance.
@Transactional(rollbackOn = { Exception.class })
public void validateAccountClearance(AccountClearance accountClearance) throws AxelorException {
Company company = accountClearance.getCompany();
AccountConfig accountConfig = company.getAccountConfig();
Tax tax = accountConfig.getStandardRateTax();
BigDecimal taxRate = taxService.getTaxRate(tax, appBaseService.getTodayDateTime().toLocalDate());
Account taxAccount = taxAccountService.getAccount(tax, company, false, false);
Account profitAccount = accountConfig.getProfitAccount();
Journal journal = accountConfig.getAccountClearanceJournal();
Set<MoveLine> moveLineList = accountClearance.getMoveLineSet();
for (MoveLine moveLine : moveLineList) {
Move move = this.createAccountClearanceMove(moveLine, taxRate, taxAccount, profitAccount, company, journal, accountClearance);
moveService.getMoveValidateService().validate(move);
}
accountClearance.setStatusSelect(AccountClearanceRepository.STATUS_VALIDATED);
accountClearance.setDateTime(appBaseService.getTodayDateTime());
accountClearance.setName(sequenceService.getSequenceNumber(SequenceRepository.ACCOUNT_CLEARANCE, company));
accountClearanceRepo.save(accountClearance);
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class IrrecoverableService method testCompanyField.
/**
* Procédure permettant de vérifier les champs d'une société
*
* @param company Une société
* @throws AxelorException
*/
public void testCompanyField(Company company) throws AxelorException {
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
accountConfigService.getIrrecoverableAccount(accountConfig);
accountConfigService.getIrrecoverableJournal(accountConfig);
accountConfigService.getIrrecoverableStandardRateTax(accountConfig);
}
use of com.axelor.apps.account.db.AccountConfig 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.AccountConfig in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method getDefaultCompanyBankDetailsFromFactorPartner.
private BankDetails getDefaultCompanyBankDetailsFromFactorPartner(Company company) throws AxelorException {
AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
if (accountConfig.getFactorPartner() == null) {
return null;
}
List<BankDetails> bankDetailsList = accountConfig.getFactorPartner().getBankDetailsList();
return bankDetailsList.stream().filter(bankDetails -> bankDetails.getIsDefault()).findFirst().orElse(null);
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class AccountingReportServiceImpl method isThereTooManyLines.
public boolean isThereTooManyLines(AccountingReport accountingReport) throws AxelorException {
AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(accountingReport.getCompany());
Integer lineMinBeforeLongReportGenerationMessageNumber = accountConfig.getLineMinBeforeLongReportGenerationMessageNumber();
if (lineMinBeforeLongReportGenerationMessageNumber != null && lineMinBeforeLongReportGenerationMessageNumber > 0) {
if (accountingReport.getReportType() == null) {
return false;
}
Integer typeSelect = accountingReport.getReportType().getTypeSelect();
long count = 0;
if (typeSelect > 0 && typeSelect <= AccountingReportRepository.REPORT_GENERAL_LEDGER2) {
count = Beans.get(MoveLineRepository.class).all().filter(this.getMoveLineList(accountingReport)).count();
} else if (typeSelect == AccountingReportRepository.REPORT_VAT_STATEMENT_RECEIVED) {
count = Beans.get(TaxPaymentMoveLineRepository.class).all().filter(this.getTaxPaymentMoveLineList(accountingReport)).count();
} else if (typeSelect == AccountingReportRepository.REPORT_ACQUISITIONS) {
count = Beans.get(FixedAssetRepository.class).all().filter(this.getFixedAssetList(accountingReport)).count();
count += JPA.em().createQuery("Select invoiceLine FROM InvoiceLine invoiceLine LEFT JOIN FixedAsset fixedAsset on fixedAsset.invoiceLine = invoiceLine.id WHERE invoiceLine.fixedAssets = true and fixedAsset.invoiceLine is null ").getResultList().size();
} else if (typeSelect == AccountingReportRepository.REPORT_GROSS_VALUES_AND_DEPRECIATION) {
count = Beans.get(FixedAssetRepository.class).all().filter(this.getFixedAssetList(accountingReport)).count();
} else if (typeSelect == AccountingReportRepository.REPORT_ANALYTIC_BALANCE) {
count = Beans.get(AnalyticMoveLineRepository.class).all().filter(this.getAnalyticMoveLineList(accountingReport)).count();
} else {
return false;
}
return count > lineMinBeforeLongReportGenerationMessageNumber;
} else {
return false;
}
}
Aggregations