use of com.axelor.apps.account.db.MoveLine 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.account.db.MoveLine in project axelor-open-suite by axelor.
the class ImportPaymentVoucher method importPaymentVoucher.
@SuppressWarnings("rawtypes")
public Object importPaymentVoucher(Object bean, Map values) {
assert bean instanceof PaymentVoucher;
try {
PaymentVoucher paymentVoucher = (PaymentVoucher) bean;
Invoice invoiceToPay = getInvoice((String) values.get("orderImport"));
MoveLine moveLineToPay = this.getMoveLineToPay(paymentVoucher, invoiceToPay);
if (moveLineToPay != null) {
PayVoucherDueElement payVoucherDueElement = paymentVoucherLoadService.createPayVoucherDueElement(moveLineToPay);
paymentVoucher.addPayVoucherElementToPayListItem(paymentVoucherLoadService.createPayVoucherElementToPay(paymentVoucher, payVoucherDueElement, 1));
}
if (paymentVoucher.getStatusSelect() == PaymentVoucherRepository.STATUS_CONFIRMED) {
paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher);
}
return paymentVoucher;
} catch (Exception e) {
TraceBackService.trace(e);
}
return bean;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveController method checkRemoveLines.
public void checkRemoveLines(ActionRequest request, ActionResponse response) {
try {
Move moveView = request.getContext().asType(Move.class);
if (moveView.getId() == null) {
return;
}
Move moveBD = Beans.get(MoveRepository.class).find(moveView.getId());
List<String> moveLineReconciledAndRemovedNameList = new ArrayList<>();
for (MoveLine moveLineBD : moveBD.getMoveLineList()) {
if (!moveView.getMoveLineList().contains(moveLineBD)) {
if (moveLineBD.getReconcileGroup() != null) {
moveLineReconciledAndRemovedNameList.add(moveLineBD.getName());
}
}
}
if (moveLineReconciledAndRemovedNameList != null && !moveLineReconciledAndRemovedNameList.isEmpty()) {
response.setError(String.format(I18n.get(IExceptionMessage.MOVE_LINE_RECONCILE_LINE_CANNOT_BE_REMOVED), moveLineReconciledAndRemovedNameList.toString()));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveLineController method computeTaxAmount.
public void computeTaxAmount(ActionRequest request, ActionResponse response) {
try {
MoveLine moveLine = request.getContext().asType(MoveLine.class);
moveLine = Beans.get(MoveLineService.class).computeTaxAmount(moveLine);
response.setValues(moveLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveLineController method usherProcess.
public void usherProcess(ActionRequest request, ActionResponse response) {
MoveLine moveLine = request.getContext().asType(MoveLine.class);
moveLine = Beans.get(MoveLineRepository.class).find(moveLine.getId());
try {
Beans.get(MoveLineService.class).usherProcess(moveLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations