예제 #1
0
 /**
  * Complete Invoice
  *
  * @param invoice invoice
  */
 private void completeInvoice(MInvoice invoice) {
   if (invoice == null) return;
   invoice.setDocAction(DocAction.ACTION_Prepare);
   invoice.processIt(DocAction.ACTION_Prepare);
   if (!invoice.save()) new IllegalStateException("Cannot save Invoice");
   //
   m_noInvoices++;
   addLog(
       invoice.get_ID(),
       invoice.getDateInvoiced(),
       invoice.getGrandTotal(),
       invoice.getDocumentNo());
 } //	completeInvoice
예제 #2
0
 /**
  * Create Shipment
  *
  * @return info
  * @throws Exception
  */
 protected String doIt() throws Exception {
   log.info("C_Invoice_ID=" + p_C_Invoice_ID + ", M_Warehouse_ID=" + p_M_Warehouse_ID);
   if (p_C_Invoice_ID <= 0) throw new FillMandatoryException("C_Invoice_ID");
   if (p_M_Warehouse_ID == 0) throw new FillMandatoryException(PARAM_M_Warehouse_ID);
   //
   MInvoice invoice = new MInvoice(getCtx(), p_C_Invoice_ID, null);
   if (invoice.get_ID() <= 0) throw new AdempiereException("@NotFound@ @C_Invoice_ID@");
   if (!MInvoice.DOCSTATUS_Completed.equals(invoice.getDocStatus()))
     throw new AdempiereException("@InvoiceCreateDocNotCompleted@");
   //
   for (MInvoiceLine invoiceLine : invoice.getLines(false)) {
     createLine(invoice, invoiceLine);
   }
   if (m_inout == null) throw new InvoiceFullyMatchedException();
   //
   return m_inout.getDocumentNo();
 } //	doIt
 /**
  * Perform process.
  *
  * @return Message (clear text)
  * @throws Exception if not successful
  */
 protected String doIt() throws Exception {
   log.info("C_InvoicePaySchedule_ID=" + getRecord_ID());
   MInvoicePaySchedule[] schedule =
       MInvoicePaySchedule.getInvoicePaySchedule(getCtx(), 0, getRecord_ID(), null);
   if (schedule.length == 0)
     throw new IllegalArgumentException("InvoicePayScheduleValidate - No Schedule");
   //	Get Invoice
   MInvoice invoice = new MInvoice(getCtx(), schedule[0].getC_Invoice_ID(), null);
   if (invoice.get_ID() == 0)
     throw new IllegalArgumentException("InvoicePayScheduleValidate - No Invoice");
   //
   BigDecimal total = Env.ZERO;
   for (int i = 0; i < schedule.length; i++) {
     BigDecimal due = schedule[i].getDueAmt();
     if (due != null) total = total.add(due);
   }
   boolean valid = invoice.getGrandTotal().compareTo(total) == 0;
   invoice.setIsPayScheduleValid(valid);
   invoice.save();
   //	Schedule
   for (int i = 0; i < schedule.length; i++) {
     if (schedule[i].isValid() != valid) {
       schedule[i].setIsValid(valid);
       schedule[i].save();
     }
   }
   String msg = "@OK@";
   if (!valid)
     msg =
         "@GrandTotal@ = "
             + invoice.getGrandTotal()
             + " <> @Total@ = "
             + total
             + "  - @Difference@ = "
             + invoice.getGrandTotal().subtract(total);
   return Msg.parseTranslation(getCtx(), msg);
 } //	doIt