BeginForm(FillItemStockAmountForPlanningSlip) Set(@RuleErrorMessage,"") If(@GridSelectList.rowCount>1) Set(@RuleErrorMessage,"Kural'ı bir den fazla planlama için çalıştıramazsınız!") Goto(ExitForm) EndIf( ) Warehouse.Get(@GridSelectList.rows.1.WarehouseId) PlanningSlip.Get(@GridSelectList.rows.1.Id) IF(@@PlanningSlip.StateId>8) Set(@RuleErrorMessage,"@@PlanningSlip.SlipNumber Numaralı planlama statüsü bu işlem için uygun değil (Fiş satatüsü Planlandı durumunda olmalı) !") Goto(ExitForm) EndIf() PlanningSlipLine.List("SlipId=@@PlanningSlip.Id","Id",@PlanningSlipline) If(@PlanningSlipline="" or @PlanningSlipline.rowCount=0) Set(@RuleErrorMessage,"@@PlanningSlip.SlipNumber Numaralı planlamaya ait fiş satırı yok !") Goto(ExitForm) EndIf() For(@i,1,@PlanningSlipline.rowCount,1) PlanningSlipLine.Get(@[email protected]) Sql("select ItemId,Sum(TotalQuantity-ReservedQuantity) As Quantity from [dbo].[GetItemTotals](@@Warehouse.Id,0,NULL,NULL,@@Item.Id,@@ItemVariant.Id,NULL) GROUP By ItemId",@sqlResult) Set(@Quantity,0) IF(@sqlResult.rowCount>0) Set(@Quantity,@sqlResult.rows.1.Quantity) EndIf() // Satır birimi anabirimden farklıysa malzeme stok toplamı seçilen birime göre hesaplanıyor. If(@@ItemUnit.IsMasterUnit!=1) Set(@Quantity,@Quantity/(@@PlanningSlipLine.ConvFactor2*@@PlanningSlipLine.ConvFactor1)) EndIf() PlanningSlipLine.Set({"ItemAmount": "@Quantity"}) PlanningSlipLine.Save() IF(@Response.Status = "-1") Set(@RuleErrorMessage,"@Response.Message") Goto(ExitForm) EndIf() Next() Set(@RuleResponse.Status,"0") Goto(SuccsessExitForm) ExitForm: Set(@RuleResponse.Status,@Response.Status) Set(@RuleResponse.CustomMessage,"Hata oluştu : @RuleErrorMessage") Goto(ReturnForm) SuccsessExitForm: If(@RuleResponse.Status="0") Set(@RuleResponse.CustomMessage,"@@PlanningSlip.SlipNumber Numaralı Planlamaya ait malzemeler için Malzeme stok miktarları set edilmiştir.") EndIf() ReturnForm: Set(@Response.Message,"") EndForm()