public static void useInvNumber(String invNumber) {
    Merchant merchant = MallUtil.getCurrentMerchant();
    String dir = merchant.getAbsolutePath() + "/invoiceCodes" + "/" + invNumber;
    try {
      Value val = (Value) SpringUtil.getRepositoryService().getFile(dir, Util.getRemoteUser());
      val.setStatus(40);
      val.save();
    } catch (FileNotFoundException fne) {

    }
  }
 public static String checkInvNumber(String invNumber) {
   Merchant merchant = MallUtil.getCurrentMerchant();
   String dir = merchant.getAbsolutePath() + "/invoiceCodes" + "/" + invNumber;
   try {
     Value val = (Value) SpringUtil.getRepositoryService().getFile(dir, Util.getRemoteUser());
     if (val.getStatus() == 40) {
       return "used";
     } else if (val.getStatus() == File.STATE_PUBLISHED) {
       return "ok";
     } else {
       return "notprinted";
     }
   } catch (FileNotFoundException fne) {
     Order order = getOrder(invNumber);
     if (order != null) {
       return "used";
     } else {
       return "ok";
     }
   }
 }
  public static Map<String, String> getParams(Order order) {
    User customer = SpringUtil.getSecurityService().loadUserByUsername(order.getOrderedBy());
    BillingInformation bi = order.getBillingInformation();
    SalesOrderEntry entry = order.getFiles(SalesOrderEntry.class).get(0);
    Map<String, String> res = new HashMap<String, String>();
    res.put("cname", customer.toString());
    res.put("caddress", bi.getAddressLine1() + " " + bi.getAddressLine2());
    res.put("cphone", bi.getPhone() + "/" + bi.getMobile());
    res.put("email", bi.getEmail());
    res.put("fsNumber", order.getCode());
    res.put("date", new SimpleDateFormat("dd/MMM/yyyy").format(order.getDateOfTransaction()));
    Calendar cal = Calendar.getInstance();
    cal.setTime(order.getDateOfTransaction());
    cal.add(Calendar.MONTH, 6);
    Date effDate = cal.getTime();
    res.put("effDate", new SimpleDateFormat("dd/MMM/yyyy").format(effDate));

    res.put("salesman", order.getOwner());
    res.put("plan", entry.getTitle());
    res.put("jFee", StringUtil.toCurrency("MUR", order.getJoiningFee()));
    res.put("inst", StringUtil.toCurrency("MUR", order.getInstallment()));
    res.put("total", StringUtil.toCurrency("MUR", order.getTotal()));
    res.put("paymentMode", order.getPaymentMethod());

    cal.add(Calendar.MONTH, -5);
    res.put("firstInstallment", new SimpleDateFormat("dd/MMM/yyyy").format(cal.getTime()));

    Value val = bi.getFile("applicationForm", Value.class);
    String[] as =
        StringUtils.splitByWholeSeparator(
            val.getString(), "-:;:-"); // StringUtil.split(val.getString(), "-:;:-");
    Map<String, String> f = new HashMap<String, String>();
    for (String s : as) {

      String[] kv = StringUtil.split(s, ":");
      if (kv.length > 1 && !kv[1].equalsIgnoreCase("null")) {
        f.put(kv[0], kv[1]);
      } else {
        if (kv.length > 0) {
          f.put(kv[0], "");
        }
      }
    }

    for (int i = 1; i <= 6; i++) {
      if (f.containsKey("c" + i + "surname")) {
        res.put("member" + (i + 1), f.get("c" + i + "surname") + " " + f.get("c" + i + "name"));
        StringBuilder dob = new StringBuilder();
        for (int c = 1; c <= 11; c++) {
          String key = "c" + i + c;
          dob.append(f.get(key));
        }
        res.put("dob" + (i + 1), dob.toString());
        res.put("sn" + (i + 1), i + "");

      } else {
        res.put("member" + (i + 1), "");
        res.put("dob" + (i + 1), "");
        res.put("sn" + (i + 1), "");
      }
    }
    res.put("dob", f.get("pdob"));

    if (res.containsKey("pidnumber")) {
      res.put("dob", res.get("pidnumber") + " " + f.get("pdob"));
    }
    res.put("cname", f.get("cfullName") + " " + f.get("cSurname"));
    res.put("address", f.get("presi") + " " + f.get("presi2"));
    res.put("phone", f.get("ptelhome") + "/" + f.get("pcell"));
    res.put("email", f.get("email"));
    res.put("name", f.get("pfullName") + " " + f.get("pSurname"));
    if (f.containsKey("sSurname") || f.containsKey("sfullName")) {
      res.put("sname", f.get("sfullName") + " " + f.get("sSurname"));
    } else {
      res.put("sname", f.get(""));
    }

    if (f.containsKey("sdob")) {
      res.put("sdob", f.get("sdob"));
    } else {
      res.put("sdob", "");
    }
    if (f.containsKey("sidnumber")) {
      String dob = res.get("sdob");
      res.put("sdob", f.get("sidnumber").toString() + " " + dob);
    }

    return res;
  }