Search in sources :

Example 41 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoicePaymentController method filterPaymentMode.

// filter the payment mode depending on the target invoice
@SuppressWarnings("unchecked")
public void filterPaymentMode(ActionRequest request, ActionResponse response) {
    Map<String, Object> partialInvoice = (Map<String, Object>) request.getContext().get("_invoice");
    Invoice invoice = Beans.get(InvoiceRepository.class).find(Long.valueOf(partialInvoice.get("id").toString()));
    PaymentMode paymentMode = invoice.getPaymentMode();
    if (invoice != null && paymentMode != null) {
        if (paymentMode.getInOutSelect() != null) {
            response.setAttr("paymentMode", "domain", "self.inOutSelect = " + paymentMode.getInOutSelect());
        }
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) Map(java.util.Map) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 42 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class ImportInvoice method importInvoice.

@Transactional(rollbackOn = { Exception.class })
public Object importInvoice(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof Invoice;
    Invoice invoice = (Invoice) bean;
    if (invoice.getAddress() != null) {
        invoice.setAddressStr(addressService.computeAddressStr(invoice.getAddress()));
    }
    invoiceRepo.save(invoice);
    if (invoice.getStatusSelect() == InvoiceRepository.STATUS_DRAFT) {
        invoiceService.setDraftSequence(invoice);
    }
    return invoice;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Transactional(com.google.inject.persist.Transactional)

Example 43 with Invoice

use of com.axelor.apps.account.db.Invoice 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;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) MoveLine(com.axelor.apps.account.db.MoveLine) PayVoucherDueElement(com.axelor.apps.account.db.PayVoucherDueElement) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Example 44 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class PaymentVoucherController method initFromInvoice.

public void initFromInvoice(ActionRequest request, ActionResponse response) {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    @SuppressWarnings("unchecked") Invoice invoice = Mapper.toBean(Invoice.class, (Map<String, Object>) request.getContext().get("_invoice"));
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        Beans.get(PaymentVoucherLoadService.class).initFromInvoice(paymentVoucher, invoice);
        response.setValues(paymentVoucher);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentVoucherLoadService(com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Example 45 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class SaleOrderComputeServiceSupplychainImpl method computeTotalInvoiceAdvancePayment.

protected BigDecimal computeTotalInvoiceAdvancePayment(SaleOrder saleOrder) {
    BigDecimal total = BigDecimal.ZERO;
    if (saleOrder.getId() == null) {
        return total;
    }
    List<Invoice> advancePaymentInvoiceList = Beans.get(InvoiceRepository.class).all().filter("self.saleOrder.id = :saleOrderId AND self.operationSubTypeSelect = :operationSubTypeSelect").bind("saleOrderId", saleOrder.getId()).bind("operationSubTypeSelect", InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE).fetch();
    if (advancePaymentInvoiceList == null || advancePaymentInvoiceList.isEmpty()) {
        return total;
    }
    for (Invoice advance : advancePaymentInvoiceList) {
        total = total.add(advance.getAmountPaid());
    }
    return total;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) BigDecimal(java.math.BigDecimal)

Aggregations

Invoice (com.axelor.apps.account.db.Invoice)195 AxelorException (com.axelor.exception.AxelorException)69 ArrayList (java.util.ArrayList)48 Transactional (com.google.inject.persist.Transactional)46 BigDecimal (java.math.BigDecimal)32 Company (com.axelor.apps.base.db.Company)31 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)29 Partner (com.axelor.apps.base.db.Partner)27 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)22 InvoiceService (com.axelor.apps.account.service.invoice.InvoiceService)22 PaymentMode (com.axelor.apps.account.db.PaymentMode)21 Map (java.util.Map)21 List (java.util.List)20 StockMove (com.axelor.apps.stock.db.StockMove)19 RefundInvoice (com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 LocalDate (java.time.LocalDate)17 InvoiceGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceGenerator)16 Context (com.axelor.rpc.Context)15 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)14