这个问题困扰了我一阵子,在此做一个总结。

设置付款科目为Undeposited Funds

建议按照customer, date, currency, undepfunds, account, payment的顺序写入值。重点是先给account赋值为null,再给undepfunds赋值'T'

按照以下例子赋值(代码片段仅供参考,不可直接运行)

let recObj = record.create({
  type: "customerpayment",
  isDynamic: true,
});
recObj.setValue({
  fieldId: "customer",
  value: customer,
});
recObj.setValue({
  fieldId: "date",
  value: format.parse({
    value: createdDate,
    type: "date",
  }),
});
recObj.setValue({
  fieldId: "account",
  value: null,
});
recObj.setValue({
  fieldId: "undepfunds",
  value: "T",
});
recObj.setText({
  fieldId: "currency",
  text: currency,
});
recObj.setValue({
  fieldId: "payment",
  value: amount,
});
for (let i = 0; i < recObj.getLineCount({ sublistId: "apply" }); i++) {
  recObj.selectLine({ sublistId: "apply", line: i });
  if (
    invIdArr.indexOf(
      recObj.getCurrentSublistValue({
        sublistId: "apply",
        fieldId: "internalid",
      }),
    ) > -1
  ) {
    recObj.setCurrentSublistValue({
      sublistId: "apply",
      fieldId: "apply",
      value: true,
    });
    let lineAmt = recObj.getCurrentSublistValue({
      sublistId: "apply",
      fieldId: "due",
    });
    if (gap > 0) {
      recObj.setCurrentSublistValue({
        sublistId: "apply",
        fieldId: "disc",
        value: gap,
      });
      gap = 0;
    } else {
      recObj.setCurrentSublistValue({
        sublistId: "apply",
        fieldId: "amount",
        value: lineAmt,
      });
    }
    recObj.commitLine({ sublistId: "apply" });
  }
}
let generatedRecId = recObj.save();

设置付款科目为具体科目

建议按照customer, date, currency, undepfunds, account, payment的顺序写入值。重点是先写入currency,给undepfunds赋值'F',给account赋值。

let recObj = record.create({
  type: "customerpayment",
  isDynamic: true,
});
recObj.setValue({
  fieldId: "customer",
  value: customer,
});
recObj.setValue({
  fieldId: "date",
  value: format.parse({
    value: createdDate,
    type: "date",
  }),
});
recObj.setText({
  fieldId: "currency",
  text: currency,
});
recObj.setValue({
  fieldId: "undepfunds",
  value: "F",
});

recObj.setValue({
  fieldId: "account",
  value: account,
});
recObj.setValue({
  fieldId: "payment",
  value: amount,
});
for (let i = 0; i < recObj.getLineCount({ sublistId: "apply" }); i++) {
  recObj.selectLine({ sublistId: "apply", line: i });
  if (
    invIdArr.indexOf(
      recObj.getCurrentSublistValue({
        sublistId: "apply",
        fieldId: "internalid",
      }),
    ) > -1
  ) {
    recObj.setCurrentSublistValue({
      sublistId: "apply",
      fieldId: "apply",
      value: true,
    });
    let lineAmt = recObj.getCurrentSublistValue({
      sublistId: "apply",
      fieldId: "due",
    });
    if (gap > 0) {
      recObj.setCurrentSublistValue({
        sublistId: "apply",
        fieldId: "disc",
        value: gap,
      });
      gap = 0;
    } else {
      recObj.setCurrentSublistValue({
        sublistId: "apply",
        fieldId: "amount",
        value: lineAmt,
      });
    }
    recObj.commitLine({ sublistId: "apply" });
  }
}
let generatedRecId = recObj.save();
Last modified: 22/12/2023

Author

Comments

Write a Reply or Comment

Your email address will not be published.