Stok Fişi BeforeSave Script

Stok Fişi BeforeSave Script

if (this.allGrids['stock-fiches-details'].api.getDisplayedRowCount() === 0)//SERKAN-YELDA
        throw new Error(angus.languageService.staticTranslator.translate('You cannot save the stock fiche without a line!')); 
       
const deleteAllRows = [];
this.allGrids['stock-fiches-details'].grid.agGrid.api.forEachNode(x =>{if (x.toBeDeleted == true) deleteAllRows.push(x)});
if(this.allGrids['stock-fiches-details'].api.getDisplayedRowCount() == deleteAllRows.length){//SERKAN-YELDA
  let msg = angus.languageService.dynamicTranslator.translate('There are no valid lines');
  throw msg;
}     
let stockFicheGrid = this.allGrids["stock-fiches-details"];
var TypeId = this.recordService.formGroup.get('TYPEID').value;
debugger;
if(this.recordService.formGroup.get('SENDERSTOREID').value  && this.recordService.formGroup.get('RECIPIENTSTOREID').value){
  if(this.recordService.formGroup.get('SENDERSTOREID').value == this.recordService.formGroup.get('RECIPIENTSTOREID').value)
    throw new Error(angus.languageService.staticTranslator.translate('Sender and recipient stores cannot be the same'));//'Giriş ve çıkış depoları aynı olamaz!'
}

stockFicheGrid.api.forEachNode(rowNode => {
  debugger;
console.log('TypeId: ',TypeId);
if(TypeId == 12 &&  rowNode.data.SENDERSTOREID){//transfer ise
  throw angus.languageService.dynamicTranslator.translate('Exits store cannot be selected in the row');
}
else if([13,14,15,17,18,19].indexOf(TypeId)!=-1 &&  rowNode.data.RECIPIENTSTOREID ) {//tüketimler ise //tüketim-ikram-ödenmez-zayi
  throw angus.languageService.dynamicTranslator.translate('Entry store cannot be selected in the row');
}
if(TypeId ==12 && this.recordService.formGroup.get('SENDERSTOREID').value){
  if(rowNode.data.RECIPIENTSTOREID)
    {
      if(this.recordService.formGroup.get('SENDERSTOREID').value == rowNode.data.RECIPIENTSTOREID) {
         throw angus.languageService.dynamicTranslator.translate(`The recipient store for {{${ rowNode.data.STOCKID_NAME ? rowNode.data.STOCKID_NAME : ''   }}} stock must be different`);
      }
    }
}
});

Last updated