Exemplo n.º 1
0
 public float getPaidAmount(int invoiceId) {
   String hql =
       " select sum(apply_amount) from accounting.ar_transaction_allocation a where a.invoice_id ="
           + invoiceId;
   List list = this.getSession().createSQLQuery(hql).list();
   return Tools.String2Float(list.get(0).toString());
 }
Exemplo n.º 2
0
 /**
  * 将状态自动更改为overdue
  *
  * @return
  * @throws SQLException
  * @throws SQLException
  */
 public int overDue(Connection conn) throws SQLException {
   int r = 0;
   String sql =
       "update accounting.ar_invoices set accounting.ar_invoices.status = '"
           + Constant.STATUS_OVERDUE
           + "' where accounting.ar_invoices.status in ('"
           + Constant.STATUS_NEW
           + "', '"
           + Constant.STATUS_INPROCESS
           + "' ) and accounting.ar_invoices.expr_date < '"
           + Tools.getCurrentTime("yyyy-MM-dd")
           + "'";
   PreparedStatement ps = null;
   try {
     ps = conn.prepareStatement(sql);
     System.out.println(sql);
     r = ps.executeUpdate();
     ps.close();
     conn.commit();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     if (ps != null) {
       ps.close();
       ps = null;
     }
   }
   return r;
 }
Exemplo n.º 3
0
  /**
   * 查询过期发票,关联customer、order、invoice表
   *
   * @return
   */
  public Page<ArInvoice> queryOverDueInvoice(Page<ArInvoice> page) {
    Page<ArInvoice> result = page;
    Long total = 0l;
    List list =
        this.getSession()
            .createQuery(
                "select count(a) from ArInvoice a where a.status in ('New','In Progress','Overdue') and a.exprDate <= ? ")
            .setDate(0, new java.util.Date())
            .list();
    if (list != null && list.size() > 0) {
      total = Long.parseLong(list.get(0).toString());
    }
    // String hql = "from ArInvoice a where a.status in ('New','In Progress','Overdue') and
    // a.exprDate <= ? "; //a.invoice_id,a.invoice_no,a.order_no,a.comment,a.expr_date
    String sql =
        "select a.invoice_id,a.invoice_no,a.order_no,a.comment,a.expr_date,b.order_date,c.bus_email,c.cust_no from accounting.ar_invoices a,order.order b,customer.customer_addresses c "
            + " where a.order_no = b.order_no and c.cust_no = b.cust_no and c.addr_type = 'CONTACT' and a.status in ('New','In Progress','Overdue') and a.expr_date <= '"
            + Tools.getCurrentTime("yyyy-MM-dd")
            + "'  order by invoice_id desc";
    System.out.println(sql);
    List list1 =
        this.getSession()
            .createSQLQuery(sql)
            .setFirstResult((page.getPageNo() - 1) * page.getPageSize())
            .setMaxResults(page.getPageSize())
            .list();

    List<ArInvoice> list2 = new ArrayList<ArInvoice>();
    ArInvoice ar = null;
    for (int i = 0; i < list1.size(); i++) {
      ar = new ArInvoice();
      Object[] obj = (Object[]) list1.get(i);
      ar.setInvoiceId((Integer) obj[0]);
      ar.setInvoiceNo(obj[1] == null ? "" : obj[1].toString());
      ar.setOrderNo((Integer) obj[2]);
      ar.setComment(obj[3].toString());
      ar.setExprDate((Date) obj[4]);
      ar.setOrderDate((Date) obj[5]);
      ar.setBusEmail(obj[6].toString());
      ar.setCustNo(Tools.String2Integer((obj[7].toString())));
      list2.add(ar);
    }

    page.setTotalCount(total);
    page.setResult(list2);
    return result;
  }
Exemplo n.º 4
0
 /**
  * 浏览历史付款
  *
  * @return
  */
 public String viewAllocationHistory() {
   int id = Tools.String2Integer(Struts2Util.getParameter("invoiceId"));
   if (id != 0) {
     String hql = "from ApTransactionAllocation a where a.invoiceId= ? ";
     apInvoiceAllocationList =
         (List<ApTransactionAllocation>) this.apInvoiceAllocationDao.createQuery(hql, id).list();
   }
   return "view_allocation_history";
 }
Exemplo n.º 5
0
  public Map getItemNum(int orderNo, int itemNo) {
    Map result = new HashMap();
    String sql =
        "  select sum(qty) as qty ,sum(size) as size ,count(qty) as num from accounting.ar_invoice_lines a "
            + " inner  join   accounting.ar_invoices b on a.invoice_id=b.invoice_id"
            + " where  "
            + " a.order_no="
            + orderNo
            + " and "
            + " a.item_no="
            + itemNo
            + " and "
            + " b.status in ('"
            + Constant.STATUS_INPROCESS
            + "','"
            + Constant.STATUS_CLOSED
            + "','"
            + Constant.STATUS_COMPLETED
            + "')"
            + "  group by a.item_no";
    try {
      List list = this.getSession().createSQLQuery(sql).list();

      result.put("qty", 0);
      result.put("size", 0.0f);

      if (list.size() > 0) {
        Object[] obj = (Object[]) list.get(0);
        int qty = Tools.String2Integer(obj[0].toString());
        float size = Tools.String2Float(obj[1].toString());
        int num = Tools.String2Integer(obj[2].toString());
        if (num == qty) qty = 1;
        result.put("qty", qty);
        result.put("size", size);
      }
    } catch (Exception e) {
      e.printStackTrace();
      result.put("qty", Tools.String2Integer("0"));
      result.put("size", Tools.String2Float("0"));
    }

    return result;
  }
Exemplo n.º 6
0
  /**
   * @function 根据唯一的发票编号查询Invoice实体
   * @param invoiceNo
   * @return true 表示存在该发票号,false表示不存在
   */
  public ArInvoice getInvoiceById(String invoiceId) {

    String hql = "from ArInvoice a where a.invoiceId = ?";
    List list = this.find(hql, Tools.String2Integer(invoiceId));
    if (list == null || list.size() == 0) {
      return new ArInvoice();
    }
    ArInvoice arInvoice = (ArInvoice) list.get(0);
    return arInvoice;
  }
Exemplo n.º 7
0
  /** @return */
  public String afteredit_invoiceline() {

    ActionContext ctx = ActionContext.getContext();
    String dispatch = Struts2Util.getRequest().getParameter("dispatch").trim();
    if (null != ctx.getSession().get("apInvoice")) {
      apInvoice = (ApInvoice) ctx.getSession().get("apInvoice");
      param = (Map) ctx.getSession().get("param");
      //						ctx.getSession().remove("apInvoice");
    }
    String LineNo = "" + apInvoiceLine.getLineNo();

    String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
    String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo");
    String[] names = param.get("name") == null ? null : (String[]) param.get("name");
    String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
    String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom");
    String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice");
    String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount");
    String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax");
    String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
    String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo");
    String[] creationDate =
        param.get("creationDate") == null ? null : (String[]) param.get("creationDate");
    String[] creationBy = param.get("createdBy") == null ? null : (String[]) param.get("createdBy");
    //			        String[] modify_dates = param.get("modifyDate")== null ? null :
    // (String[])param.get("modifyDate");
    //					String[] modified_by = param.get("modifiedBy")== null ? null :
    // (String[])param.get("modifiedBy");
    //			        ctx.getSession().remove("param");
    int i = 0;
    for (i = 0; i < lineNo.length; i++) {
      if (LineNo.equals(lineNo[i])) {
        break;
      }
    }
    amounts[i] = "" + apInvoiceLine.getAmount();
    catalogNo[i] = apInvoiceLine.getCatalogNo();
    itemNos[i] = "" + apInvoiceLine.getItemNo();
    names[i] = apInvoiceLine.getName();
    qtys[i] = "" + apInvoiceLine.getQty();
    qtyUoms[i] = "" + apInvoiceLine.getQtyUom();
    unitPrices[i] = "" + apInvoiceLine.getUnitPrice();
    taxs[i] = "" + apInvoiceLine.getTax();
    sizes[i] = "" + apInvoiceLine.getSize();
    lineNo[i] = "" + apInvoiceLine.getLineNo();
    creationDate[i] = Tools.getCurrentTime("yyyy-MM-dd");
    creationBy[i] = "" + SessionUtil.getUserId();

    //			        modify_dates[i]=Tools.getCurrentTime("yyyy-MM-dd");
    //			        modified_by[i]=""+SessionUtil.getUserId();

    Struts2Util.getRequest().setAttribute("paramEL", param);
    return dispatch;
  }
Exemplo n.º 8
0
  /** 退票 */
  public void changeOderItem(ApInvoice apInvoice) {
    if (0 == param.size()) return;

    String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
    String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
    String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
    if (null != itemNos) {
      for (int i = 0; i < itemNos.length; i++) {
        int itemNo = 0;
        int quantity = 0;
        double size = 0;

        itemNo = Tools.String2Integer(itemNos[i]);
        quantity = Tools.String2Integer(qtys[i]);
        size = Tools.String2Float(sizes[i]);

        this.apInvoiceService.checkOderItem(
            apInvoice.getInvoiceId(), apInvoice.getOrderNo(), itemNo, quantity, size, true);
      } // for 循环结束
    }
    /** 对invoice line 进行check 结束 */
  }
Exemplo n.º 9
0
 /** 分页查询 */
 public String list() throws Exception {
   PagerUtil<ApInvoiceView> pagerUtil = new PagerUtil<ApInvoiceView>();
   apInvoicePage = pagerUtil.getRequestPage();
   apInvoicePage.setPageSize(10);
   Map m = Tools.buildMap(Struts2Util.getRequest());
   List<ApInvoiceView> invoiceList = null;
   long total = 0;
   try {
     invoiceList = apInvoiceDao.list(apInvoicePage, m);
     total = this.apInvoiceDao.getTotalPage(m);
   } catch (Exception e) {
     e.printStackTrace();
   }
   apInvoicePage.setTotalCount(total);
   apInvoicePage.setResult(invoiceList);
   Struts2Util.getRequest().setAttribute("pagerInfo", apInvoicePage);
   Struts2Util.getRequest().setAttribute("params", m);
   return "success";
 }
Exemplo n.º 10
0
  /**
   * @function 修改
   * @author 陈文擎 @
   */
  public String edit_invoiceline() {
    ActionContext ctx = ActionContext.getContext();
    String symbol = currency_Dao.getCurrencySymbol(apInvoice.getCurrency());
    apInvoice.setSymbol(symbol);
    ctx.getSession().put("apInvoice", apInvoice);
    ctx.getSession().put("param", param);

    Struts2Util.getRequest().setAttribute("paramEL", param);

    String LineNo = Struts2Util.getRequest().getParameter("LineNo").trim();
    if (0 == param.size()) return "edit_invoiceline";

    String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
    String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo");
    String[] names = param.get("name") == null ? null : (String[]) param.get("name");
    String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
    String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom");
    String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice");
    String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount");
    String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax");
    String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
    String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo");

    int i = 0;
    for (i = 0; i < lineNo.length; i++) {
      if (LineNo.equals(lineNo[i])) {
        break;
      }
    }
    apInvoiceLine.setAmount(Tools.String2Float(amounts[i]));
    apInvoiceLine.setCatalogNo(catalogNo[i]);
    apInvoiceLine.setItemNo(Tools.String2Integer(itemNos[i]));
    apInvoiceLine.setName(names[i]);
    apInvoiceLine.setQty(Tools.String2Integer(qtys[i]));
    apInvoiceLine.setQtyUom(qtyUoms[i]);
    apInvoiceLine.setUnitPrice(Tools.String2Float(unitPrices[i]));
    apInvoiceLine.setTax(Tools.String2Float(taxs[i]));
    apInvoiceLine.setSize(Tools.String2Float(sizes[i]));
    apInvoiceLine.setLineNo(Tools.String2Integer(lineNo[i]));
    return "edit_invoiceline";
  }
Exemplo n.º 11
0
 public long getTotalPage(Map m) {
   long total = 0;
   String sql = "select count(*) from accounting.v_ar_invoice_list a where 1= 1 ";
   if (m != null) {
     if (m.get("filter_LIKES_invoiceNo") != null
         && Tools.String2Integer(m.get("filter_LIKES_invoiceNo").toString()) != 0) {
       sql += " and a.invoice_id =" + m.get("filter_LIKES_invoiceNo");
     }
     if (m.get("filter_LIKES_invoiceId") != null
         && Tools.String2Integer(m.get("filter_LIKES_invoiceId").toString()) != 0) {
       sql +=
           " and a.invoice_id ="
               + Tools.String2Integer(m.get("filter_LIKES_invoiceId").toString());
     }
     if (m.get("filter_EQI_orderNo") != null
         && Tools.String2Integer(m.get("filter_EQI_orderNo").toString()) != 0) {
       sql += " and a.order_no =" + m.get("filter_EQI_orderNo");
     }
     if (m.get("filter_EQI_custNo") != null
         && Tools.String2Integer(m.get("filter_EQI_custNo").toString()) != 0) {
       sql += " and a.cust_no =" + m.get("filter_EQI_custNo");
     }
     if (m.get("filter_EQI_shipmentId") != null
         && Tools.String2Integer(m.get("filter_EQI_shipmentId").toString()) != 0) {
       sql += " and a.shipment_id = " + m.get("filter_EQI_shipmentId");
     }
     if (m.get("filter_EQS_status") != null && !m.get("filter_EQS_status").equals("")) {
       sql += " and a.status='" + m.get("filter_EQS_status") + "'";
     }
     if (m.get("filter_EQS_currency") != null && !m.get("filter_EQS_currency").equals("")) {
       sql += " and a.currency='" + m.get("filter_EQS_currency") + "'";
     }
     if (m.get("filter_GTD_invoiceDate") != null && !m.get("filter_GTD_invoiceDate").equals("")) {
       sql += " and a.invoice_date>='" + m.get("filter_GTD_invoiceDate") + "'";
     }
     if (m.get("filter_LTD_invoiceDate") != null && !m.get("filter_LTD_invoiceDate").equals("")) {
       sql += " and a.invoice_date<='" + m.get("filter_LTD_invoiceDate") + "'";
     }
   } else {
     //			sql += " and a.status !='"+Constant.STATUS_OVERDUE+"'";
   }
   List list = this.getSession().createSQLQuery(sql).list();
   total = Long.parseLong(list.get(0).toString());
   return total;
 }
Exemplo n.º 12
0
 /**
  * 根据查询条件查询发票结果,从视图中查询
  *
  * @param m
  * @return
  * @throws SQLException
  */
 public List<ArInvoiceView> list(Page<ArInvoiceView> page, Map m) throws SQLException {
   List<ArInvoiceView> list = new ArrayList<ArInvoiceView>();
   Connection conn = this.getSession().connection();
   String sql = "select * from accounting.v_ar_invoice_list a where 1= 1 ";
   if (m != null) {
     if (m.get("filter_LIKES_invoiceNo") != null
         && Tools.String2Integer(m.get("filter_LIKES_invoiceNo").toString()) != 0) {
       sql += " and a.invoice_id =" + m.get("filter_LIKES_invoiceNo");
     }
     if (m.get("filter_LIKES_invoiceId") != null
         && Tools.String2Integer(m.get("filter_LIKES_invoiceId").toString()) != 0) {
       sql +=
           " and a.invoice_id ="
               + Tools.String2Integer(m.get("filter_LIKES_invoiceId").toString());
     }
     if (m.get("filter_EQI_orderNo") != null
         && Tools.String2Integer(m.get("filter_EQI_orderNo").toString()) != 0) {
       sql += " and a.order_no =" + m.get("filter_EQI_orderNo");
     }
     if (m.get("filter_EQI_custNo") != null
         && Tools.String2Integer(m.get("filter_EQI_custNo").toString()) != 0) {
       sql += " and a.cust_no =" + m.get("filter_EQI_custNo");
     }
     if (m.get("filter_EQI_shipmentId") != null
         && Tools.String2Integer(m.get("filter_EQI_shipmentId").toString()) != 0) {
       sql += " and a.shipment_id = " + m.get("filter_EQI_shipmentId");
     }
     if (m.get("filter_EQS_status") != null && !m.get("filter_EQS_status").equals("")) {
       sql += " and a.status='" + m.get("filter_EQS_status") + "'";
     }
     if (m.get("filter_EQS_currency") != null && !m.get("filter_EQS_currency").equals("")) {
       sql += " and a.currency='" + m.get("filter_EQS_currency") + "'";
     }
     if (m.get("filter_GTD_invoiceDate") != null && !m.get("filter_GTD_invoiceDate").equals("")) {
       sql += " and a.invoice_date>='" + m.get("filter_GTD_invoiceDate") + "'";
     }
     if (m.get("filter_LTD_invoiceDate") != null && !m.get("filter_LTD_invoiceDate").equals("")) {
       sql += " and a.invoice_date<='" + m.get("filter_LTD_invoiceDate") + "'";
     }
   } else {
     //			sql += " and a.status !='"+Constant.STATUS_OVERDUE+"'";
   }
   sql += " order by a.invoice_id desc ";
   long start = (page.getPageNo() - 1) * page.getPageSize();
   sql += " limit " + start + ", " + page.getPageSize();
   PreparedStatement ps = conn.prepareStatement(sql);
   ResultSet rs = ps.executeQuery();
   ArInvoiceView a = null;
   while (rs.next()) {
     a = new ArInvoiceView();
     a.setInvoiceId(rs.getInt("invoice_id"));
     a.setInvoiceNo(rs.getString("invoice_no"));
     a.setStatus(rs.getString("status"));
     a.setPaidAmt(rs.getFloat("paid_amt"));
     a.setBalance(rs.getFloat("balance"));
     a.setOrderNo(rs.getInt("order_no"));
     a.setShipmentId(rs.getInt("shipment_id"));
     a.setCustNo(rs.getInt("cust_no"));
     a.setInvoiceType(rs.getString("invoice_type"));
     a.setInvoiceDate(new java.util.Date(rs.getTimestamp("invoice_date").getTime()));
     a.setTotalAmount(rs.getFloat("total_amount"));
     a.setCurrency(rs.getString("currency"));
     a.setSymbol(rs.getString("symbol"));
     a.setPrecision(rs.getInt("precision"));
     list.add(a);
   }
   rs.close();
   ps.close();
   conn.close();
   return list;
 }
Exemplo n.º 13
0
  /** 保存修改invoiceLine后的发票 */
  public String saveEdit() {
    ActionContext ctx = ActionContext.getContext();
    try {

      ApInvoice oldApInvoice = apInvoiceDao.getById(apInvoice.getInvoiceId());
      apInvoice.setModifiedBy(SessionUtil.getUserId());
      apInvoice.setModifyDate(new Date());
      // 如果原来状态既非  new  也非  inprocess 则不能 修改内容,只能修改状态
      if ((!Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus()))
          && (!Constant.STATUS_NEW.equals(oldApInvoice.getStatus()))) {
        String status = oldApInvoice.getStatus(); // 以手动更改为Invalid 手动改为Void	

        if (Constant.STATUS_VOID.equals(status) || Constant.STATUS_INVALID.equals(status)) {
          oldApInvoice.setStatus(apInvoice.getStatus());
          status = apInvoice.getStatus();
          if (Constant.STATUS_INPROCESS.equals(status) || Constant.STATUS_NEW.equals(status)) {
            apInvoiceDao.getSession().clear();
            apInvoiceService.edit(oldApInvoice);
          }
        }

        ctx.getSession().remove("apInvoice");
        ctx.getSession().remove("param");
        return input();
      }
      //

      boolean flag = this.apInvoiceDao.isAllocation(apInvoice.getInvoiceId()); // 没对过账,对过账的不能修改
      boolean changeStatus = false;

      String status = apInvoice.getStatus(); // 手动更改为Invalid 手动改为Void		
      if (Constant.STATUS_VOID.equals(status)
          || Constant.STATUS_INVALID.equals(status) && (!flag)) {
        oldApInvoice.setStatus(status);
        changeStatus = true;

        if (Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus())) {
          this.changeOderItem(oldApInvoice);
          apInvoiceDao.getSession().clear();
          apInvoiceService.edit(oldApInvoice);
          ctx.getSession().remove("apInvoice");
          ctx.getSession().remove("param");
          return input();
        }
      }

      if ((!oldApInvoice.getCurrency().equals(apInvoice.getCurrency()))
          && (!flag)
          && (!changeStatus)) // 没对过账 Currency更改 没手动更改为Invalid 、Void
      {
        if (Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus())) // 原本就是inprocess
        {
          apInvoiceService.copyNewInvoice(apInvoice);
          apInvoice.setCurrency(oldApInvoice.getCurrency());
          apInvoice.setStatus(Constant.STATUS_VOID);
          apInvoiceDao.getSession().clear();
          apInvoiceService.edit(apInvoice);
          ctx.getSession().remove("apInvoice");
          ctx.getSession().remove("param");
          return input();
        }
        // 原来状态是new的不需要
      }

      apInvoiceDao.getSession().clear();
      apInvoiceService.edit(apInvoice);

      if (!Constant.STATUS_NEW.equals(oldApInvoice.getStatus())) {
        ctx.getSession().remove("apInvoice");
        ctx.getSession().remove("param");
        return input();
      }

      int InvoiceId = apInvoice.getInvoiceId();
      if (0 != param.size()) {
        String[] invoiceLineIds =
            param.get("invoiceLineIds") == null ? null : (String[]) param.get("invoiceLineIds");
        String[] invoiceIds =
            param.get("invoiceIds") == null ? null : (String[]) param.get("invoiceIds");
        String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
        String[] catalogNo =
            param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo");
        String[] names = param.get("name") == null ? null : (String[]) param.get("name");
        String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
        String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom");
        String[] unitPrices =
            param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice");
        String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount");
        String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax");
        String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
        String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo");
        String[] discounts =
            param.get("discount") == null ? null : (String[]) param.get("discount");
        String[] creation_dates =
            param.get("creationDate") == null ? null : (String[]) param.get("creationDate");
        String[] created_by =
            param.get("createdBy") == null ? null : (String[]) param.get("createdBy");
        String[] modify_dates =
            param.get("modifyDate") == null ? null : (String[]) param.get("modifyDate");
        String[] modified_by =
            param.get("modifiedBy") == null ? null : (String[]) param.get("modifiedBy");

        /** 对从invoice 状态从new 变为 inprocess的 invoice line的审核 对invoice line 进行check 开始 */
        if (Constant.STATUS_INPROCESS.equals(apInvoice.getStatus()) && (null != itemNos)) {
          for (int i = 0; i < itemNos.length; i++) {
            int itemNo = 0;
            int quantity = 0;
            double size = 0;

            itemNo = Tools.String2Integer(itemNos[i]);
            quantity = Tools.String2Integer(qtys[i]);
            size = Tools.String2Float(sizes[i]);
            //
            //		   						OrderItemOverSizeDTO = this.apInvoiceService.checkOderItem(
            // apInvoice.getInvoiceId(),
            //		   					           apInvoice.getOrderNo(),itemNo,quantity, size,false );
            //
            //		   						if(null!=OrderItemOverSizeDTO)
            //		   						{
            //		   							apInvoiceService.edit(oldApInvoice);// 将 主表的数据 退回 原值
            //		   							return "edit_invoice";
            //		   						}
          } // for 循环结束
        }
        /** 对invoice line 进行check 结束 */

        ////////////// 在状态为New时。InvoiceLine 执行删除////////////////
        //		  				if(Constant.STATUS_NEW.equals(apInvoice.getStatus()))
        //		  				{
        String InvoiceLineIds = "0";
        String invoiceId = "" + InvoiceId;
        for (int i = 0; i < invoiceLineIds.length; i++) {
          InvoiceLineIds = InvoiceLineIds + "," + invoiceLineIds[i];
        }
        try {
          apInvoiceLineDao.DeleteBatch(invoiceId, InvoiceLineIds);
        } catch (Exception e) {
          e.printStackTrace();
        }

        //		  				}

        ////////////////////////////////

        ApInvoiceLine insertLine = null;
        for (int i = 0; i < itemNos.length; i++) {
          insertLine =
              apInvoiceLineDao.queryInvoiceLine(Tools.String2Integer(invoiceLineIds[i]).intValue());

          if (null == insertLine) {
            insertLine = new ApInvoiceLine();
          } else {
            insertLine.setInvoiceLineId(Tools.String2Integer(invoiceLineIds[i]));
          }
          insertLine.setAmount(Tools.String2Float(amounts[i]));
          insertLine.setCatalogNo(catalogNo[i]);

          insertLine.setDiscount(Tools.String2Float(discounts[i]));
          ;
          insertLine.setInvoiceId(InvoiceId);
          insertLine.setItemNo(Tools.String2Integer(itemNos[i]));
          int linno = Tools.String2Integer(lineNo[i]);
          //		  					insertLine.setLineNo(linno);
          insertLine.setLineNo(i + 1);

          insertLine.setModifiedBy(SessionUtil.getUserId());
          insertLine.setModifyDate(new Date());

          insertLine.setCreatedBy(Tools.String2Integer(created_by[i]));
          insertLine.setCreationDate(Tools.getFormatDate(creation_dates[i]));

          insertLine.setName(names[i]);
          insertLine.setOrderNo(apInvoice.getOrderNo());
          insertLine.setQty(Tools.String2Integer(qtys[i]));
          insertLine.setQtyUom(qtyUoms[i]);
          insertLine.setSize(Tools.String2Float(sizes[i]));
          insertLine.setSizeUom("");
          insertLine.setTax(Tools.String2Float(taxs[i]));
          insertLine.setUnitPrice(Tools.String2Float(unitPrices[i]));
          insertLine.setStatus(apInvoice.getStatus());

          apInvoiceLineDao.save(insertLine);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    ctx.getSession().remove("apInvoice");
    ctx.getSession().remove("param");

    return input();
  }
Exemplo n.º 14
0
  /**
   * 新增一个发票点击save后,但是数据还没有保存到数据库
   *
   * @return
   */
  public String afteradd_invoiceline() {

    ActionContext ctx = ActionContext.getContext();
    String dispatch = Struts2Util.getRequest().getParameter("dispatch").trim();

    if (null != ctx.getSession().get("apInvoice")) {
      apInvoice = (ApInvoice) ctx.getSession().get("apInvoice");
      //		 			ctx.getSession().remove("apInvoice");
    }

    if (null != ctx.getSession().get("param")) {
      param = (Map) ctx.getSession().get("param");

      String[] invoiceLineIds =
          param.get("invoiceLineIds") == null ? null : (String[]) param.get("invoiceLineIds");
      String[] invoiceIds =
          param.get("invoiceIds") == null ? null : (String[]) param.get("invoiceIds");
      String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
      String[] catalogNo =
          param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo");
      String[] names = param.get("name") == null ? null : (String[]) param.get("name");
      String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
      String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom");
      String[] unitPrices =
          param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice");
      String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount");
      String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax");
      String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
      String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo");
      String[] discounts = param.get("discount") == null ? null : (String[]) param.get("discount");
      String[] creation_dates =
          param.get("creationDate") == null ? null : (String[]) param.get("creationDate");
      String[] created_by =
          param.get("createdBy") == null ? null : (String[]) param.get("createdBy");
      String[] modify_dates =
          param.get("modifyDate") == null ? null : (String[]) param.get("modifyDate");
      String[] modified_by =
          param.get("modifiedBy") == null ? null : (String[]) param.get("modifiedBy");

      //		 			ctx.getSession().remove("param");

      String[] invoiceLineIds1 = Tools.add(invoiceLineIds, "0");
      String[] invoiceIds1 = Tools.add(invoiceIds, "0");
      String itemNo1[] = Tools.add(itemNos, this.apInvoiceLine.getItemNo() + "");
      String catalogNo1[] = Tools.add(catalogNo, this.apInvoiceLine.getCatalogNo());
      String names1[] = Tools.add(names, this.apInvoiceLine.getName()); // name 未填
      String qtys1[] = Tools.add(qtys, this.apInvoiceLine.getQty() + "");
      String qtyUoms1[] = Tools.add(qtyUoms, this.apInvoiceLine.getQtyUom());
      String unitPrices1[] = Tools.add(unitPrices, this.apInvoiceLine.getUnitPrice() + "");
      String amounts1[] = Tools.add(amounts, this.apInvoiceLine.getAmount() + "");
      String taxs1[] = Tools.add(taxs, this.apInvoiceLine.getTax() + "");
      String[] sizes1 = Tools.add(sizes, this.apInvoiceLine.getSize() + "");
      String[] lineNo1 = Tools.add(lineNo, this.apInvoiceLine.getLineNo() + "");
      String[] discounts1 = Tools.add(discounts, this.apInvoiceLine.getDiscount() + "");
      String[] creation_dates1 = Tools.add(creation_dates, Tools.getCurrentTime("yyyy-MM-dd"));
      String[] created_by1 = Tools.add(created_by, SessionUtil.getUserId() + "");
      String[] modify_dates1 = Tools.add(modify_dates, Tools.getCurrentTime("yyyy-MM-dd") + "");
      String[] modified_by1 = Tools.add(modified_by, SessionUtil.getUserId() + "");

      param.put("invoiceLineIds", invoiceLineIds1);
      param.put("invoiceIds", invoiceIds1);
      param.put("itemNo", itemNo1);
      param.put("catalogNo", catalogNo1);
      param.put("name", names1);
      param.put("qty", qtys1);
      param.put("qtyUom", qtyUoms1);
      param.put("amount", amounts1);
      param.put("tax", taxs1);
      param.put("unitPrice", unitPrices1);
      param.put("size", sizes1);
      param.put("lineNo", lineNo1);
      param.put("discount", discounts1);
      param.put("creationDate", creation_dates1);
      param.put("createdBy", created_by1);
      param.put("modifyDate", modify_dates1);
      param.put("modifiedBy", modified_by1);

      //		 			ctx.getSession().put("param", param);
    } else {
      String[] invoiceLineIds = new String[1];
      invoiceLineIds[0] = "0";
      String[] invoiceIds = new String[1];
      invoiceIds[0] = "0";
      String itemNo[] = new String[1];
      itemNo[0] = this.apInvoiceLine.getItemNo() + "";
      String catalogNo[] = new String[1];
      catalogNo[0] = apInvoiceLine.getCatalogNo();
      String names[] = new String[1];
      names[0] = apInvoiceLine.getName(); // 还未给值
      String qtys[] = new String[1];
      qtys[0] = apInvoiceLine.getQty() + "";
      String qtyUoms[] = new String[1];
      qtyUoms[0] = apInvoiceLine.getQtyUom();
      String unitPrices[] = new String[1];
      unitPrices[0] = this.apInvoiceLine.getUnitPrice() + "";
      String amounts[] = new String[1];
      amounts[0] = this.apInvoiceLine.getAmount() + "";
      String taxs[] = new String[1];
      taxs[0] = this.apInvoiceLine.getTax() + "";
      String[] sizes = new String[1];
      sizes[0] = this.apInvoiceLine.getSize() + "";
      String[] lineNo = new String[1];
      lineNo[0] = this.apInvoiceLine.getLineNo() + "";
      String[] discount = new String[1];
      discount[0] = this.apInvoiceLine.getDiscount() + "";
      String[] creation_dates = Tools.add(null, Tools.getCurrentTime("yyyy-MM-dd") + "");
      String[] created_by = Tools.add(null, SessionUtil.getUserId() + "");
      String[] modify_dates = Tools.add(null, Tools.getCurrentTime("yyyy-MM-dd") + "");
      String[] modified_by = Tools.add(null, SessionUtil.getUserId() + "");

      param.put("invoiceLineIds", invoiceLineIds);
      param.put("invoiceIds", invoiceIds);
      param.put("itemNo", itemNo);
      param.put("catalogNo", catalogNo);
      param.put("name", names);
      param.put("qty", qtys);
      param.put("qtyUom", qtyUoms);
      param.put("amount", amounts);
      param.put("tax", taxs);
      param.put("unitPrice", unitPrices);
      param.put("size", sizes);
      param.put("lineNo", lineNo);
      param.put("discount", discount);
      param.put("creationDate", creation_dates);
      param.put("createdBy", created_by);
      param.put("modifyDate", modify_dates);
      param.put("modifiedBy", modified_by);
      //		 			ctx.getSession().put("param", param);
    }

    Struts2Util.getRequest().setAttribute("paramEL", param);
    return dispatch;
  }
Exemplo n.º 15
0
  /**
   * 修改invocie
   *
   * @return
   */
  public String edit() {
    int invoiceId = Tools.String2Integer(Struts2Util.getParameter("invoiceId"));
    List<ApInvoiceLine> apInvoiceLines = null;
    try {
      apInvoice = new ApInvoice();
      apInvoice = (ApInvoice) this.apInvoiceDao.getSession().get(ApInvoice.class, invoiceId);
      apInvoice.setOldStatus(apInvoice.getStatus());
      apInvoiceLines = apInvoiceLineDao.queryInvoiceByInvoiceId(apInvoice.getInvoiceId());
      String symbol = currency_Dao.getCurrencySymbol(apInvoice.getCurrency());
      apInvoice.setSymbol(symbol);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if ((null == apInvoiceLines) || (0 == apInvoiceLines.size())) {
      return "edit_invoice";
    }
    int length = apInvoiceLines.size();

    String[] itemNos = new String[length];
    String[] invoiceLineIds = new String[length];
    String[] invoiceIds = new String[length];
    String[] catalogNo = new String[length];
    String[] names = new String[length];
    String[] qtys = new String[length];
    String[] qtyUoms = new String[length];
    String[] unitPrices = new String[length];
    String[] amounts = new String[length];
    String[] taxs = new String[length];
    String[] sizes = new String[length];
    String[] lineNo = new String[length];
    String[] discounts = new String[length];
    String[] createDate = new String[length];
    String[] createBy = new String[length];
    String[] modifyDate = new String[length];
    String[] modifyBy = new String[length];
    ApInvoiceLine InvoiceLine = null;

    for (int i = 0; i < apInvoiceLines.size(); i++) {
      InvoiceLine = apInvoiceLines.get(i);
      invoiceLineIds[i] = "" + InvoiceLine.getInvoiceLineId();
      invoiceIds[i] = "" + InvoiceLine.getInvoiceId();
      amounts[i] = "" + InvoiceLine.getAmount();
      catalogNo[i] = InvoiceLine.getCatalogNo();
      itemNos[i] = "" + InvoiceLine.getItemNo();
      names[i] = InvoiceLine.getName();
      qtys[i] = "" + InvoiceLine.getQty();
      qtyUoms[i] = "" + InvoiceLine.getQtyUom();
      unitPrices[i] = "" + InvoiceLine.getUnitPrice();
      taxs[i] = "" + InvoiceLine.getTax();
      sizes[i] = "" + InvoiceLine.getSize();
      lineNo[i] = "" + InvoiceLine.getLineNo();
      discounts[i] = "" + InvoiceLine.getDiscount();
      createDate[i] = "" + InvoiceLine.getCreationDate();
      createBy[i] = "" + InvoiceLine.getCreatedBy();
      modifyDate[i] = "" + InvoiceLine.getModifyDate();
      modifyBy[i] = "" + InvoiceLine.getModifiedBy();
    }

    param.put("invoiceLineIds", invoiceLineIds);
    param.put("invoiceIds", invoiceIds);
    param.put("itemNo", itemNos);
    param.put("catalogNo", catalogNo);
    param.put("name", names);
    param.put("qty", qtys);
    param.put("qtyUom", qtyUoms);
    param.put("unitPrice", unitPrices);
    param.put("amount", amounts);
    param.put("tax", taxs);
    param.put("size", sizes);
    param.put("lineNo", lineNo);
    param.put("discount", discounts);
    param.put("creationDate", createDate);
    param.put("createdBy", createBy);
    param.put("modifyDate", modifyDate);
    param.put("modifiedBy", modifyBy);

    Struts2Util.getRequest().setAttribute("paramEL", param);
    return "edit_invoice";
  }
Exemplo n.º 16
0
  /**
   * 添加invoice,跳转到页面
   *
   * @return
   * @throws Exception
   */
  public String save() throws Exception {
    try {
      apInvoice.setCreatedBy(SessionUtil.getUserId());
      apInvoice.setCreationDate(new Date());
      apInvoice.setModifiedBy(SessionUtil.getUserId());
      apInvoice.setModifyDate(new Date());
      apInvoice.setPrintedFlag("N");
      int companyId = this.apInvoiceDao.getCompanyId(apInvoice.getOrderNo());
      apInvoice.setCompanyId(companyId); // 测试
      int InvoiceId = apInvoiceService.add(apInvoice);
      if (0 != param.size()) {
        String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo");
        String[] catalogNo =
            param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo");
        String[] names = param.get("name") == null ? null : (String[]) param.get("name");
        String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty");
        String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom");
        String[] unitPrices =
            param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice");
        String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount");
        String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax");
        String[] sizes = param.get("size") == null ? null : (String[]) param.get("size");
        String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo");
        String[] discounts =
            param.get("discount") == null ? null : (String[]) param.get("discount");
        ApInvoiceLine insertLine = null;
        for (int i = 0; i < itemNos.length; i++) {
          insertLine = new ApInvoiceLine();
          insertLine.setAmount(Tools.String2Float(amounts[i]));
          insertLine.setCatalogNo(catalogNo[i]);
          insertLine.setCreatedBy(SessionUtil.getUserId());
          insertLine.setCreationDate(new Date());
          insertLine.setDiscount(Tools.String2Float(discounts[i]));
          insertLine.setInvoiceId(InvoiceId);
          insertLine.setItemNo(Tools.String2Integer(itemNos[i]));
          int linno = Tools.String2Integer(lineNo[i]);
          //					insertLine.setLineNo(linno);
          insertLine.setLineNo(i + 1);
          insertLine.setModifiedBy(SessionUtil.getUserId());
          insertLine.setModifyDate(new Date());
          insertLine.setName(names[i]);
          insertLine.setOrderNo(apInvoice.getOrderNo());
          insertLine.setQty(Tools.String2Integer(qtys[i]));
          insertLine.setQtyUom(qtyUoms[i]);
          insertLine.setSize(Tools.String2Float(sizes[i]));
          insertLine.setSizeUom("");
          insertLine.setTax(Tools.String2Float(taxs[i]));
          insertLine.setUnitPrice(Tools.String2Float(unitPrices[i]));
          insertLine.setStatus(Constant.STATUS_NEW);
          apInvoiceLineDao.save(insertLine);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    ActionContext ctx = ActionContext.getContext();
    ctx.getSession().remove("apInvoice");
    ctx.getSession().remove("param");

    return input();
  }