Package org.bigk.invoices.model

Examples of org.bigk.invoices.model.Invoice


  public Invoice prepareNewInvoice() throws ServiceException {
    if (logger.isDebugEnabled()) {
      logger.debug("prepareNewInvoice() - start");
    }
   
    Invoice invoice = null;
    if (this.invoiceTemplate != null) {
      try {
        invoice = invoiceTemplate.clone();
      } catch (CloneNotSupportedException e) {
        logger.warn("prepareNewInvoice()", e);
      }
    }
   
    if (invoice == null) {
      invoice = new Invoice();
    }

    Calendar nowDay = Calendar.getInstance();
    nowDay.set(Calendar.HOUR, 0);
    nowDay.set(Calendar.MINUTE, 0);
    nowDay.set(Calendar.SECOND, 0);
    nowDay.set(Calendar.MILLISECOND, 0);
   
    String curYear = Integer.toString(nowDay.get(Calendar.YEAR));
    String curMonth = Integer.toString(nowDay.get(Calendar.MONTH) + 1);
    curMonth = StringUtils.right("0" + curMonth, 2);
   
    curYear += "/" + curMonth;
    invoice.setYear(curYear);
   
    int maxInvoiceNumber = this.getMaxInvoiceNumber(curYear);
    maxInvoiceNumber++;
   
    Long number = new Long(maxInvoiceNumber);
    invoice.setNumber(number);
    invoice.setDocumentDate(nowDay.getTime());
    invoice.setSoldDate(nowDay.getTime());
   
    PaymentKind pk = null;
    if (invoice.getPaymentKindId() != null) {
      pk = paymentKindsService.getPaymentKind(invoice.getPaymentKindId());
    }
   
    Date paymentDate = null;
    if (pk != null) {
      invoice.setPaymentKind(pk);
      paymentDate = paymentKindsService.calculatePaymentDate(nowDay.getTime(), pk.getId());
      invoice.setPaymentDate(paymentDate);
    }
   
    recalculateInvoice(invoice);
    hrInvoiceNumberService.updateHRInvoiceNumber(invoice);
View Full Code Here


  public Invoice getInvoice(Long id) throws ServiceException {
    if (logger.isDebugEnabled()) {
      logger.debug("getInvoice(Long id=" + id + ") - start");
    }

    Invoice object = null;
    Session session = null;
    try {
      session = HibernateUtils.getCurrentSession();
      object = (Invoice) session.get(Invoice.class, id);
     
View Full Code Here

  public Invoice prepareNewInvoice() throws ServiceException {
    if (logger.isDebugEnabled()) {
      logger.debug("prepareNewInvoice() - start");
    }
   
    Invoice invoice = null;
    if (this.invoiceTemplate != null) {
      try {
        invoice = invoiceTemplate.clone();
      } catch (CloneNotSupportedException e) {
        logger.warn("prepareNewInvoice()", e);
      }
    }
   
    if (invoice == null) {
      invoice = new Invoice();
    }
   
    Calendar nowDay = Calendar.getInstance();
    nowDay.set(Calendar.HOUR, 0);
    nowDay.set(Calendar.MINUTE, 0);
    nowDay.set(Calendar.SECOND, 0);
    nowDay.set(Calendar.MILLISECOND, 0);
   
    Long curYear = new Long(nowDay.get(Calendar.YEAR));
    invoice.setYear(curYear.toString());
   
    int maxInvoiceNumber = this.getMaxInvoiceNumber(curYear.toString());
    maxInvoiceNumber++;
   
    Long number = new Long(maxInvoiceNumber);
    invoice.setNumber(number);
    invoice.setDocumentDate(nowDay.getTime());
    invoice.setSoldDate(nowDay.getTime());
   
    PaymentKind pk = null;
    if (invoice.getPaymentKindId() != null) {
      pk = paymentKindsService.getPaymentKind(invoice.getPaymentKindId());
    }
   
    Date paymentDate = null;
    if (pk != null) {
      invoice.setPaymentKind(pk);
      paymentDate = paymentKindsService.calculatePaymentDate(nowDay.getTime(), pk.getId());
      invoice.setPaymentDate(paymentDate);
    }
   
    recalculateInvoice(invoice);
    hrInvoiceNumberService.updateHRInvoiceNumber(invoice);
   
View Full Code Here

  @Override
  public Invoice getInvoice(Long id) throws ServiceException {
    logger.debug("getInvoice(id=[{}]) - start", + id);

    Invoice invoice = em.find(Invoice.class, id);
    recalculateInvoice(invoice);
    hrInvoiceNumberService.updateHRInvoiceNumber(invoice);

    logger.debug("getInvoice(Long) - end - return value=[{}]", invoice);
    return invoice;
View Full Code Here

  }

  public Invoice prepareNewInvoice() throws ServiceException {
    logger.debug("prepareNewInvoice() - start");
   
    Invoice invoice = null;
    if (this.invoiceTemplate != null) {
      try {
        invoice = invoiceTemplate.clone();
      } catch (CloneNotSupportedException e) {
        logger.warn("prepareNewInvoice()", e);
      }
    }
   
    if (invoice == null) {
      invoice = new Invoice();
    }
   
    invoice.setInvoicePositions(new ArrayList<InvoicePosition>());
    invoice.setInvoicePurchasers(new ArrayList<InvoicePurchaser>());
   
    Calendar nowDay = Calendar.getInstance();
    nowDay.set(Calendar.HOUR, 0);
    nowDay.set(Calendar.MINUTE, 0);
    nowDay.set(Calendar.SECOND, 0);
    nowDay.set(Calendar.MILLISECOND, 0);
   
    Long curYear = new Long(nowDay.get(Calendar.YEAR));
    invoice.setYear(curYear.toString());
   
    int maxInvoiceNumber = this.getMaxInvoiceNumber(curYear.toString());
    maxInvoiceNumber++;
   
    Long number = new Long(maxInvoiceNumber);
    invoice.setNumber(number);
    invoice.setDocumentDate(nowDay.getTime());
    invoice.setSoldDate(nowDay.getTime());
   
    PaymentKind pk = null;
    if (invoice.getPaymentKindId() != null) {
      pk = paymentKindsService.getPaymentKind(invoice.getPaymentKindId());
    }
   
    Date paymentDate = null;
    if (pk != null) {
      invoice.setPaymentKind(pk);
      paymentDate = paymentKindsService.calculatePaymentDate(nowDay.getTime(), pk.getId());
      invoice.setPaymentDate(paymentDate);
    }
   
    recalculateInvoice(invoice);
    hrInvoiceNumberService.updateHRInvoiceNumber(invoice);
   
View Full Code Here

        .where(critBuilder.equal(root.get(Invoice_.year), year))
        .orderBy(critBuilder.desc(root.get(Invoice_.number)));
   
    TypedQuery<Invoice> query = em.createQuery(critQuery).setMaxResults(1);
   
    Invoice invoice = null;
    try {
      invoice = query.getSingleResult();
    } catch (NoResultException ex) {
      logger.info("getMaxInvoiceNumber() - no result found - no invoices in this year?");
    }
   
    int maxNumber = 0;
    if (invoice != null) {
      maxNumber = invoice.getNumber().intValue();
    }
   
    logger.debug("getMaxInvoiceNumber() - end - return value=[{}]", maxNumber);
    return maxNumber;
  }
View Full Code Here

  }
 
  public void prepareBackToList() throws ServiceException {
    logger.debug("prepareBackToList() - start");

    this.model = new Invoice();

    logger.debug("prepareBackToList() - end");
  }
View Full Code Here

TOP

Related Classes of org.bigk.invoices.model.Invoice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.