public void DeleteExpenseMileageItemOnTransaction(Guid txId, long expenseMileageItemId) { ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpenseMileageItemRow row = expDs.FnExpenseMileageItem.FindByExpenseMileageItemID(expenseMileageItemId); row.Delete(); }
public void AddExpenseMileageItemOnTransaction(FnExpenseMileageItem expenseMileageItem, Guid txId) { this.ValidateMileageItem(expenseMileageItem, txId); ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpenseMileageItemRow row = ds.FnExpenseMileageItem.NewFnExpenseMileageItemRow(); row.TravelDate = expenseMileageItem.TravelDate.Value; row.LocationFrom = expenseMileageItem.LocationFrom; row.LocationTo = expenseMileageItem.LocationTo; row.CarMeterStart = (decimal)expenseMileageItem.CarMeterStart.Value; row.CarMeterEnd = (decimal)expenseMileageItem.CarMeterEnd.Value; row.DistanceTotal = (decimal)ComputeDistanceTotal(expenseMileageItem.CarMeterStart.Value, expenseMileageItem.CarMeterEnd.Value); if (expenseMileageItem.ExpenseMileage != null) { row.ExpenseMileageID = expenseMileageItem.ExpenseMileage.ExpenseMileageID; if (expenseMileageItem.ExpenseMileage.Owner.Equals(OwnerMileage.Employee)) { row.DistanceFirst100Km = (decimal)ComputeFirstDistance(expenseMileageItem.CarMeterStart.Value, expenseMileageItem.CarMeterEnd.Value, expenseMileageItem.ExpenseMileage.TypeOfCar); row.DistanceExceed100Km = (decimal)ComputeExceedDistance(expenseMileageItem.CarMeterStart.Value, expenseMileageItem.CarMeterEnd.Value, expenseMileageItem.ExpenseMileage.TypeOfCar); } else { row.DistanceAdjust = (decimal)expenseMileageItem.DistanceAdjust; row.DistanceNet = (decimal)ComputeDistanceNet(row.DistanceTotal, (row.DistanceAdjust)); } } row.Active = true; row.CreDate = DateTime.Now; row.CreBy = UserAccount.UserID; row.UpdDate = DateTime.Now; row.UpdBy = UserAccount.UserID; row.UpdPgm = UserAccount.CurrentProgramCode; ds.FnExpenseMileageItem.AddFnExpenseMileageItemRow(row); //Calculate for Mileage if (expenseMileageItem.ExpenseMileage != null) { FnExpenseMileageService.UpdateMileageSummary(txId, expenseMileageItem.ExpenseMileage); } }
public void PrepareDataToDataset(ExpenseDataSet ds, long mileageId) { IList <FnExpenseMileageItem> itemList = ScgeAccountingQueryProvider.FnExpenseMileageItemQuery.GetMileageItemByMileageID(mileageId); foreach (FnExpenseMileageItem item in itemList) { // Set data to invoice row in Dataset. ExpenseDataSet.FnExpenseMileageItemRow row = ds.FnExpenseMileageItem.NewFnExpenseMileageItemRow(); row.ExpenseMileageItemID = item.ExpenseMileageItemID; if (item.ExpenseMileage != null) { row.ExpenseMileageID = mileageId; } row.TravelDate = item.TravelDate.Value; row.LocationFrom = item.LocationFrom; row.LocationTo = item.LocationTo; row.CarMeterStart = (decimal)item.CarMeterStart.Value; row.CarMeterEnd = (decimal)item.CarMeterEnd.Value; row.DistanceTotal = (decimal)item.DistanceTotal; //(decimal)ComputeDistanceTotal(item.CarMeterStart.Value, item.CarMeterEnd.Value); row.DistanceFirst100Km = (decimal)item.DistanceFirst100Km; //(decimal)ComputeDistanceFirst100Km(item.CarMeterStart.Value, item.CarMeterEnd.Value); row.DistanceExceed100Km = (decimal)item.DistanceExceed100Km; //(decimal)ComputeDistanceExceed100Km(item.CarMeterStart.Value, item.CarMeterEnd.Value); row.DistanceAdjust = (decimal)item.DistanceAdjust; row.DistanceNet = (decimal)item.DistanceNet; row.Active = item.Active; row.CreBy = item.CreBy; row.CreDate = item.CreDate; row.UpdBy = item.UpdBy; row.UpdDate = item.UpdDate; row.UpdPgm = item.UpdPgm; // Add mileage item row to documentDataset. ds.FnExpenseMileageItem.AddFnExpenseMileageItemRow(row); } }