public boolean canInvoice(Timestamp xDate,BigDecimal orderAmt){
  if (isAmount() && getAmt() != null && orderAmt != null && orderAmt.compareTo(getAmt()) >= 0)   return true;
  if (INVOICEFREQUENCY_Daily.equals(getInvoiceFrequency()))   return true;
  xDate=TimeUtil.getDay(xDate);
  Calendar today=TimeUtil.getToday();
  if (INVOICEFREQUENCY_Weekly.equals(getInvoiceFrequency())) {
    Calendar cutoff=TimeUtil.getToday();
    cutoff.set(Calendar.DAY_OF_WEEK,getCalendarDay(getInvoiceWeekDayCutoff()));
    if (cutoff.after(today))     cutoff.add(Calendar.DAY_OF_YEAR,-7);
    Timestamp cutoffDate=new Timestamp(cutoff.getTimeInMillis());
    log.fine("canInvoice - Date=" + xDate + " > Cutoff="+ cutoffDate+ " - "+ xDate.after(cutoffDate));
    if (xDate.after(cutoffDate))     return false;
    Calendar invoice=TimeUtil.getToday();
    invoice.set(Calendar.DAY_OF_WEEK,getCalendarDay(getInvoiceWeekDay()));
    if (invoice.after(today))     invoice.add(Calendar.DAY_OF_YEAR,-7);
    Timestamp invoiceDate=new Timestamp(invoice.getTimeInMillis());
    log.fine("canInvoice - Date=" + xDate + " > Invoice="+ invoiceDate+ " - "+ xDate.after(invoiceDate));
    if (xDate.after(invoiceDate))     return false;
    return true;
  }
  if (INVOICEFREQUENCY_Monthly.equals(getInvoiceFrequency()) || INVOICEFREQUENCY_TwiceMonthly.equals(getInvoiceFrequency())) {
    if (getInvoiceDayCutoff() > 0) {
      Calendar cutoff=TimeUtil.getToday();
      cutoff.set(Calendar.DAY_OF_MONTH,getInvoiceDayCutoff());
      if (cutoff.after(today))       cutoff.add(Calendar.MONTH,-1);
      Timestamp cutoffDate=new Timestamp(cutoff.getTimeInMillis());
      log.fine("canInvoice - Date=" + xDate + " > Cutoff="+ cutoffDate+ " - "+ xDate.after(cutoffDate));
      if (xDate.after(cutoffDate))       return false;
    }
    Calendar invoice=TimeUtil.getToday();
    invoice.set(Calendar.DAY_OF_MONTH,getInvoiceDay());
    if (invoice.after(today))     invoice.add(Calendar.MONTH,-1);
    Timestamp invoiceDate=new Timestamp(invoice.getTimeInMillis());
    log.fine("canInvoice - Date=" + xDate + " > Invoice="+ invoiceDate+ " - "+ xDate.after(invoiceDate));
    if (xDate.after(invoiceDate))     return false;
    return true;
  }
  if (INVOICEFREQUENCY_TwiceMonthly.equals(getInvoiceFrequency())) {
    if (getInvoiceDayCutoff() > 0) {
      Calendar cutoff=TimeUtil.getToday();
      cutoff.set(Calendar.DAY_OF_MONTH,getInvoiceDayCutoff() + 15);
      if (cutoff.after(today))       cutoff.add(Calendar.MONTH,-1);
      Timestamp cutoffDate=new Timestamp(cutoff.getTimeInMillis());
      if (xDate.after(cutoffDate))       return false;
    }
    Calendar invoice=TimeUtil.getToday();
    invoice.set(Calendar.DAY_OF_MONTH,getInvoiceDay() + 15);
    if (invoice.after(today))     invoice.add(Calendar.MONTH,-1);
    Timestamp invoiceDate=new Timestamp(invoice.getTimeInMillis());
    if (xDate.after(invoiceDate))     return false;
    return true;
  }
  return false;
}

public boolean canInvoice ( Timestamp xDate , BigDecimal orderAmt ) { if ( isAmount ( ) && getAmt ( ) != null && orderAmt != null && orderAmt . compareTo ( getAmt ( ) ) >= 0 ) return true ; if ( INVOICEFREQUENCY_Daily . equals ( getInvoiceFrequency ( ) ) ) return true ; xDate = TimeUtil . getDay ( xDate ) ; Calendar today = TimeUtil . getToday ( ) ; if ( INVOICEFREQUENCY_Weekly . equals ( getInvoiceFrequency ( ) ) ) { Calendar cutoff = TimeUtil . getToday ( ) ; cutoff . set ( Calendar . DAY_OF_WEEK , getCalendarDay ( getInvoiceWeekDayCutoff ( ) ) ) ; if ( cutoff . after ( today ) ) cutoff . add ( Calendar . DAY_OF_YEAR , - 7 ) ; Timestamp cutoffDate = new Timestamp ( cutoff . getTimeInMillis ( ) ) ; log . fine ( "canInvoice - Date=" + xDate + " > Cutoff=" + cutoffDate + " - " + xDate . after ( cutoffDate ) ) ; if ( xDate . after ( cutoffDate ) ) return false ; Calendar invoice = TimeUtil . getToday ( ) ; invoice . set ( Calendar . DAY_OF_WEEK , getCalendarDay ( getInvoiceWeekDay ( ) ) ) ; if ( invoice . after ( today ) ) invoice . add ( Calendar . DAY_OF_YEAR , - 7 ) ; Timestamp invoiceDate = new Timestamp ( invoice . getTimeInMillis ( ) ) ; log . fine ( "canInvoice - Date=" + xDate + " > Invoice=" + invoiceDate + " - " + xDate . after ( invoiceDate ) ) ; if ( xDate . after ( invoiceDate ) ) return false ; return true ; } if ( INVOICEFREQUENCY_Monthly . equals ( getInvoiceFrequency ( ) ) || INVOICEFREQUENCY_TwiceMonthly . equals ( getInvoiceFrequency ( ) ) ) { if ( getInvoiceDayCutoff ( ) > 0 ) { Calendar cutoff = TimeUtil . getToday ( ) ; cutoff . set ( Calendar . DAY_OF_MONTH , getInvoiceDayCutoff ( ) ) ; if ( cutoff . after ( today ) ) cutoff . add ( Calendar . MONTH , - 1 ) ; Timestamp cutoffDate = new Timestamp ( cutoff . getTimeInMillis ( ) ) ; log . fine ( "canInvoice - Date=" + xDate + " > Cutoff=" + cutoffDate + " - " + xDate . after ( cutoffDate ) ) ; if ( xDate . after ( cutoffDate ) ) return false ; } Calendar invoice = TimeUtil . getToday ( ) ; invoice . set ( Calendar . DAY_OF_MONTH , getInvoiceDay ( ) ) ; if ( invoice . after ( today ) ) invoice . add ( Calendar . MONTH , - 1 ) ; Timestamp invoiceDate = new Timestamp ( invoice . getTimeInMillis ( ) ) ; log . fine ( "canInvoice - Date=" + xDate + " > Invoice=" + invoiceDate + " - " + xDate . after ( invoiceDate ) ) ; if ( xDate . after ( invoiceDate ) ) return false ; return true ; } if ( INVOICEFREQUENCY_TwiceMonthly . equals ( getInvoiceFrequency ( ) ) ) { if ( getInvoiceDayCutoff ( ) > 0 ) { Calendar cutoff = TimeUtil . getToday ( ) ; cutoff . set ( Calendar . DAY_OF_MONTH , getInvoiceDayCutoff ( ) + 15 ) ; if ( cutoff . after ( today ) ) cutoff . add ( Calendar . MONTH , - 1 ) ; Timestamp cutoffDate = new Timestamp ( cutoff . getTimeInMillis ( ) ) ; if ( xDate . after ( cutoffDate ) ) return false ; } Calendar invoice = TimeUtil . getToday ( ) ; invoice . set ( Calendar . DAY_OF_MONTH , getInvoiceDay ( ) + 15 ) ; if ( invoice . after ( today ) ) invoice . add ( Calendar . MONTH , - 1 ) ; Timestamp invoiceDate = new Timestamp ( invoice . getTimeInMillis ( ) ) ; if ( xDate . after ( invoiceDate ) ) return false ; return true ; } return false ; }
can i send invoice
