Exemplo n.º 1
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();
  }