Search in sources :

Example 66 with Company

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

the class PaymentVoucherSequenceService method getReference.

public String getReference(PaymentVoucher paymentVoucher) throws AxelorException {
    PaymentMode paymentMode = paymentVoucher.getPaymentMode();
    Company company = paymentVoucher.getCompany();
    return sequenceService.getSequenceNumber(paymentModeService.getPaymentModeSequence(paymentMode, company, paymentVoucher.getCompanyBankDetails()));
}
Also used : Company(com.axelor.apps.base.db.Company) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 67 with Company

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

the class InvoicePaymentCreateServiceImpl method getInvoiceIdsToPay.

@Override
public List<Long> getInvoiceIdsToPay(List<Long> invoiceIdList) throws AxelorException {
    Company company = null;
    Currency currency = null;
    List<Long> invoiceToPay = new ArrayList<>();
    Boolean isActivatePassedForPayment = Beans.get(AppAccountService.class).getAppAccount().getActivatePassedForPayment();
    for (Long invoiceId : invoiceIdList) {
        Invoice invoice = Beans.get(InvoiceRepository.class).find(invoiceId);
        if ((invoice.getStatusSelect() != InvoiceRepository.STATUS_VENTILATED && invoice.getOperationSubTypeSelect() != InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) || (invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE && invoice.getStatusSelect() != InvoiceRepository.STATUS_VALIDATED)) {
            continue;
        }
        if (invoice.getAmountRemaining().compareTo(BigDecimal.ZERO) <= 0) {
            continue;
        }
        if (company == null) {
            company = invoice.getCompany();
        }
        if (currency == null) {
            currency = invoice.getCurrency();
        }
        if (invoice.getCompany() == null || company == null || !invoice.getCompany().equals(company)) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MERGE_ERROR_COMPANY));
        }
        if (invoice.getCurrency() == null || currency == null || !invoice.getCurrency().equals(currency)) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MERGE_ERROR_CURRENCY));
        }
        if (isActivatePassedForPayment && invoice.getPfpValidateStatusSelect() != InvoiceRepository.PFP_STATUS_VALIDATED) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MASS_PAYMENT_ERROR_PFP_LITIGATION));
        }
        invoiceToPay.add(invoiceId);
    }
    return invoiceToPay;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) Currency(com.axelor.apps.base.db.Currency) ArrayList(java.util.ArrayList) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository)

Example 68 with Company

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

the class UpdateAll method updatePeriod.

@Transactional
public Object updatePeriod(Object bean, Map<String, Object> values) {
    try {
        assert bean instanceof Company;
        Company company = (Company) bean;
        for (Year year : yearRepo.all().filter("self.company.id = ?1 AND self.typeSelect = 1", company.getId()).fetch()) {
            if (!year.getPeriodList().isEmpty()) {
                continue;
            }
            for (Integer month : Arrays.asList(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 })) {
                Period period = new Period();
                LocalDate dt = LocalDate.of(year.getFromDate().getYear(), month, 1);
                period.setFromDate(dt.withDayOfMonth(1));
                period.setToDate(dt.withDayOfMonth(dt.lengthOfMonth()));
                period.setYear(year);
                period.setStatusSelect(PeriodRepository.STATUS_OPENED);
                period.setCode((dt.toString().split("-")[1] + "/" + year.getCode().split("_")[0] + "_" + company.getCode()).toUpperCase());
                period.setName(dt.toString().split("-")[1] + '/' + year.getName());
                periodRepo.save(period);
            }
        }
        return company;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return bean;
}
Also used : Company(com.axelor.apps.base.db.Company) Year(com.axelor.apps.base.db.Year) Period(com.axelor.apps.base.db.Period) LocalDate(java.time.LocalDate) Transactional(com.google.inject.persist.Transactional)

Example 69 with Company

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

the class ImportCompany method importCompany.

public Object importCompany(Object bean, Map<String, Object> values) {
    assert bean instanceof Company;
    Company company = (Company) bean;
    String fileName = (String) values.get("logo_fileName");
    if (!StringUtils.isEmpty(fileName)) {
        final Path path = (Path) values.get("__path__");
        try {
            final File image = path.resolve(fileName).toFile();
            if (image != null && image.isFile()) {
                final MetaFile metaFile = metaFiles.upload(image);
                company.setLogo(metaFile);
            }
        } catch (Exception e) {
            LOG.error("Error when importing company : {}", e);
        }
    }
    return company;
}
Also used : Path(java.nio.file.Path) Company(com.axelor.apps.base.db.Company) MetaFile(com.axelor.meta.db.MetaFile) MetaFile(com.axelor.meta.db.MetaFile) File(java.io.File)

Example 70 with Company

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

the class ContractLineServiceImpl method fill.

@Override
public ContractLine fill(ContractLine contractLine, Product product) throws AxelorException {
    Preconditions.checkNotNull(product, I18n.get(IExceptionMessage.CONTRACT_EMPTY_PRODUCT));
    Company company = contractLine.getContractVersion() != null ? contractLine.getContractVersion().getContract() != null ? contractLine.getContractVersion().getContract().getCompany() : null : null;
    contractLine.setProductName((String) productCompanyService.get(product, "name", company));
    Unit unit = (Unit) productCompanyService.get(product, "salesUnit", company);
    if (unit != null) {
        contractLine.setUnit(unit);
    } else {
        contractLine.setUnit((Unit) productCompanyService.get(product, "unit", company));
    }
    contractLine.setPrice((BigDecimal) productCompanyService.get(product, "salePrice", company));
    contractLine.setDescription((String) productCompanyService.get(product, "description", company));
    return contractLine;
}
Also used : Company(com.axelor.apps.base.db.Company) Unit(com.axelor.apps.base.db.Unit)

Aggregations

Company (com.axelor.apps.base.db.Company)213 Transactional (com.google.inject.persist.Transactional)72 Partner (com.axelor.apps.base.db.Partner)68 AxelorException (com.axelor.exception.AxelorException)65 BigDecimal (java.math.BigDecimal)54 Move (com.axelor.apps.account.db.Move)35 MoveLine (com.axelor.apps.account.db.MoveLine)35 LocalDate (java.time.LocalDate)35 ArrayList (java.util.ArrayList)31 PaymentMode (com.axelor.apps.account.db.PaymentMode)28 AccountConfig (com.axelor.apps.account.db.AccountConfig)27 Journal (com.axelor.apps.account.db.Journal)26 Account (com.axelor.apps.account.db.Account)25 Invoice (com.axelor.apps.account.db.Invoice)25 BankDetails (com.axelor.apps.base.db.BankDetails)22 Currency (com.axelor.apps.base.db.Currency)19 Product (com.axelor.apps.base.db.Product)17 StockLocation (com.axelor.apps.stock.db.StockLocation)17 StockMove (com.axelor.apps.stock.db.StockMove)15 List (java.util.List)15