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