|
|
@@ -126,71 +126,94 @@ public class tinvoiceapply extends PaoCust {
|
|
|
setValue("submitdate", issubmit ? getDateTime() : null, 11L);
|
|
|
}
|
|
|
|
|
|
- public void checkvalidate() throws P2Exception {
|
|
|
+ public void checkvalidate(boolean ischeck) throws P2Exception {
|
|
|
PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
|
|
|
PaoSetRemote tinvoicebillSet = getPaoSet("tinvoicebill");
|
|
|
/****************** 单据检验 *********************/
|
|
|
-
|
|
|
- if (!"提交".equals(getString("fstatus"))) {
|
|
|
- throw new P2AppException("", "非提交状态下不可审核");
|
|
|
- }
|
|
|
- if (tinvoiceapplyorderSet.isEmpty()) {
|
|
|
- throw new P2AppException("", "订单信息为空不可审核");
|
|
|
- }
|
|
|
- if (tinvoicebillSet.isEmpty()) {
|
|
|
- throw new P2AppException("", "开票信息为空不可审核");
|
|
|
- }
|
|
|
- if (tinvoiceapplyorderSet.min("finvoiceamount") <= 0) {
|
|
|
- throw new P2AppException("", "订单行开票金额必须大于0");
|
|
|
- }
|
|
|
- PaoSetRemote tinvoiceapply_totalview = getPaoSet("tinvoiceapply_totalview");
|
|
|
- if (tinvoiceapply_totalview.getPao(0).getDouble("forderamount") != tinvoiceapply_totalview.getPao(0).getDouble("fbillamount")) {
|
|
|
- throw new P2AppException("", "订单金额和开票金额不一致");
|
|
|
- }
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- PaoRemote detailpao = null;
|
|
|
- while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
|
|
|
- double finvoiceamount = detailpao.getDouble("finvoiceamount");//本次开票金额
|
|
|
-
|
|
|
- PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
|
|
|
- PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
|
|
|
- double freceivedamount = 0;
|
|
|
- if (!saorder_receivedviewSet.isEmpty()) {
|
|
|
- freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//订单已收货金额
|
|
|
+ if (ischeck) {
|
|
|
+ if (!"提交".equals(getString("fstatus"))) {
|
|
|
+ throw new P2AppException("", "非提交状态下不可审核");
|
|
|
}
|
|
|
- String fsonum = saorderdetail.getString("fsonum");//订单号
|
|
|
- String fitemname = saorderdetail.getString("fitemname");//商品名称
|
|
|
- double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
|
|
|
- if (finvoiceamount > Math.sub(freceivedamount, finvoiceamount_order)) {
|
|
|
- throw new P2AppException("", "订单" + fsonum + "商品" + fitemname + "本次开票金额" + finvoiceamount + "超过订单可开票金额" + Math.sub(freceivedamount, finvoiceamount_order));
|
|
|
+ if (tinvoiceapplyorderSet.isEmpty()) {
|
|
|
+ throw new P2AppException("", "订单信息为空不可审核");
|
|
|
+ }
|
|
|
+ if (tinvoicebillSet.isEmpty()) {
|
|
|
+ throw new P2AppException("", "开票信息为空不可审核");
|
|
|
+ }
|
|
|
+ if (tinvoiceapplyorderSet.min("finvoiceamount") <= 0) {
|
|
|
+ throw new P2AppException("", "订单行开票金额必须大于0");
|
|
|
+ }
|
|
|
+ PaoSetRemote tinvoiceapply_totalview = getPaoSet("tinvoiceapply_totalview");
|
|
|
+ if (tinvoiceapply_totalview.getPao(0).getDouble("forderamount") != tinvoiceapply_totalview.getPao(0).getDouble("fbillamount")) {
|
|
|
+ throw new P2AppException("", "订单金额和开票金额不一致");
|
|
|
}
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void check() throws P2Exception {
|
|
|
|
|
|
- if ("手工".equalsIgnoreCase(getString("ftype"))) {
|
|
|
- PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
|
|
|
int i = 0;
|
|
|
PaoRemote detailpao = null;
|
|
|
while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
|
|
|
- double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
|
|
|
+ double finvoiceamount = detailpao.getDouble("finvoiceamount");//本次开票金额
|
|
|
+
|
|
|
PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
|
|
|
+ PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
|
|
|
+ double freceivedamount = 0;
|
|
|
+ if (!saorder_receivedviewSet.isEmpty()) {
|
|
|
+ freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//订单已收货金额
|
|
|
+ }
|
|
|
+ String fsonum = saorderdetail.getString("fsonum");//订单号
|
|
|
+ String fitemname = saorderdetail.getString("fitemname");//商品名称
|
|
|
double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
|
|
|
- saorderdetail.setValue("finvoiceamount", Math.add(finvoiceamount_order, finvoiceamount_detail), 111L);
|
|
|
+ if (finvoiceamount > Math.sub(freceivedamount, finvoiceamount_order)) {
|
|
|
+ throw new P2AppException("", "订单" + fsonum + "商品" + fitemname + "本次开票金额" + finvoiceamount + "超过订单可开票金额" + Math.sub(freceivedamount, finvoiceamount_order));
|
|
|
+ }
|
|
|
i++;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (!"手工".equalsIgnoreCase(getString("ftype"))) {
|
|
|
+ int i = 0;
|
|
|
+ while (tinvoicebillSet.getPao(i) != null) {
|
|
|
+ if (!tinvoicebillSet.getPao(i).getString("fstatus").equals("")) {
|
|
|
+ throw new P2AppException("", "已对接开票接口,不可进行反审核!");
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- setValue("fstatus", "审核", 11L);
|
|
|
- setValue("checkby", getUserName(), 11L);
|
|
|
- setValue("checkdate", getDateTime(), 11L);
|
|
|
-
|
|
|
- //getPaoSet("tinvoicebill").selectAll();
|
|
|
- //createBlueInvoice();
|
|
|
-
|
|
|
+ public void check(boolean ischeck) throws P2Exception {
|
|
|
+ if (ischeck) {
|
|
|
+ if ("手工".equalsIgnoreCase(getString("ftype"))) {
|
|
|
+ PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
|
|
|
+ int i = 0;
|
|
|
+ PaoRemote detailpao = null;
|
|
|
+ while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
|
|
|
+ double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
|
|
|
+ PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
|
|
|
+ double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
|
|
|
+ saorderdetail.setValue("finvoiceamount", Math.add(finvoiceamount_order, finvoiceamount_detail), 111L);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setValue("fstatus", "审核", 11L);
|
|
|
+ setValue("checkby", getUserName(), 11L);
|
|
|
+ setValue("checkdate", getDateTime(), 11L);
|
|
|
+ } else {
|
|
|
+ if ("手工".equalsIgnoreCase(getString("ftype"))) {
|
|
|
+ PaoSetRemote tinvoiceapplyorderSet = getPaoSet("tinvoiceapplyorder");
|
|
|
+ int i = 0;
|
|
|
+ PaoRemote detailpao = null;
|
|
|
+ while ((detailpao = tinvoiceapplyorderSet.getPao(i)) != null) {
|
|
|
+ double finvoiceamount_detail = detailpao.getDouble("finvoiceamount");//本次开票金额
|
|
|
+ PaoRemote saorderdetail = detailpao.getPaoSet("saorderdetail").getPao(0);
|
|
|
+ double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//订单已开票金额
|
|
|
+ saorderdetail.setValue("finvoiceamount", Math.sub(finvoiceamount_order, finvoiceamount_detail), 111L);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setValue("fstatus", "提交", 11L);
|
|
|
+ setValue("checkby", "", 11L);
|
|
|
+ setValue("checkdate", "", 11L);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -354,8 +377,8 @@ public class tinvoiceapply extends PaoCust {
|
|
|
if (!rows.isEmpty()) {
|
|
|
setValue("FINVOICEMOBILE", rows.get(0).getString("fphonenumber"));
|
|
|
setValue("FINVOICEBANKANDACCOUNT", rows.get(0).getString("fbankcardid"));
|
|
|
- }else{
|
|
|
- setValue("FINVOICEMOBILE","");
|
|
|
+ } else {
|
|
|
+ setValue("FINVOICEMOBILE", "");
|
|
|
setValue("FINVOICEBANKANDACCOUNT", "");
|
|
|
}
|
|
|
}
|