use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class InvoiceController method setDefaultMail.
/**
* set default value for automatic invoice printing
*
* @param request
* @param response
* @throws AxelorException
*/
public void setDefaultMail(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
Company company = invoice.getCompany();
Partner partner = invoice.getPartner();
if (company != null && partner != null) {
AccountingSituation accountingSituation = Beans.get(AccountingSituationService.class).getAccountingSituation(partner, company);
if (accountingSituation != null) {
response.setValue("invoiceAutomaticMail", accountingSituation.getInvoiceAutomaticMail());
response.setValue("invoiceMessageTemplate", accountingSituation.getInvoiceMessageTemplate());
response.setValue("invoiceAutomaticMailOnValidate", accountingSituation.getInvoiceAutomaticMailOnValidate());
response.setValue("invoiceMessageTemplateOnValidate", accountingSituation.getInvoiceMessageTemplateOnValidate());
}
}
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class ImportMove method importFECMove.
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public Object importFECMove(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof MoveLine;
MoveLine moveLine = (MoveLine) bean;
try {
moveLine.setCounter(1);
if (values.get("EcritureNum") == null) {
return null;
}
String moveReference = values.get("EcritureNum").toString();
MoveLine mvLine = moveLineRepo.all().filter("self.name LIKE '" + moveReference + "-%'").order("-counter").fetchOne();
if (mvLine != null) {
int counter = mvLine.getCounter() + 1;
moveLine.setCounter(counter);
}
if (values.get("EcritureDate") != null) {
LocalDate moveLineDate = LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE);
moveLine.setDate(moveLineDate);
}
Move move = moveRepository.all().filter("self.reference = ?", moveReference).fetchOne();
if (move == null) {
move = new Move();
move.setReference(moveReference);
if (values.get("ValidDate") != null) {
move.setStatusSelect(MoveRepository.STATUS_VALIDATED);
move.setValidationDate(LocalDate.parse(values.get("ValidDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
} else {
move.setStatusSelect(MoveRepository.STATUS_ACCOUNTED);
}
move.setCompany(getCompany(values));
move.setCompanyCurrency(move.getCompany().getCurrency());
move.setDate(LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
move.setPeriod(Beans.get(PeriodService.class).getPeriod(move.getDate(), move.getCompany(), YearRepository.TYPE_FISCAL));
if (values.get("Idevise") != null) {
move.setCurrency(Beans.get(CurrencyRepository.class).findByCode(values.get("Idevise").toString()));
move.setCurrencyCode(values.get("Idevise").toString());
}
if (values.get("JournalCode") != null) {
Journal journal = Beans.get(JournalRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("JournalCode").toString(), move.getCompany().getId()).fetchOne();
move.setJournal(journal);
}
if (values.get("CompAuxNum") != null) {
Partner partner = Beans.get(PartnerRepository.class).all().filter("self.partnerSeq = ?", values.get("CompAuxNum").toString()).fetchOne();
move.setPartner(partner);
}
moveRepository.save(move);
}
if (values.get("CompteNum") != null) {
Account account = Beans.get(AccountRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("CompteNum").toString(), move.getCompany().getId()).fetchOne();
moveLine.setAccount(account);
}
moveLine.setMove(move);
} catch (Exception e) {
TraceBackService.trace(e);
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, e.getMessage());
}
return moveLine;
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class ImportMoveLine method importMoveLine.
@Transactional(rollbackOn = Exception.class)
public Object importMoveLine(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof MoveLine;
MoveLine moveLine = (MoveLine) bean;
String accountId = (String) values.get("account_importId");
Account account = getAccount(accountId);
if (account != null) {
moveLine.setAccountCode(account.getCode());
moveLine.setAccountName(account.getName());
} else {
moveLine.setAccountCode((String) values.get("accountCode"));
moveLine.setAccountName((String) values.get("accountName"));
}
String taxLineId = (String) values.get("taxLine_importId");
TaxLine taxLine = getTaxLine(taxLineId);
if (taxLine != null) {
moveLine.setTaxCode(taxLine.getTax().getCode());
moveLine.setTaxRate(taxLine.getValue());
} else {
moveLine.setTaxCode((String) values.get("taxCode"));
moveLine.setTaxRate(new BigDecimal((String) values.get("taxRate")));
}
String partnerId = (String) values.get("partner_importId");
Partner partner = getPartner(partnerId);
if (partner != null) {
moveLine.setPartnerSeq(partner.getPartnerSeq());
moveLine.setPartnerFullName(partner.getFullName());
} else {
moveLine.setPartnerSeq((String) values.get("partnerSeq"));
moveLine.setPartnerFullName((String) values.get("partnerFullName"));
}
moveLineRepository.save(moveLine);
return moveLine;
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class PartnerController method getDefaultSpecificTaxNote.
public void getDefaultSpecificTaxNote(ActionRequest request, ActionResponse response) {
Partner partner = request.getContext().asType(Partner.class);
response.setValue("specificTaxNote", Beans.get(PartnerAccountService.class).getDefaultSpecificTaxNote(partner));
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class PaymentVoucherController method fillCompanyBankDetails.
/**
* Called on load and in partner, company or payment mode change. Fill the bank details with a
* default value.
*
* @param request
* @param response
* @throws AxelorException
*/
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
Company company = paymentVoucher.getCompany();
Partner partner = paymentVoucher.getPartner();
if (company == null) {
return;
}
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
response.setValue("companyBankDetails", defaultBankDetails);
}
Aggregations