public async Task <JsonResult> EditCategory(BillingCategory billingCategory)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var cattoEdit = await _billingRepository.GetByIdAsync(billingCategory.BillingCategoryId);

                    cattoEdit.EstateId      = billingCategory.EstateId;
                    cattoEdit.BillingAmount = billingCategory.BillingAmount;
                    cattoEdit.BillingAmount = billingCategory.BillingAmount;


                    var catAdded = await _billingRepository.Update(billingCategory.BillingCategoryId, cattoEdit);

                    if (catAdded != null)
                    {
                        return(Json(catAdded));
                    }
                }
                catch (Exception)
                {
                    return(Json(false));

                    throw;
                }
            }
            return(Json(false));
        }
Esempio n. 2
0
        public string UpdateBilling(BillingCategory types)
        {
            var sb = new StringBuilder();

            // DataClean and Data must be run again to get the last day of the month. The daily task alone will not
            // capture the last day because when it runs on the 1st the new period is used for the import date range.

            // 1) DataClean
            sb.AppendLine(GetLogText(Process.DataClean(GetDataCleanCommand(types))));

            // 2) Data
            sb.AppendLine(GetLogText(Process.Data(GetDataCommand(types))));

            // 3) Step1
            sb.AppendLine(GetLogText(Process.Step1(GetStep1Command(types))));

            // 4) Step4
            if (!IsTemp())
            {
                sb.AppendLine(GetLogText(Process.Step4(GetStep4Command())));
            }

            string message = sb.ToString();

            return(message);
        }
Esempio n. 3
0
        public async Task <BillingCategory> Update(int Id, BillingCategory obj)
        {
            var cat = _context.BillingCategory.Update(obj);
            await _context.SaveChangesAsync();

            return(cat.Entity);
        }
Esempio n. 4
0
        public async Task <int> DeleteAsync(BillingCategory obj)
        {
            var cat             = _context.BillingCategory.Remove(obj);
            var noOfRowAffected = await _context.SaveChangesAsync();

            return(noOfRowAffected);
        }
Esempio n. 5
0
        public async Task <JsonResult> CreateBillingCategory([FromBody] BillingCategory billingCategory)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var estate = await _estateRepository.GetByIdAsync(billingCategory.EstateId);

                    var cat = new BillingCategory
                    {
                        EstateId            = estate.EstateId,
                        BillingCategoryName = billingCategory.BillingCategoryName,
                        BillingAmount       = billingCategory.BillingAmount
                    };
                    var categoryAdded = await _billingRepository.InsertAsync(cat);

                    if (categoryAdded != null)
                    {
                        return(Json(categoryAdded));
                    }
                }
                catch (Exception)
                {
                    return(Json(false));

                    throw;
                }
            }
            return(Json(false));
        }
Esempio n. 6
0
        public async Task <BillingCategory> InsertAsync(BillingCategory obj)
        {
            var cat = await _context.BillingCategory.AddAsync(obj);

            await _context.SaveChangesAsync();

            return(cat.Entity);
        }
Esempio n. 7
0
 private MiscBillingByAccount(DateTime period, IClient client, IAccount acct, IBillingType bt, BillingCategory bc, decimal totalMisc, decimal totalSubsidy)
 {
     Period                   = period;
     Client                   = client;
     Account                  = acct;
     BillingType              = bt;
     BillingCategory          = bc;
     TotalMisc                = totalMisc;
     TotalMiscSubsidyDiscount = totalSubsidy;
 }
Esempio n. 8
0
 private DataCleanCommand GetDataCleanCommand(BillingCategory bc)
 {
     return(new DataCleanCommand
     {
         BillingCategory = bc,
         StartDate = Period,
         EndDate = Period.AddMonths(1),
         ClientID = ClientID
     });
 }
Esempio n. 9
0
 private DataCommand GetDataCommand(BillingCategory bc)
 {
     return(new DataCommand
     {
         BillingCategory = bc,
         Period = Period,
         ClientID = ClientID,
         Record = 0
     });
 }
Esempio n. 10
0
 private Step1Command GetStep1Command(BillingCategory bc)
 {
     return(new Step1Command
     {
         BillingCategory = bc,
         Period = Period,
         ClientID = ClientID,
         Record = 0,
         IsTemp = IsTemp(),
         Delete = true
     });
 }
Esempio n. 11
0
        public async Task <JsonResult> CategoryCreate(BillingCategory obj)
        {
            if (obj.BillingCategoryId == 0)
            {
                var model = new BillingCategory();
                model.Name = obj.Name;
                if (obj.BillingPeriodsId != null)
                {
                    model.BillingPeriodsId = obj.BillingPeriodsId;
                    model.BillingPeriods   = obj.BillingPeriods;
                }
                else
                {
                    return(Json("error", JsonRequestBehavior.AllowGet));
                }
                model.MinimunMinutes = obj.MinimunMinutes;
                _db.BillingCategories.Add(model);
                var save = await _db.SaveChangesAsync();

                if (save > 0)
                {
                    return(Json("added", JsonRequestBehavior.AllowGet));
                }
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
            else
            {
                var category = await _db.BillingCategories.FirstOrDefaultAsync(x => x.BillingCategoryId == obj.BillingCategoryId);

                //if (obj.BillingPeriodsId != null)
                //{
                //    category.BillingPeriodsId = obj.BillingPeriodsId;
                //    category.BillingPeriods = obj.BillingPeriods;
                //}
                //else
                //{
                //    return Json("error", JsonRequestBehavior.AllowGet);
                //}
                category.MinimunMinutes   = obj.MinimunMinutes;
                _db.Entry(category).State = EntityState.Modified;
                var save = await _db.SaveChangesAsync();

                if (save > 0)
                {
                    return(Json("updated", JsonRequestBehavior.AllowGet));
                }
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 12
0
        public async Task <ActionResult> CategoryDetails(int?id)

        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BillingCategory billingCategory = await _db.BillingCategories.FindAsync(id);

            if (billingCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(billingCategory));
        }
Esempio n. 13
0
        public async Task <ActionResult> CategoryIndex()
        {
            var model      = new BillingCategory();
            var Categories = await _db.BillingCategories.ToListAsync();

            //  var BillingPeriodsIds = _db.BillingCategories.Select(p => p.BillingPeriodsId).ToList().Distinct();

            ViewBag.Categories = Categories;

            var BillingPeriods = _db.BillingPeriods.ToList();

            // _db.BillingPeriods.Where(p=>!BillingPeriodsIds.Contains(p.BillingPeriodsId)).Select(p=>p).ToList();
            ViewBag.BillingPeriod = BillingPeriods;
            return(View(model));
        }
Esempio n. 14
0
        private MiscBillingByAccount CreateMiscBillingByAccount(IGrouping <MiscBillingGroupByKeySelector, IMiscBillingCharge> grp, IEnumerable <IHoliday> holidays, IBillingTypeRepository mgr)
        {
            var period    = grp.Key.Period;
            var clientId  = grp.Key.ClientID;
            var accountId = grp.Key.AccountID;

            IClient  client = ServiceProvider.Current.Data.Client.GetClient(clientId);
            IAccount acct   = ServiceProvider.Current.Data.Account.GetAccount(accountId);

            IBillingType    bt           = mgr.GetBillingType(period, clientId, acct.OrgID, holidays);
            BillingCategory bc           = (BillingCategory)Enum.Parse(typeof(BillingCategory), grp.Key.SubType, true);
            decimal         totalMisc    = grp.Sum(g => Convert.ToDecimal(g.Quantity) * g.UnitCost);
            decimal         totalSubsidy = grp.Sum(g => g.SubsidyDiscount);

            return(new MiscBillingByAccount(period, client, acct, bt, bc, totalMisc, totalSubsidy));
        }
        protected void btnAddBilling_Click(object sender, EventArgs e)
        {
            //Insert Values into discounts table using linq
            TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
            BillingCategory addBilling = new BillingCategory();
            addBilling.BillingCategoryDescription = txtDesciption.Text;

            if (cbTaxable.Checked)
            {
                addBilling.BillingCategoryTaxable = true;
            }
            else
            {
                addBilling.BillingCategoryTaxable = false;
            }
            db.BillingCategories.InsertOnSubmit(addBilling);
            db.SubmitChanges();
        }
Esempio n. 16
0
        public int DeleteData(BillingCategory billingCategory, DateTime period, int clientId = 0, int record = 0)
        {
            if (period == default)
            {
                throw new Exception("Missing parameter: Period");
            }

            if (period.Day != 1)
            {
                throw new Exception("Period must be the first day of the month.");
            }

            string recordParam;

            switch (billingCategory)
            {
            case BillingCategory.Tool:
                recordParam = "ResourceID";
                break;

            case BillingCategory.Room:
                recordParam = "RoomID";
                break;

            case BillingCategory.Store:
                recordParam = "ItemID";
                break;

            default:
                throw new NotImplementedException();
            }

            string sql = $"DELETE FROM {billingCategory}Data WHERE Period = @Period AND ClientID = ISNULL(@ClientID, ClientID) AND {recordParam} = ISNULL(@Record, {1})";

            int result = Session.Command(CommandType.Text)
                         .Param("Period", period)
                         .Param("ClientID", clientId > 0, clientId, DBNull.Value)
                         .Param("Record", record > 0, record, DBNull.Value)
                         .ExecuteNonQuery(sql).Value;

            return(result);
        }
Esempio n. 17
0
        public static int GetServiceUnitBillingNumber(DateTime period, BillingCategory billingCategory)
        {
            int yearoff  = period.Year - July2010.Year;
            int monthoff = period.Month - July2010.Month;

            int increment = (yearoff * 12 + monthoff) * 3;

            //263 is the starting number for room sub in July 2010
            if (billingCategory == BillingCategory.Tool)
            {
                return(263 + increment + 1);
            }
            else if (billingCategory == BillingCategory.Store)
            {
                return(263 + increment + 2);
            }
            else
            {
                return(263 + increment);
            }
        }
Esempio n. 18
0
        public WorkingWeek(ObjectId employeeId)
        {
            Id              = ObjectId.GenerateNewId();
            Project         = new Project();
            Activity        = new Activity();
            BillingCategory = new BillingCategory();
            EmployeeId      = employeeId;

            From = Utilities.GetMonday(DateTime.Today);
            To   = From.AddDays(6);

            WorkingDays = new List <WorkingDay>();

            for (var i = 0; i < 7; i++)
            {
                var workingDay = new WorkingDay(Id);
                WorkingDays.Add(workingDay);
            }

            Order = 1;
        }
Esempio n. 19
0
        public UpdateTablesResult UpdateTables(BillingCategory categories, UpdateDataType types = UpdateDataType.DataClean | UpdateDataType.Data)
        {
            DateTime startedAt = DateTime.Now;
            DateTime period    = startedAt.FirstOfMonth();

            //First, update tables
            UpdateResult updateResult = Provider.Billing.Process.Update(new UpdateCommand
            {
                BillingTypes = categories,
                UpdateTypes  = types,
                Period       = period,
                ClientID     = 0
            });

            var            holidays           = Utility.GetHolidays(period, period.AddMonths(1));
            var            isFirstBusinessDay = Utility.IsFirstBusinessDay(startedAt, holidays);
            FinalizeResult finalizeResult;

            //the daily update DOES produce correct data
            //however, if a change was made since the update, it needs to be caught
            if (isFirstBusinessDay)
            {
                finalizeResult = Finalize(period.AddMonths(-1));
            }
            else
            {
                finalizeResult = null;
            }

            var result = new UpdateTablesResult(startedAt)
            {
                Now                = startedAt,
                Period             = period,
                IsFirstBusinessDay = isFirstBusinessDay,
                FinalizeResult     = finalizeResult,
                UpdateResult       = updateResult
            };

            return(result);
        }
        public async Task <IActionResult> Create(BillingCategory billingCategory)
        {
            try
            {
                var cattobeAdded = await _billingRepository.InsertAsync(billingCategory);

                if (cattobeAdded != null)
                {
                    return(RedirectToAction(nameof(Categories)));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
Esempio n. 21
0
        public static int GetJournalUnitNumber(DateTime period, BillingCategory billingCategory, JournalUnitTypes juType)
        {
            int yearOff  = period.Year - July2010.Year;
            int monthOff = period.Month - July2010.Month;

            int increment = (yearOff * 12 + monthOff) * 6;

            //263 is the starting number for room sub in July 2010
            if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.A)
            {
                return(100 + increment);
            }
            else if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.B)
            {
                return(100 + increment + 1);
            }
            else if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.C)
            {
                return(100 + increment + 2);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.A)
            {
                return(100 + increment + 3);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.B)
            {
                return(100 + increment + 4);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.C)
            {
                return(100 + increment + 5);
            }
            else
            {
                throw new ArgumentException("Invalid arguments passed to LNF.Billing.Reports.ServiceUnitBilling.ReportSettings.GetJournalUnitNumber");
            }
        }
Esempio n. 22
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 19, Configuration.FieldSeparator),
                       Id,
                       PrimaryKeyValuePrc?.ToDelimitedString(),
                       FacilityIdPrc != null ? string.Join(Configuration.FieldRepeatSeparator, FacilityIdPrc.Select(x => x.ToDelimitedString())) : null,
                       Department != null ? string.Join(Configuration.FieldRepeatSeparator, Department.Select(x => x.ToDelimitedString())) : null,
                       ValidPatientClasses != null ? string.Join(Configuration.FieldRepeatSeparator, ValidPatientClasses.Select(x => x.ToDelimitedString())) : null,
                       Price != null ? string.Join(Configuration.FieldRepeatSeparator, Price.Select(x => x.ToDelimitedString())) : null,
                       Formula != null ? string.Join(Configuration.FieldRepeatSeparator, Formula) : null,
                       MinimumQuantity.HasValue ? MinimumQuantity.Value.ToString(Consts.NumericFormat, culture) : null,
                       MaximumQuantity.HasValue ? MaximumQuantity.Value.ToString(Consts.NumericFormat, culture) : null,
                       MinimumPrice?.ToDelimitedString(),
                       MaximumPrice?.ToDelimitedString(),
                       EffectiveStartDate.HasValue ? EffectiveStartDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       EffectiveEndDate.HasValue ? EffectiveEndDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       PriceOverrideFlag?.ToDelimitedString(),
                       BillingCategory != null ? string.Join(Configuration.FieldRepeatSeparator, BillingCategory.Select(x => x.ToDelimitedString())) : null,
                       ChargeableFlag,
                       ActiveInactiveFlag,
                       Cost?.ToDelimitedString(),
                       ChargeOnIndicator?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Esempio n. 23
0
        private string GenerateExcelJU(JournalUnitReportItem[] items, CreditEntry creditEntry, BillingCategory billingCategory, JournalUnitTypes juType)
        {
            //Contruct the excel object
            string fileName     = Utility.GetRequiredAppSetting("JU_Template");
            string templatePath = ExcelUtility.GetTemplatePath(fileName);

            using (var mgr = ExcelUtility.NewExcelManager())
            {
                mgr.OpenWorkbook(templatePath);
                mgr.SetActiveWorksheet("Sheet1");

                DateTime period = EndPeriod.AddMonths(-1);
                string   billingCategoryName = Utility.EnumToString(billingCategory);

                //We start at first row, because for ExcelLite control, the header row is not included

                // [2021-09-27 jg]
                //      source was previoulsy JU, now it is ENG (set in web.config)
                //      journalDescription was previously "JU {0} {1:MM/yy} {2} {3}{4}" now set in web.config
                string source            = Utility.GetRequiredAppSetting("JournalSource"); //ENG
                int    journalUnitNumber = ReportSettings.GetJournalUnitNumber(period, billingCategory, juType);
                // JournalDescription example: [email protected]; JU {0} {1:MM/yy} {2} {3}{4}
                string journalDescription = string.Format(
                    Utility.GetRequiredAppSetting("JournalDescription"),
                    /*0*/ journalUnitNumber,
                    /*1*/ period,
                    /*2*/ ReportSettings.CompanyName,
                    /*3*/ billingCategoryName,
                    /*4*/ Utility.EnumToString(juType)
                    );

                //column A
                mgr.SetCellTextValue(2, 0, "H");
                //column B
                mgr.SetCellTextValue(2, 1, "NEXT");
                //column C
                mgr.SetCellTextValue(2, 2, DateTime.Now.ToString("MM/dd/yyyy"));
                //column D
                mgr.SetCellTextValue(2, 3, source);
                //column E
                mgr.SetCellTextValue(2, 4, period.ToString("yyyy/MM"));
                //column F
                mgr.SetCellTextValue(2, 5, journalDescription);
                //column G
                mgr.SetCellTextValue(2, 6, ReportSettings.FinancialManagerUserName);

                int iRow = 3;
                int iCol = 7;

                //DataView dv = dt.DefaultView;
                //dv.Sort = "ItemDescription ASC, ProjectGrant ASC";
                foreach (JournalUnitReportItem item in items.Where(i => i.ItemDescription != $"zz{ReportSettings.FinancialManagerUserName}"))
                {
                    //column A
                    mgr.SetCellTextValue(iRow, 0, "L");
                    //column H
                    mgr.SetCellTextValue(iRow, iCol, item.Account);
                    //column I
                    mgr.SetCellTextValue(iRow, iCol + 1, item.FundCode);
                    //column J
                    mgr.SetCellTextValue(iRow, iCol + 2, item.DeptID);
                    //column K
                    mgr.SetCellTextValue(iRow, iCol + 3, item.ProgramCode);
                    //column L
                    mgr.SetCellTextValue(iRow, iCol + 4, item.Class);
                    //column M
                    mgr.SetCellTextValue(iRow, iCol + 5, item.ProjectGrant);
                    //column N
                    mgr.SetCellNumberValue(iRow, iCol + 6, string.IsNullOrEmpty(item.MerchandiseAmount) ? 0 : Convert.ToDouble(item.MerchandiseAmount));
                    //column O
                    mgr.SetCellTextValue(iRow, iCol + 7, item.DepartmentalReferenceNumber);
                    //column P
                    mgr.SetCellTextValue(iRow, iCol + 8, item.ItemDescription);
                    iRow += 1;
                }

                //Add the last row - which is the summary unit
                mgr.SetCellTextValue(iRow, 0, "L");
                mgr.SetCellTextValue(iRow, iCol, creditEntry.Account);
                mgr.SetCellTextValue(iRow, iCol + 1, creditEntry.FundCode);
                mgr.SetCellTextValue(iRow, iCol + 2, creditEntry.DeptID);
                mgr.SetCellTextValue(iRow, iCol + 3, creditEntry.ProgramCode);
                mgr.SetCellTextValue(iRow, iCol + 4, creditEntry.ClassName);
                mgr.SetCellTextValue(iRow, iCol + 5, creditEntry.ProjectGrant);
                mgr.SetCellNumberValue(iRow, iCol + 6, creditEntry.MerchandiseAmount);
                mgr.SetCellTextValue(iRow, iCol + 7, creditEntry.DepartmentalReferenceNumber); //should be davejd
                mgr.SetCellTextValue(iRow, iCol + 8, creditEntry.ItemDescription);             // should be MM/YY LNF UsageCase Subsidy;SUB#

                string workPathDir = ExcelUtility.GetWorkPath(CurrentUser.ClientID);

                if (!Directory.Exists(workPathDir))
                {
                    Directory.CreateDirectory(workPathDir);
                }

                string workFilePath = Path.Combine(workPathDir, "JU" + Enum.GetName(typeof(JournalUnitTypes), juType) + "_" + billingCategoryName + "_" + period.ToString("yyyy-MM") + Path.GetExtension(fileName));
                mgr.SaveAs(workFilePath);

                return(workFilePath);
            }
        }
Esempio n. 24
0
 /// <summary>
 /// Loads DataClean and Data tables with latest Tool, Room, and Store data. This does not load the Billing tables.
 /// </summary>
 public UpdateTablesResult Update(BillingCategory types)
 {
     return(_wd.UpdateTables(types));
 }
Esempio n. 25
0
        public static void ApplyMiscCharge(NHibernate.ISession session, DataTable dt, DataTable dtClientAccount, DateTime startPeriod, DateTime endPeriod, BillingCategory billingCategory, int clientId)
        {
            int primaryOrgId = 17;

            string billingCategoryName = Enum.GetName(typeof(BillingCategory), billingCategory);

            object queryParameters;

            if (clientId == 0)
            {
                queryParameters = new { Action = "GetAllByPeriodAndSUBTypeAndOrgID", StartPeriod = startPeriod, EndPeriod = endPeriod, SUBType = billingCategoryName, OrgID = primaryOrgId }
            }
            ;
            else
            {
                queryParameters = new { Action = "GetAllByPeriodAndSUBTypeAndOrgID", StartPeriod = startPeriod, EndPeriod = endPeriod, SUBType = billingCategoryName, OrgID = primaryOrgId, ClientID = clientId }
            };

            DataTable dtMisc = DataAccess.MiscBillingChargeSelect(session, queryParameters);

            DataRow ndr;

            DataRow[] rows;
            foreach (DataRow dr in dtMisc.Rows)
            {
                ndr = dt.NewRow();

                rows = dt.Select(string.Format("Period = '{0}' AND ClientID = {1} AND AccountID = {2}", dr["Period"], dr["ClientID"], dr["AccountID"]));

                if (rows.Length == 0)
                {
                    //This client and account has not been used in this month, so we have to add the entry to ClientAccountData
                    DataRow[] tempRows = dtClientAccount.Select(string.Format("Period = '{0}' AND ClientID = {1} AND AccountID = {2}", dr["Period"], dr["ClientID"], dr["AccountID"]));
                    if (tempRows.Length == 0)
                    {
                        DataRow ndrClientAccount = dtClientAccount.NewRow();
                        ndrClientAccount["Period"]    = dr["Period"];
                        ndrClientAccount["ClientID"]  = dr["ClientID"];
                        ndrClientAccount["AccountID"] = dr["AccountID"];
                        dtClientAccount.Rows.Add(ndrClientAccount);
                    }
                }

                ndr["Period"]      = dr["Period"];
                ndr["ClientID"]    = dr["ClientID"];
                ndr["AccountID"]   = dr["AccountID"];
                ndr["DisplayName"] = dr["DisplayName"];
                ndr["UserName"]    = dr["UserName"];

                if (dt.Columns.Contains("BillingTypeName"))
                {
                    ndr["BillingTypeName"] = "Miscellaneous";
                }

                ndr["Number"]    = dr["Number"];
                ndr["ShortCode"] = dr["ShortCode"];
                ndr["LineCost"]  = Utility.ConvertTo(dr["Quantity"], 0.0) * Utility.ConvertTo(dr["UnitCost"], 0.0);

                //it's possible store charge would come here
                try
                {
                    ndr["SubsidyDiscount"] = dr["SubsidyDiscount"];
                }
                catch { }

                dt.Rows.Add(ndr);
            }
        }
    }
Esempio n. 26
0
        public static void ApplyFilter(NHibernate.ISession session, DataTable dtClientAccount, BillingCategory billingCategory)
        {
            string filter;

            switch (billingCategory)
            {
            case BillingCategory.Store:
                //The only filter is 943777 account should be removed because it's also a credit account, but it's done in the main code already
                filter = "ShortCode = 943777";
                break;

            default:
                filter = string.Empty;
                break;
            }

            int accountId = 0;

            DataRow[] query = DataAccess.AccountSelect(session, new { Action = "GetAllNonBillingAccounts" }).Select(filter);

            foreach (DataRow dr in dtClientAccount.Rows)
            {
                accountId = dr.Field <int>("AccountID");
                DataRow acct = query.FirstOrDefault(x => x.Field <int>("AccountID") == accountId);
                if (acct != null)
                {
                    dr.Delete();
                }
            }
        }
 public int DeleteData(BillingCategory billingCategory, DateTime period, int clientId = 0, int record = 0)
 {
     using (DA.StartUnitOfWork())
         return(Provider.Billing.Process.DeleteData(billingCategory, period, clientId, record));
 }
Esempio n. 28
0
 public int DeleteData(BillingCategory billingCategory, DateTime period, int clientId = 0, int record = 0)
 {
     return(Delete("webapi/billing/process/data/{billingCategory}", UrlSegments(new { billingCategory }) & QueryStrings(new { period, clientId, record })));
 }
Esempio n. 29
0
        private IEnumerable <ManagerUsageDetailItem> GetManagerUsageDetailItemsByCategory(IEnumerable <IManagerUsageCharge> charges, BillingCategory billingCategory, bool aggregate)
        {
            IEnumerable <ManagerUsageDetailItem> result;

            if (aggregate)
            {
                result = charges
                         .Where(x => x.BillingCategory == billingCategory)
                         .GroupBy(x => new
                {
                    x.Period,
                    x.BillingCategory,
                    x.ManagerUserName,
                    x.UserLName,
                    x.UserFName,
                    x.ShortCode,
                    x.AccountNumber,
                    x.AccountName,
                    x.OrgName,
                    x.ChargeTypeID,
                    x.IsSubsidyOrg
                })
                         .ToList()
                         .Select(x => new ManagerUsageDetailItem()
                {
                    Period          = x.Key.Period,
                    BillingCategory = x.Key.BillingCategory,
                    ResourceID      = 0,
                    ResourceName    = $"{Enum.GetName(typeof(BillingCategory), x.Key.BillingCategory)} Charge",
                    UserName        = x.Key.ManagerUserName,
                    DisplayName     = Clients.GetDisplayName(x.Key.UserLName, x.Key.UserFName),
                    Account         = GetAccountName(x.Key.ShortCode, x.Key.AccountNumber, x.Key.AccountName, x.Key.OrgName),
                    ChargeTypeID    = x.Key.ChargeTypeID,
                    Sort            = x.Key.BillingCategory + ":" + GetAccountSort(x.Key.ShortCode, x.Key.AccountNumber, x.Key.AccountName, x.Key.OrgName),
                    TotalCharge     = x.Sum(g => g.TotalCharge),
                    SubsidyDiscount = x.Sum(g => g.SubsidyDiscount),
                    SubsidyOrg      = x.Key.IsSubsidyOrg
                }).ToList();
            }
            else
            {
                result = charges
                         .Where(x => x.BillingCategory == billingCategory)
                         .GroupBy(x => new
                {
                    x.Period,
                    x.BillingCategory,
                    x.ResourceID,
                    x.ResourceName,
                    x.ManagerUserName,
                    x.UserLName,
                    x.UserFName,
                    x.ShortCode,
                    x.AccountNumber,
                    x.AccountName,
                    x.OrgName,
                    x.ChargeTypeID,
                    x.IsSubsidyOrg
                })
                         .ToList()
                         .Select(x => new ManagerUsageDetailItem()
                {
                    Period          = x.Key.Period,
                    BillingCategory = x.Key.BillingCategory,
                    ResourceID      = x.Key.ResourceID,
                    ResourceName    = x.Key.ResourceName,
                    UserName        = x.Key.ManagerUserName,
                    DisplayName     = Clients.GetDisplayName(x.Key.UserLName, x.Key.UserFName),
                    Account         = GetAccountName(x.Key.ShortCode, x.Key.AccountNumber, x.Key.AccountName, x.Key.OrgName),
                    ChargeTypeID    = x.Key.ChargeTypeID,
                    Sort            = x.Key.BillingCategory + ":" + GetAccountSort(x.Key.ShortCode, x.Key.AccountNumber, x.Key.AccountName, x.Key.OrgName),
                    TotalCharge     = x.Sum(g => g.TotalCharge),
                    SubsidyDiscount = x.Sum(g => g.SubsidyDiscount),
                    SubsidyOrg      = x.Key.IsSubsidyOrg
                }).ToList();
            }

            return(result);
        }