|
@@ -18,7 +18,7 @@ public class twriteoffbill extends PaoCust {
|
|
|
super.init();
|
|
super.init();
|
|
|
if (!toBeAdded()) {
|
|
if (!toBeAdded()) {
|
|
|
if (!"新建".equals(getString("fstatus"))) {
|
|
if (!"新建".equals(getString("fstatus"))) {
|
|
|
- setFieldFlag(new String[]{"ficashbillnum", "fdate", "fnotes","fagentnum", "fwriteoffamount"}, READONLY, true);
|
|
|
|
|
|
|
+ setFieldFlag(new String[]{"ficashbillnum", "fdate", "fnotes", "fagentnum", "fwriteoffamount"}, READONLY, true);
|
|
|
}
|
|
}
|
|
|
PaoSetRemote ficashbillSet = getPaoSet("ficashbill");
|
|
PaoSetRemote ficashbillSet = getPaoSet("ficashbill");
|
|
|
if (!ficashbillSet.isEmpty()) {
|
|
if (!ficashbillSet.isEmpty()) {
|
|
@@ -50,7 +50,7 @@ public class twriteoffbill extends PaoCust {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void caculate() throws P2Exception {
|
|
public void caculate() throws P2Exception {
|
|
|
- double funwriteoffamount = getDouble("funwriteoffamount");//凭证未核销金额
|
|
|
|
|
|
|
+ double fwriteoffamount = getDouble("fwriteoffamount");//凭证核销金额
|
|
|
|
|
|
|
|
PaoSetRemote twriteofforderSet = getPaoSet("twriteofforder");
|
|
PaoSetRemote twriteofforderSet = getPaoSet("twriteofforder");
|
|
|
int i = 0;
|
|
int i = 0;
|
|
@@ -62,19 +62,19 @@ public class twriteoffbill extends PaoCust {
|
|
|
if (fwriteoffamount_detail <= 0) {
|
|
if (fwriteoffamount_detail <= 0) {
|
|
|
throw new P2AppException("", "表体订单行无剩余可核销金额");
|
|
throw new P2AppException("", "表体订单行无剩余可核销金额");
|
|
|
}
|
|
}
|
|
|
- if (fwriteoffamount_detail <= funwriteoffamount) {
|
|
|
|
|
|
|
+ if (fwriteoffamount_detail <= fwriteoffamount) {
|
|
|
setValue("fwriteoffamount", fwriteoffamount_detail, 11L);
|
|
setValue("fwriteoffamount", fwriteoffamount_detail, 11L);
|
|
|
} else {
|
|
} else {
|
|
|
- //如果凭证剩余未核销金额小于所选订单表体金额,则进行分摊计算
|
|
|
|
|
|
|
+ //如果凭证核销金额小于所选订单表体金额,则进行分摊计算
|
|
|
i = 0;
|
|
i = 0;
|
|
|
while (twriteofforderSet.getPao(i) != null) {
|
|
while (twriteofforderSet.getPao(i) != null) {
|
|
|
double fwriteoffamount_old = twriteofforderSet.getPao(i).getDouble("fwriteoffamount");
|
|
double fwriteoffamount_old = twriteofforderSet.getPao(i).getDouble("fwriteoffamount");
|
|
|
- double fwriteoffamount_new = funwriteoffamount * (fwriteoffamount_old / fwriteoffamount_detail);
|
|
|
|
|
|
|
+ double fwriteoffamount_new = fwriteoffamount * (fwriteoffamount_old / fwriteoffamount_detail);
|
|
|
twriteofforderSet.getPao(i).setValue("fwriteoffamount", fwriteoffamount_new, 11L);
|
|
twriteofforderSet.getPao(i).setValue("fwriteoffamount", fwriteoffamount_new, 11L);
|
|
|
i++;
|
|
i++;
|
|
|
}
|
|
}
|
|
|
//差额补齐计算
|
|
//差额补齐计算
|
|
|
- double chae = Math.sub(funwriteoffamount, twriteofforderSet.sum("fwriteoffamount"));
|
|
|
|
|
|
|
+ double chae = Math.sub(fwriteoffamount, twriteofforderSet.sum("fwriteoffamount"));
|
|
|
if (chae != 0) {
|
|
if (chae != 0) {
|
|
|
twriteofforderSet.getPao(i - 1).setValue("fwriteoffamount", Math.add(twriteofforderSet.getPao(i - 1).getDouble("fwriteoffamount"), chae), 11L);
|
|
twriteofforderSet.getPao(i - 1).setValue("fwriteoffamount", Math.add(twriteofforderSet.getPao(i - 1).getDouble("fwriteoffamount"), chae), 11L);
|
|
|
}
|
|
}
|
|
@@ -176,6 +176,21 @@ public class twriteoffbill extends PaoCust {
|
|
|
@Override
|
|
@Override
|
|
|
public void fieldValidate(Object paoField, String fieldname) throws P2Exception {
|
|
public void fieldValidate(Object paoField, String fieldname) throws P2Exception {
|
|
|
super.fieldValidate(paoField, fieldname);
|
|
super.fieldValidate(paoField, fieldname);
|
|
|
|
|
+ if ("fwriteoffamount".equalsIgnoreCase(fieldname)) {
|
|
|
|
|
+ if (getDouble("fwriteoffamount") > getDouble("funwriteoffamount")) {
|
|
|
|
|
+ throw new P2AppException("", "本次核销金额不可大于凭证未核销金额");
|
|
|
|
|
+ }
|
|
|
|
|
+ double funwriteoffamount = 0;
|
|
|
|
|
+ PaoSetRemote twriteofforderSet = getPaoSet("twriteofforder");
|
|
|
|
|
+ int i = 0;
|
|
|
|
|
+ while (twriteofforderSet.getPao(i) != null) {
|
|
|
|
|
+ funwriteoffamount = Math.add(funwriteoffamount, twriteofforderSet.getPao(i).getDouble("funwriteoffamount"));
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (getDouble("fwriteoffamount") > funwriteoffamount) {
|
|
|
|
|
+ throw new P2AppException("", "本次核销金额不可大于订单未核销金额");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|