|
|
@@ -11,9 +11,8 @@ import p2.util.P2Exception;
|
|
|
import saorder.saorder;
|
|
|
import taccbal.taccbal;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
|
|
|
/**
|
|
|
* 收支凭证表主类
|
|
|
@@ -41,7 +40,7 @@ public class ficashbill extends PaoCust {
|
|
|
/*
|
|
|
* 非新建状态下或者该数据是其他单据生成的或者待审标记是true的情况下,将数据设为只读。
|
|
|
*/
|
|
|
- if (!"新建".equals(getString("fstatus")) || getInt("FSOURCEID") > 0 || getBoolean("FWILLCHECK")) {
|
|
|
+ if (!"新建".equals(getString("fstatus")) || (getInt("FSOURCEID") > 0 && !getString("fsourceobject").equalsIgnoreCase(getName())) || getBoolean("FWILLCHECK")) {
|
|
|
setFieldFlag(new GetFieldsName(getName()).getFields(), READONLY, true);
|
|
|
if ("提交".equals(getString("fstatus"))) {
|
|
|
setFieldFlag("fconfirmamount", READONLY, false);
|
|
|
@@ -54,8 +53,10 @@ public class ficashbill extends PaoCust {
|
|
|
setFieldFlag("FWILLCHECK", READONLY, false);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- setValue("FUNWRITEOFFAMOUNT", getDouble("FAMOUNT") - getDouble("FWRITEOFFAMOUNT"), 11l);
|
|
|
+ if (getDouble("famount") > 0) {
|
|
|
+ PaoSetRemote set = getPaoSet(Calendar.getInstance().getTimeInMillis() + getName(), getName(), "fstatus='审核' and ftype='" + getString("ftype") + "' and fsourceid='" + getUniqueIDValue() + "' and fsourceobject='" + getName() + "'");
|
|
|
+ setValue("FUNWRITEOFFAMOUNT", getDouble("FAMOUNT") + set.sum("famount") - getDouble("FWRITEOFFAMOUNT"), 11l);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -103,7 +104,7 @@ public class ficashbill extends PaoCust {
|
|
|
throw new P2AppException("", "非新建状态不可删除");
|
|
|
}
|
|
|
|
|
|
- if (getInt("fsourceid") > 0 && !"sendrepair".equalsIgnoreCase(getString("fsourceobject"))) {
|
|
|
+ if (getInt("fsourceid") > 0 && !("sendrepair".equalsIgnoreCase(getString("fsourceobject")) || (getName().equalsIgnoreCase(getString("fsourceobject"))))) {
|
|
|
throw new P2AppException("", "该单为系统自动生成,不可删除");
|
|
|
}
|
|
|
if (getBoolean("fwillcheck")) {
|
|
|
@@ -217,6 +218,22 @@ public class ficashbill extends PaoCust {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (getName().equalsIgnoreCase(getString("fsourceobject"))) {
|
|
|
+ if (famount >= 0) {
|
|
|
+ throw new P2AppException("", "对冲凭证必须为负数");
|
|
|
+ }
|
|
|
+ //原凭证
|
|
|
+ PaoSetRemote cashbillset = getPaoSet(Calendar.getInstance().getTimeInMillis() + getName(), getName(), "ficashbillid=" + getLong("fsourceid"));
|
|
|
+ if (cashbillset.isEmpty()) {
|
|
|
+ throw new P2AppException("", "原凭证不存在");
|
|
|
+ }
|
|
|
+ PaoRemote cashbill = cashbillset.getPao(0);
|
|
|
+ double funwriteoffamount = cashbill.getDouble("funwriteoffamount");//原凭证未核销金额
|
|
|
+ if (-famount > funwriteoffamount) {
|
|
|
+ throw new P2AppException("", "对冲金额绝对值必须小于原凭证未核销金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -478,6 +495,24 @@ public class ficashbill extends PaoCust {
|
|
|
throw new P2AppException("", "金额不可小于0");
|
|
|
}
|
|
|
}
|
|
|
+ if (getDouble(fieldname) == 0) {
|
|
|
+ throw new P2AppException("", "金额不可等于0");
|
|
|
+ }
|
|
|
+ if (getName().equalsIgnoreCase(getString("fsourceobject"))) {
|
|
|
+ if (getDouble(fieldname) >= 0) {
|
|
|
+ throw new P2AppException("", "对冲凭证必须为负数");
|
|
|
+ }
|
|
|
+ //原凭证
|
|
|
+ PaoSetRemote cashbillset = getPaoSet(Calendar.getInstance().getTimeInMillis() + getName(), getName(), "ficashbillid=" + getLong("fsourceid"));
|
|
|
+ if (cashbillset.isEmpty()) {
|
|
|
+ throw new P2AppException("", "原凭证不存在");
|
|
|
+ }
|
|
|
+ PaoRemote cashbill = cashbillset.getPao(0);
|
|
|
+ double funwriteoffamount = cashbill.getDouble("famount");//原凭证未核销金额
|
|
|
+ if (-getDouble(fieldname) > funwriteoffamount) {
|
|
|
+ throw new P2AppException("", "对冲金额绝对值必须小于原凭证未核销金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -548,4 +583,32 @@ public class ficashbill extends PaoCust {
|
|
|
pao.setValue("ficashbillnum", getString("fbillnum"));
|
|
|
return pao.getUniqueIDValue();
|
|
|
}
|
|
|
+
|
|
|
+ public long createredcashbill() throws P2Exception {
|
|
|
+ if (!"审核".equalsIgnoreCase(getString("fstatus"))) {
|
|
|
+ throw new P2AppException("", "非审核状态下不可进行对冲操作");
|
|
|
+ }
|
|
|
+ double famount = getDouble("famount");//凭证未核销金额
|
|
|
+ if (famount <= 0) {
|
|
|
+ throw new P2AppException("", "该凭证无法进行对冲操作");
|
|
|
+ }
|
|
|
+ double funwriteoffamount = getDouble("funwriteoffamount");//凭证未核销金额
|
|
|
+ if (funwriteoffamount <= 0) {
|
|
|
+ throw new P2AppException("", "当前凭证已无法进行对冲操作");
|
|
|
+ }
|
|
|
+ PaoSetRemote ficashbillSet = getPaoSet("$$ficashbill", "ficashbill");
|
|
|
+ ficashbillSet.setApp(getThisPaoSet().getApp().toUpperCase());
|
|
|
+ PaoRemote pao = ficashbillSet.addAtEnd();
|
|
|
+ pao.setValue("fsourceid", getUniqueIDValue());
|
|
|
+ pao.setValue("fsourceobject", "FICASHBILL");
|
|
|
+ pao.setValue("fagentnum", getString("fagentnum"));
|
|
|
+ pao.setValue("faccclsnum", getString("faccclsnum"));
|
|
|
+ pao.setValue("ftypemx", getString("ftypemx"), 11L);
|
|
|
+ pao.setValue("ftypemxdetail", getString("ftypemxdetail"), 11L);
|
|
|
+ pao.setValue("fnotes", "凭证对冲", 11L);
|
|
|
+ pao.setValue("fdate", getDate("fdate"));
|
|
|
+ pao.setValue("famount", -funwriteoffamount);
|
|
|
+ return pao.getUniqueIDValue();
|
|
|
+ }
|
|
|
+
|
|
|
}
|