コード例 #1
0
        public ActionResult CreateUpdateOtherItemExpense(OtherExpenseModel otherItemExpenseModel)
        {
            if (!ModelState.IsValid)
            {
                return(ShowErrorMessage(GetModelErrors(ModelState)));
            }

            var otherItemExpense = new OtherExpense();

            if (otherItemExpenseModel.Id > 0)
            {
                otherItemExpense = FarmManagementEntities.OtherExpenses.Single(x => x.Id == otherItemExpenseModel.Id);
            }

            otherItemExpense.FarmId    = otherItemExpenseModel.FarmId;
            otherItemExpense.AccountId = otherItemExpenseModel.AccountId;

            otherItemExpense.OtherItemId = otherItemExpenseModel.OtherItemId;
            otherItemExpense.Amount      = otherItemExpenseModel.Amount;
            otherItemExpense.Description = otherItemExpenseModel.Description;
            otherItemExpense.Date        = otherItemExpenseModel.Date;

            if (otherItemExpenseModel.Id == 0)
            {
                otherItemExpense.UserId = otherItemExpenseModel.UserId;
                FarmManagementEntities.OtherExpenses.Add(otherItemExpense);
            }

            FarmManagementEntities.SaveChanges();

            var message = string.Format(Constant.SuccessMessage, otherItemExpenseModel.Id > 0 ? "updated" : "added");

            return(ShowSuccessMessage(message));
        }
コード例 #2
0
        public OtherExpenseDetail FixDate(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService)
        {
            otherExpenseDetail.EndDate = otherExpenseDetail.EffectiveDate;
            OtherExpense otherExpense = _otherExpenseService.GetObjectById(otherExpenseDetail.OtherExpenseId);

            if (otherExpense != null)
            {
                DateTime curDay = otherExpenseDetail.EffectiveDate;
                int      cnt    = otherExpenseDetail.Recurring;
                while (cnt > 1)
                {
                    switch ((Constant.SalaryItemStatus)otherExpense.SalaryStatus)
                    {
                    case Constant.SalaryItemStatus.Daily: otherExpenseDetail.EndDate = curDay.AddDays(1); break;

                    case Constant.SalaryItemStatus.Weekly: otherExpenseDetail.EndDate = curDay.AddDays(7); break;

                    case Constant.SalaryItemStatus.Monthly: otherExpenseDetail.EndDate = curDay.AddMonths(1); break;

                    case Constant.SalaryItemStatus.Yearly: otherExpenseDetail.EndDate = curDay.AddYears(1); break;
                    }
                    curDay = otherExpenseDetail.EndDate;
                    cnt--;
                }
            }
            return(otherExpenseDetail);
        }
コード例 #3
0
        public dynamic GetDefaultInfo()
        {
            OtherExpense model = new OtherExpense();

            try
            {
                model = _otherExpenseService.GetQueryable().FirstOrDefault();
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Id,
                model.SalaryItemId,
                model.Code,
                model.Name,
                model.Description,
                model.SalaryStatus,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public dynamic Insert(OtherExpense model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.OtherExpense, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Add record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _otherExpenseService.CreateObject(model, _salaryItemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #5
0
 public OtherExpense UpdateObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidUpdateObject(otherExpense, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());
         if (salaryItem == null)
         {
             salaryItem = _salaryItemService.CreateObject(otherExpense.Code, otherExpense.Name, (int)Constant.SalarySign.Expense, (int)Constant.SalaryItemType.SalarySlip, otherExpense.SalaryStatus, otherExpense.IsMainSalary, otherExpense.IsDetailSalary, false);
             otherExpense.SalaryItemId = salaryItem.Id;
         }
         else
         {
             salaryItem.Code             = otherExpense.Code;
             salaryItem.Name             = otherExpense.Name;
             salaryItem.SalaryItemStatus = otherExpense.SalaryStatus;
             _salaryItemService.UpdateObject(salaryItem);
             if (salaryItem.Errors.Any())
             {
                 otherExpense.Errors.Clear();
                 otherExpense.Errors.Add("Code", "Tidak dapat mengubah SalaryItem dengan Code ini");
             }
         }
         _repository.UpdateObject(otherExpense);
     }
     return(otherExpense);
 }
コード例 #6
0
        static void OtherExpense()                                                                  // method to call otherexpenses and its functions
        {
            var amount = new OtherExpense();

            amount.PrintLine();

            amount.Amount();
        }
コード例 #7
0
        public OtherExpense VHasSalaryItem(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                otherExpense.Errors.Add("SalaryItem", "Tidak valid");
            }
            return(otherExpense);
        }
コード例 #8
0
        public OtherExpenseDetail VHasOtherExpense(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService)
        {
            OtherExpense otherExpense = _otherExpenseService.GetObjectById(otherExpenseDetail.OtherExpenseId);

            if (otherExpense == null)
            {
                otherExpenseDetail.Errors.Add("OtherExpense", "Tidak ada");
            }
            return(otherExpenseDetail);
        }
コード例 #9
0
 public Task <int> SaveExpenseAsync(OtherExpense otherExpense)
 {
     if (otherExpense.ID != 0)
     {
         return(_sdatabase.UpdateAsync(otherExpense));
     }
     else
     {
         return(_sdatabase.InsertAsync(otherExpense));
     }
 }
コード例 #10
0
 public List <OtherExpense> GetAllApprovedExpense(OtherExpense otherExpense)
 {
     try
     {
         return(_otherExpenseRepository.GetAllApprovedExpense(otherExpense));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #11
0
 public OtherExpense InsertOtherExpense(OtherExpense otherExpense)
 {
     try
     {
         return(_otherExpenseRepository.InsertOtherExpense(otherExpense));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #12
0
 public OtherExpense VHasUniqueCode(OtherExpense otherExpense, IOtherExpenseService _otherExpenseService)
 {
     if (String.IsNullOrEmpty(otherExpense.Code) || otherExpense.Code.Trim() == "")
     {
         otherExpense.Errors.Add("Code", "Tidak boleh kosong");
     }
     else if (_otherExpenseService.IsCodeDuplicated(otherExpense))
     {
         otherExpense.Errors.Add("Code", "Tidak boleh ada duplikasi");
     }
     return(otherExpense);
 }
コード例 #13
0
 public string GetAllApprovedExpense(OtherExpense otherExpense)
 {
     try
     {
         List <OtherExpenseViewModel> expense = Mapper.Map <List <OtherExpense>, List <OtherExpenseViewModel> >(_otherExpenseBusiness.GetAllApprovedExpense(otherExpense));
         return(JsonConvert.SerializeObject(new { Result = true, Records = expense }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
コード例 #14
0
        public string PrintError(OtherExpense obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
コード例 #15
0
 public OtherExpense SoftDeleteObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidDeleteObject(otherExpense))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());
         _repository.SoftDeleteObject(otherExpense);
         if (salaryItem != null)
         {
             _salaryItemService.SoftDeleteObject(salaryItem);
         }
     }
     return(otherExpense);
 }
コード例 #16
0
        /// <summary>
        /// Saves a new OtherExpense or updates an already existing OtherExpense.
        /// </summary>
        /// <param name="OtherExpense">OtherExpense to be saved or updated.</param>
        /// <param name="OtherExpenseId">OtherExpenseId of the OtherExpense creating or updating</param>
        /// <returns>OtherExpenseId</returns>
        public long SaveOtherExpense(OtherExpenseDTO otherExpenseDTO, string userId)
        {
            long otherExpenseId = 0;

            if (otherExpenseDTO.OtherExpenseId == 0)
            {
                var otherExpense = new OtherExpense()
                {
                    Amount      = otherExpenseDTO.Amount,
                    Description = otherExpenseDTO.Description,
                    BranchId    = otherExpenseDTO.BranchId,
                    SectorId    = otherExpenseDTO.SectorId,
                    BatchId     = otherExpenseDTO.BatchId,
                    CreatedOn   = DateTime.Now,
                    TimeStamp   = DateTime.Now,
                    CreatedBy   = userId,
                    Deleted     = false,
                };

                this.UnitOfWork.Get <OtherExpense>().AddNew(otherExpense);
                this.UnitOfWork.SaveChanges();
                otherExpenseId = otherExpense.OtherExpenseId;
                return(otherExpenseId);
            }

            else
            {
                var result = this.UnitOfWork.Get <OtherExpense>().AsQueryable()
                             .FirstOrDefault(e => e.OtherExpenseId == otherExpenseDTO.OtherExpenseId);
                if (result != null)
                {
                    result.Amount      = otherExpenseDTO.Amount;
                    result.UpdatedBy   = userId;
                    result.Description = otherExpenseDTO.Description;
                    result.BatchId     = otherExpenseDTO.BatchId;
                    result.TimeStamp   = DateTime.Now;
                    result.Deleted     = otherExpenseDTO.Deleted;
                    result.BranchId    = otherExpenseDTO.BranchId;
                    result.SectorId    = otherExpenseDTO.SectorId;
                    result.DeletedBy   = otherExpenseDTO.DeletedBy;
                    result.DeletedOn   = otherExpenseDTO.DeletedOn;

                    this.UnitOfWork.Get <OtherExpense>().Update(result);
                    this.UnitOfWork.SaveChanges();
                }
                return(otherExpenseDTO.OtherExpenseId);
            }
            return(otherExpenseId);
        }
コード例 #17
0
        public OtherExpense GetOpeningBalance(string OpeningDate)
        {
            try
            {
                OtherExpense OtherExpenseObj = null;

                OtherExpenseObj                   = _otherExpenseRepository.GetOpeningBalance(OpeningDate);
                OtherExpenseObj.OpeningBank       = _commonBusiness.ConvertCurrency(decimal.Parse(OtherExpenseObj.OpeningBank));
                OtherExpenseObj.OpeningCash       = _commonBusiness.ConvertCurrency(decimal.Parse(OtherExpenseObj.OpeningCash));
                OtherExpenseObj.OpeningNCBank     = _commonBusiness.ConvertCurrency(decimal.Parse(OtherExpenseObj.OpeningNCBank));
                OtherExpenseObj.UndepositedCheque = _commonBusiness.ConvertCurrency(decimal.Parse(OtherExpenseObj.UndepositedCheque));
                return(OtherExpenseObj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #18
0
        public string GetExpenseDetailsForMobile(OtherExpense expObj)
        {
            try
            {
                if (expObj == null)
                {
                    throw new Exception(messages.NoItems);
                }

                List <OtherExpenseViewModel> expenseObj = Mapper.Map <List <OtherExpense>, List <OtherExpenseViewModel> >(_otherExpenseBusiness.GetExpenseTypeDetails(expObj));

                return(JsonConvert.SerializeObject(new { Result = true, Records = expenseObj }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
            }
        }
コード例 #19
0
 public string ApproveOtherExpenseForMobile(OtherExpense otherExpenseObj)
 {
     try
     {
         if (otherExpenseObj.ID != Guid.Empty && otherExpenseObj.ID != null)
         {
             string resultMessage = _otherExpenseBusiness.ApproveOtherExpense(otherExpenseObj.ID);
             return(JsonConvert.SerializeObject(new { Result = true, Message = resultMessage }));
         }
         else
         {
             throw new Exception("Invalid Input");
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
コード例 #20
0
 public string GetOtherExpenseByIDForMobile(OtherExpense otherExpenseObj)
 {
     try
     {
         if (otherExpenseObj.ID != Guid.Empty && otherExpenseObj.ID != null)
         {
             OtherExpenseViewModel expenseObj = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.GetOtherExpenseByID(otherExpenseObj.ID));
             return(JsonConvert.SerializeObject(new { Result = true, Records = expenseObj }));
         }
         else
         {
             throw new Exception("Invalid Input");
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
コード例 #21
0
        public long SaveOtherExpense(OtherExpense otherExpense, string userId)
        {
            var otherExpenseDTO = new DTO.OtherExpenseDTO()
            {
                OtherExpenseId = otherExpense.OtherExpenseId,
                BatchId        = otherExpense.BatchId,
                Description    = otherExpense.Description,
                BranchId       = otherExpense.BranchId,
                Amount         = otherExpense.Amount,
                Deleted        = otherExpense.Deleted,
                CreatedBy      = otherExpense.CreatedBy,
                CreatedOn      = otherExpense.CreatedOn,
                SectorId       = otherExpense.SectorId,
            };

            var OtherExpenseId = this._dataService.SaveOtherExpense(otherExpenseDTO, userId);

            return(OtherExpenseId);
        }
コード例 #22
0
        /// <summary>
        /// Maps OtherExpense EF object to OtherExpense Model Object and
        /// returns the OtherExpense model object.
        /// </summary>
        /// <param name="result">EF OtherExpense object to be mapped.</param>
        /// <returns>OtherExpense Model Object.</returns>
        public OtherExpense MapEFToModel(EF.Models.OtherExpense data)
        {
            var otherExpense = new OtherExpense()
            {
                OtherExpenseId = data.OtherExpenseId,
                Amount         = data.Amount,
                SectorId       = data.SectorId,
                BranchId       = data.BranchId,
                BatchId        = data.BatchId,
                Description    = data.Description,
                BranchName     = data.Branch != null ? data.Branch.Name : "",
                SectorName     = data.Sector != null ? data.Sector.Name : "",
                CreatedOn      = data.CreatedOn,
                TimeStamp      = data.TimeStamp,
                Deleted        = data.Deleted,
                CreatedBy      = _userService.GetUserFullName(data.AspNetUser),
                UpdatedBy      = _userService.GetUserFullName(data.AspNetUser1),
            };

            return(otherExpense);
        }
コード例 #23
0
        public dynamic Update(OtherExpense model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.OtherExpense, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _otherExpenseService.GetObjectById(model.Id);
                //data.SalaryItemId = model.SalaryItemId;
                data.Code         = model.Code;
                data.Name         = model.Name;
                data.Description  = model.Description;
                data.SalaryStatus = model.SalaryStatus;
                model             = _otherExpenseService.UpdateObject(data, _salaryItemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #24
0
 public OtherExpense CreateObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     otherExpense.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(otherExpense, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectByCode(otherExpense.Code);
         if (salaryItem != null)
         {
             otherExpense.Errors = new Dictionary <string, string>();
             otherExpense.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada");
             return(otherExpense);
         }
         salaryItem = _salaryItemService.CreateObject(otherExpense.Code, otherExpense.Name, (int)Constant.SalarySign.Expense, (int)Constant.SalaryItemType.OtherExpense, otherExpense.SalaryStatus, otherExpense.IsMainSalary, otherExpense.IsDetailSalary, false);
         if (salaryItem == null)
         {
             otherExpense.Errors = new Dictionary <string, string>();
             otherExpense.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini");
             return(otherExpense);
         }
         otherExpense.SalaryItemId = salaryItem.Id;
         _repository.CreateObject(otherExpense);
     }
     return(otherExpense);
 }
コード例 #25
0
        public dynamic Delete(OtherExpense model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Delete", Core.Constants.Constant.MenuName.OtherExpense, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Delete Record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _otherExpenseService.GetObjectById(model.Id);
                model = _otherExpenseService.SoftDeleteObject(data, _salaryItemService);
            }

            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
コード例 #26
0
 public bool ValidUpdateObject(OtherExpense otherExpense, IOtherExpenseService _otherExpenseService)
 {
     otherExpense.Errors.Clear();
     ValidCreateObject(otherExpense, _otherExpenseService);
     return(isValid(otherExpense));
 }
コード例 #27
0
        /// <summary>
        /// Maps Batch EF object to Batch Model Object and
        /// returns the Batch model object.
        /// </summary>
        /// <param name="result">EF Batch object to be mapped.</param>
        /// <returns>Batch Model Object.</returns>
        public Batch MapEFToModel(EF.Models.Batch data)
        {
            var batch = new Batch()
            {
                BatchId  = data.BatchId,
                Name     = data.Name,
                Quantity = data.Quantity,
                BranchId = data.BranchId,

                BranchName = data.Branch != null ? data.Branch.Name : "",
                SectorName = data.Sector != null ? data.Sector.Name : "",
                SectorId   = data.SectorId,
                CreatedOn  = data.CreatedOn,
                TimeStamp  = data.TimeStamp,
                Deleted    = data.Deleted,
                BranchMillingChargeRate = data.Branch != null? data.Branch.MillingChargeRate:0,
                CreatedBy = _userService.GetUserFullName(data.AspNetUser),
                UpdatedBy = _userService.GetUserFullName(data.AspNetUser1),
            };


            var batchOutPuts = GetAllBatchOutPutsForABatch(data.BatchId);
            List <BatchOutPut> batchOutPutList = new List <BatchOutPut>();

            if (batchOutPuts.Any())
            {
                foreach (var outPut in batchOutPuts)
                {
                    var batchOutPut = new BatchOutPut()
                    {
                        Grades          = outPut.Grades,
                        TotalBuveraCost = outPut.TotalBuveraCost,
                        TotalQuantity   = outPut.TotalQuantity,
                        BrandOutPut     = outPut.BrandOutPut,
                        FlourPercentage = outPut.FlourPercentage,
                        BrandPercentage = outPut.BrandPercentage,
                        FlourOutPut     = outPut.FlourOutPut,
                        LossPercentage  = outPut.LossPercentage,
                        Loss            = outPut.Loss,
                    };
                    batchOutPutList.Add(batchOutPut);
                    batch.TotalBuveraCost = batchOutPut.TotalBuveraCost;
                    batch.TotalQuantity   = batchOutPut.TotalQuantity;
                    batch.FlourOutPut     = batchOutPut.FlourOutPut;
                    batch.LossPercentage  = batchOutPut.LossPercentage;
                    batch.Loss            = Convert.ToDouble(batchOutPut.Loss);
                    batch.BrandOutPut     = batchOutPut.BrandOutPut;
                    batch.BrandPercentage = batchOutPut.BrandPercentage;
                    batch.FlourPercentage = batchOutPut.FlourPercentage;
                    batch.Grades          = batchOutPut.Grades;
                }
            }
            batch.MillingCharge = batch.BranchMillingChargeRate * batch.FlourOutPut;

            var    otherExpenses    = GetAllOtherExpensesForABatch(data.BatchId);
            double otherExpenseCost = 0;
            List <OtherExpense> otherExpenseList = new List <OtherExpense>();

            if (otherExpenses.Any())
            {
                foreach (var other in otherExpenses)
                {
                    var otherExpense = new OtherExpense()
                    {
                        Amount      = other.Amount,
                        Description = other.Description,
                    };
                    otherExpenseList.Add(otherExpense);
                    otherExpenseCost = otherExpenseCost + other.Amount;
                }
                batch.TotalOtherExpenseCost = otherExpenseCost;
                batch.OtherExpenses         = otherExpenseList;
            }

            var            utilities   = GetAllUtilitiesForABatch(data.BatchId);
            double         utilityCost = 0;
            List <Utility> utilityList = new List <Utility>();

            if (utilities.Any())
            {
                foreach (var utility in utilities)
                {
                    var utilityObject = new Utility()
                    {
                        Amount      = utility.Amount,
                        Description = utility.Description,
                    };
                    utilityList.Add(utility);
                    utilityCost = utilityCost + utility.Amount;
                }
                batch.TotalUtilityCost = utilityCost;
                batch.Utilities        = utilityList;
            }

            var    factoryExpenses     = GetAllFactoryExpensesForABatch(data.BatchId);
            double totalFactoryExpense = 0;
            double factoryExpenseCost  = 0;
            List <FactoryExpense> factoryExpenseList = new List <FactoryExpense>();

            if (factoryExpenses.Any())
            {
                foreach (var item in factoryExpenses)
                {
                    var factoryExpense = new FactoryExpense()
                    {
                        Amount      = item.Amount,
                        Description = item.Description,
                    };
                    factoryExpenseList.Add(factoryExpense);
                    factoryExpenseCost = factoryExpenseCost + item.Amount;
                }
                batch.FactoryExpenseCost = factoryExpenseCost;
                batch.FactoryExpenses    = factoryExpenseList;
            }
            var    machineRepairs = GetAllMachineRepairsForABatch(data.BatchId);
            double machineCosts   = 0;
            List <MachineRepair> machineRepairList = new List <MachineRepair>();

            if (machineRepairs.Any())
            {
                foreach (var repair in machineRepairs)
                {
                    var machineRepair = new MachineRepair()
                    {
                        Amount      = repair.Amount,
                        Description = repair.Description,
                    };
                    machineRepairList.Add(machineRepair);
                    machineCosts = machineRepair.Amount + machineCosts;
                }
                batch.MachineRepairs   = machineRepairList;
                batch.TotalMachineCost = machineCosts;
            }
            totalFactoryExpense           = batch.TotalMachineCost + batch.FactoryExpenseCost;
            batch.TotalFactoryExpenseCost = totalFactoryExpense;
            batch.MillingChargeBalance    = ComputeMillingChargeBalance(batch.MillingCharge, batch.TotalFactoryExpenseCost);

            var               labourCosts      = GetAllLabourCostsForABatch(data.BatchId);
            double            totalLabourCosts = 0;
            List <LabourCost> labourCostList   = new List <LabourCost>();

            // labourCostList.AddRange(AddBatchLabourCostsAutomatically(data));
            if (labourCosts.Any())
            {
                foreach (var labour in labourCosts)
                {
                    var labourCost = new LabourCost()
                    {
                        ActivityName = labour.ActivityName,
                        Amount       = labour.Amount,
                        Quantity     = labour.Quantity,
                        Rate         = labour.Rate,
                    };
                    labourCostList.Add(labourCost);
                    totalLabourCosts = totalLabourCosts + labour.Amount;
                }
                batch.TotalLabourCosts = totalLabourCosts;
                batch.LabourCosts      = labourCostList;
            }

            if (data.BatchSupplies != null)
            {
                if (data.BatchSupplies.Any())
                {
                    double        totalSupplyAmount = 0;
                    List <Supply> supplies          = new List <Supply>();
                    var           batchSupplies     = data.BatchSupplies.AsQueryable().Where(m => m.BatchId == data.BatchId);
                    foreach (var batchSupply in batchSupplies)
                    {
                        var supply = new Supply()
                        {
                            SupplyId     = batchSupply.Supply.SupplyId,
                            Quantity     = batchSupply.Supply.Quantity,
                            SupplierId   = batchSupply.Supply.SupplierId,
                            Price        = batchSupply.Supply.Price,
                            Amount       = batchSupply.Supply.Amount,
                            SupplierName = _userService.GetUserFullName(batchSupply.Supply.AspNetUser2),
                        };
                        supplies.Add(supply);
                        totalSupplyAmount = totalSupplyAmount + supply.Amount;
                    }
                    batch.Supplies          = supplies;
                    batch.TotalSupplyAmount = totalSupplyAmount;
                }


                batch.TotalProductionCost = ComputeTotalProductionCost(batch.MillingCharge, batch.TotalLabourCosts, batch.TotalBuveraCost);
            }

            return(batch);
        }
コード例 #28
0
        public long Save(OtherExpense model)
        {
            var otherExpenseId = _otherExpenseService.SaveOtherExpense(model, userId);

            return(otherExpenseId);
        }
コード例 #29
0
        public bool isValid(OtherExpense obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
コード例 #30
0
 public bool ValidDeleteObject(OtherExpense otherExpense)
 {
     otherExpense.Errors.Clear();
     return(isValid(otherExpense));
 }