Ödeme Emri BeforeSave Script

let docTypeOther = this.allFormControls['DOCTYPEOTHER'].value;
let docType = this.allFormControls['DOCTYPE'].value;
if (docType == 8) {
  if (
    docTypeOther == undefined ||
    docTypeOther == null ||
    docTypeOther == ' '
  ) {
    let msg = angus.languageService.dynamicTranslator.translate(
      'Document Type Other Required!'
    );
    throw msg;
  }
}

const rows = [];
this.allGrids['accounting-paymentorders-detail'].grid.agGrid.api.forEachNode(
  (x) => {
    if (x.toBeDeleted !== true) rows.push(x);
  }
);
const fields = ['LOCALCREDIT', 'LOCALDEBIT'];
const totals = rows.reduce((acc, row) => {
  fields.forEach((field) => {
    debugger;
    acc[field] = (acc[field] || 0) + row.data[field];
    console.log(acc[field], 'field: ' + field);
  });
  return acc;
}, {});

console.log(totals, 'totals');

debugger;
const controls = this.recordService.formGroup.controls;
controls.TOTALCREDIT.setValue(totals.LOCALCREDIT);
controls.TOTALDEBIT.setValue(totals.LOCALDEBIT);
if (Math.abs(totals.LOCALCREDIT - totals.LOCALDEBIT) > 0.0049) {
  let msg = angus.languageService.dynamicTranslator.translate(
    'Total Debit and Credit Must Be Equal'
  );
  throw msg;
}

Last updated