Exemple #1
0
 public Client(PhoneNumberStruct phoneNumber, String userName, IBillingType billingType, DateTime billingChangeDate)
 {
     _phoneNumber = phoneNumber;
     _userName = userName;
     _billingType = billingType;
     _billingChangeDate = billingChangeDate;
 }
Exemple #2
0
 public CallStatisticsItem(PhoneNumberStruct phoneSource, PhoneNumberStruct phoneDestination, IBillingType billingType, DateTime startTimeCall, DateTime finishTimeCall)
 {
     _phoneSource = phoneSource;
     _phoneDestination = phoneDestination;
     _billingType = billingType;
     _startTimeCall = startTimeCall;
     _finishTimeCall = finishTimeCall;
 }
Exemple #3
0
 public void SetNewBillingType(PhoneNumberStruct number,IBillingType billingType, DateTime billingChangeDate)
 {
     var clientBuff = _clients.FirstOrDefault(x=>x.PhoneNumber == number);
     if (clientBuff != null)
     {
         clientBuff.SetNewBillingType(billingType,billingChangeDate);
     }
 }
Exemple #4
0
        public void AddPort(PBXPort item, String name, IBillingType billing )
        {
            _pbxPorts.Add(item);
            _pbxPorts.Last().ConnectingTo += ConnectingToHandler;
            _pbxPorts.Last().EndedCall += EndedCallHandler;
            _pbxPorts.Last().Answered += AnsweredHandler;

            _billingSystem.AddClient(new Client(item.PhoneNumber, name, billing, System.DateTime.Now));
        }
Exemple #5
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;
 }
Exemple #6
0
 public void SetNewBillingType(IBillingType billingType, DateTime billingChangeDate)
 {
     if (billingType != null)
     {
         if ((billingChangeDate - _billingChangeDate).TotalDays > 30)
         {
             _billingType = billingType;
             _billingChangeDate = billingChangeDate;
         }
     }
 }
 public void TestBillAfterFixedThisWeek()
 {
     bill = new Bill {
         Id = 1, CompanyId = 1, Date = new DateTime(2018, 12, 10), Amount = 100, Number = 1.ToString()
     };
     billingType = new BillAfterFixed(1, false);
     Assert.AreEqual(new DateTime(2018, 12, 10), billingType.GetFirstDate(bill.Date));
     Assert.AreEqual(new DateTime(2018, 12, 11), billingType.GetLastDate(bill.Date));
     billingType = new BillAfterFixed(4, false);
     Assert.AreEqual(new DateTime(2018, 12, 14), billingType.GetLastDate(bill.Date));
     billingType = new BillAfterFixed(4, true);
     Assert.AreEqual(new DateTime(2018, 12, 14), billingType.GetLastDate(bill.Date));
 }
Exemple #8
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));
        }
Exemple #9
0
 public static string GetBillingTypeName(IBillingType billingType)
 {
     if (billingType == Instance.ExtAc_Ga)
     {
         return("External Academic GaAs");
     }
     else if (billingType == Instance.ExtAc_Hour)
     {
         return("External Academic Hour");
     }
     else if (billingType == Instance.ExtAc_Si)
     {
         return("External Academic Si");
     }
     else if (billingType == Instance.ExtAc_Tools)
     {
         return("External Academic Tools");
     }
     else if (billingType == Instance.Int_Ga)
     {
         return("Internal Academic GaAs");
     }
     else if (billingType == Instance.Int_Hour)
     {
         return("Internal Academic Hour");
     }
     else if (billingType == Instance.Int_Si)
     {
         return("Internal Academic Si");
     }
     else if (billingType == Instance.Int_Tools)
     {
         return("Internal Academic Tools");
     }
     else if (billingType == Instance.NonAc)
     {
         return("Non Academic");
     }
     else if (billingType == Instance.NonAc_Hour)
     {
         return("Non Academic Hour");
     }
     else
     {
         return("Other");
     }
 }
Exemple #10
0
        public static IBillingType GetBillingType(this ISession session, int clientId, int accountId, DateTime period)
        {
            // always add one more month for @Period, because we allow changes made during the current month that will take effect
            // as long as it's before the 4th business day of business
            // 2011-01-26 the above statement is not quite right.  We should not allow change after the Period.  if a change is made on 2011-01-04, it has nothing
            // to do with period = 2010-12-01
            //set @Period = dbo.udf_BusinessDate (DATEADD(MONTH, 1, @Period), null)

            DateTime sd = period;
            DateTime ed = sd.AddMonths(1);

            var client = session.Require <Client>(clientId);
            var acct   = session.Require <Account>(accountId);

            int          record = 0;
            IBillingType result = null;

            var clientOrgs     = session.Query <ClientOrg>().Where(x => x.Client == client && x.Org == acct.Org).FindActive(x => x.ClientOrgID, sd, ed, session.Query <ActiveLog>().Where(x => x.TableName == "ClientOrg"));
            var clientAccounts = session.Query <ClientAccount>().Where(x => x.ClientOrg.Client == client && x.Account == acct).FindActive(x => x.ClientAccountID, sd, ed, session.Query <ActiveLog>().Where(x => x.TableName == "ClientAccount"));
            var clientRemotes  = session.Query <ClientRemote>().Where(x => x.Client == client && x.Account == acct).FindActive(x => x.ClientRemoteID, sd, ed, session.Query <ActiveLog>().Where(x => x.TableName == "ClientRemote"));
            var co             = clientOrgs.FirstOrDefault(x => x.Client == client && x.Org == acct.Org);

            if (co != null)
            {
                //is null for remote runs
                ClientAccount ca = clientAccounts.FirstOrDefault(x => x.ClientOrg == co && x.Account == acct);
                if (ca != null)
                {
                    record = ca.ClientAccountID;
                }
            }

            if (record == 0)
            {
                ClientRemote cr = clientRemotes.FirstOrDefault(x => x.Client == client && x.Account == acct);
                if (cr != null)
                {
                    record = cr.ClientRemoteID;
                }
                if (record == 0)
                {
                    result = BillingTypes.Instance.RegularException;
                }
                else
                {
                    result = BillingTypes.Instance.Remote;
                }
            }
            else
            {
                ClientOrgBillingTypeLog cobtlog = null;

                if (co != null)
                {
                    var cobtLogs = session.ActiveClientOrgBillingTypeLogQuery(sd, ed).Where(x => x.ClientOrgID == co.ClientOrgID).ToArray();
                    cobtlog = cobtLogs.FirstOrDefault(x => x.ClientOrgID == co.ClientOrgID);
                }

                if (cobtlog != null)
                {
                    result = session.Require <BillingType>(cobtlog.BillingTypeID);
                }
                if (result == null)
                {
                    result = BillingTypes.Instance.Regular;
                }
            }

            return(result);
        }
 public void TestBillBefore()
 {
     billingType = new BillBefore();
     Assert.AreEqual(bill.Date, billingType.GetFirstDate(bill.Date));
     Assert.AreEqual(bill.Date, billingType.GetLastDate(bill.Date));
 }
Exemple #12
0
 public void SetNewBillingType(PhoneNumberStruct number, IBillingType billingType)
 {
     _billingSystem.SetNewBillingType(number,billingType,System.DateTime.Now);
 }