//only call AFTER GENERATING NEW RD FOR UNFULFILLED ITEMS
        public void CheckRequisitionCompletenessAfterDisbursement(int disbursementId, Models.MobileDTOs.DisbursementDTO dDto)
        {
            List <Requisition> uniqueReqs = requisitionDetailRepo.GetUniqueRequisitionsForDisbursement(disbursementId);

            foreach (Requisition r in uniqueReqs)
            {
                int rowsReqDets   = requisitionDetailRepo.FindBy(x => x.RequisitionId == r.Id).Count();
                int rowsFulfilled = requisitionDetailRepo.FindBy(x => x.RequisitionId == r.Id &&
                                                                 x.Status.Equals("COLLECTED")).Count();
                if (rowsReqDets == rowsFulfilled)
                {
                    //update r to completed
                    Requisition req = requisitionRepo.FindById(r.Id);
                    req.Status = RequisitionStatusEnum.COMPLETED.ToString();
                    requisitionRepo.Update(req);
                    emailNotificationService.NotifyEmployeeCompletedRequisition(req, req.Employee);
                }
            }
            Disbursement d = disbursementRepo.FindById(disbursementId);

            d.DeliveryDateTime = DateTime.Now;
            byte[] bytes = Convert.FromBase64String(dDto.Signature);
            d.Signature = bytes;
            d.OnRoute   = false;
            disbursementRepo.Update(d);
            foreach (RequisitionDetail rd in d.RequisitionDetails)
            {
                Stationery s = stationeryRepo.FindById(rd.Stationery.Id);
                s.Quantity -= (int)rd.QuantityDelivered;
                stationeryRepo.Update(s);
            }
        }
Exemplo n.º 2
0
 public void UpdateAdjustmentVoucher(AdjustmentVoucher adj)
 {
     if (adj.Status.Equals("Submitted"))
     {
         foreach (AdjustmentVoucherDetail avd in adj.AdjustmentVoucherDetails)
         {
             int        sId = avd.StationeryId;
             Stationery s   = stationeryRepo.FindById(sId);
             s.Quantity += avd.Quantity;
             stationeryRepo.Update(s);
         }
     }
     adjustmentVoucherRepo.Update(adj);
 }