|
|
@@ -110,6 +110,7 @@ public class tinvoicebill extends PaoCust {
|
|
|
// return;
|
|
|
// }
|
|
|
String finvoiceserialnum = getString("finvoiceserialnum");//发票流水号
|
|
|
+ String foldstatus = getString("status");//原状态
|
|
|
|
|
|
JSONObject contentObject = new JSONObject();
|
|
|
contentObject.put("isOfferInvoiceDetail", "1");
|
|
|
@@ -149,7 +150,7 @@ public class tinvoicebill extends PaoCust {
|
|
|
setValue("invoiceNo", invoiceNo, 11L);
|
|
|
}
|
|
|
createPrintStr(getString("invoiceCode"), getString("invoiceNo"), Double.parseDouble(resultObject.getString("orderAmount")));
|
|
|
- if ("红".equals(getString("frb"))) {
|
|
|
+ if ("红".equals(getString("frb")) && !foldstatus.equals("2")) {
|
|
|
//红票查询成功后,更新订单已开票数量
|
|
|
DBConnect dbConnect = new DBConnect();
|
|
|
Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
@@ -190,8 +191,48 @@ public class tinvoicebill extends PaoCust {
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
- } else if (status.equals("3") && "红".equals(getString("frb"))) {
|
|
|
+ } else if ("红".equals(getString("frb")) && status.equals("3") && foldstatus.equals("2")) {
|
|
|
//如果红字发票作废
|
|
|
+ //红票查询成功后,更新订单已开票数量
|
|
|
+ DBConnect dbConnect = new DBConnect();
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
+ "inner join tinvoicebillitem t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t1.tinvoicebillid=t2.tinvoicebillid\n" +
|
|
|
+ "inner join tinvoiceapplyorder t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoiceapplyordid=t3.tinvoiceapplyordid\n" +
|
|
|
+ "where t1.tinvoicebillid='" + getUniqueIDValue() + "' group by t3.saorderdetailid");
|
|
|
+ PaoSetRemote saorderdetailSet = getPaoSet("$saorderdetail", "saorderdetail", "siteid='" + getString("siteid") + "' and saorderdetailid in " + rows.getInWhere("saorderdetailid"));
|
|
|
+ int i = 0;
|
|
|
+ while (saorderdetailSet.getPao(i) != null) {
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (String.valueOf(saorderdetailSet.getPao(i).getUniqueIDValue()).equalsIgnoreCase(row.getString("saorderdetailid"))) {
|
|
|
+ double foldinvoiceamount = saorderdetailSet.getPao(i).getDouble("finvoiceamount");
|
|
|
+ saorderdetailSet.getPao(i).setValue("finvoiceamount", Math.add(foldinvoiceamount, -row.getDouble("taxincludedamount")), 11L);
|
|
|
+
|
|
|
+ double sainvoiceamount = -row.getDouble("taxincludedamount");
|
|
|
+ /**
|
|
|
+ * 更新发货单已开票金额
|
|
|
+ */
|
|
|
+ PaoSetRemote sainvoicedetailSet = saorderdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
+ sainvoicedetailSet.setOrderBy("sainvoicedetailid");
|
|
|
+ int n = 0;
|
|
|
+ while (sainvoicedetailSet.getPao(n) != null) {
|
|
|
+ if (sainvoicedetailSet.getPao(n).getPaoSet("SAINVOICE").getPao(0).getString("fstatus").equals("关闭")) {
|
|
|
+ double famount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("famount");//发货金额
|
|
|
+ double finvoiceamount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("finvoiceamount");//发货单已开票金额
|
|
|
+ if (famount_sainvoice > finvoiceamount_sainvoice) {
|
|
|
+ double fneedinvoiceamount_sainvoice = baseclass.tools.Math.sub(famount_sainvoice, finvoiceamount_sainvoice);//发货单应开票数
|
|
|
+ if (fneedinvoiceamount_sainvoice > sainvoiceamount) {
|
|
|
+ fneedinvoiceamount_sainvoice = sainvoiceamount;
|
|
|
+ }
|
|
|
+ sainvoicedetailSet.getPao(n).setValue("finvoiceamount", baseclass.tools.Math.add(finvoiceamount_sainvoice, fneedinvoiceamount_sainvoice), 11L);
|
|
|
+ sainvoiceamount = baseclass.tools.Math.sub(sainvoiceamount, fneedinvoiceamount_sainvoice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ n++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|