Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        //   public static bool ViewReport(int month, int year)
        // {
        //first check to see if there is a summary file
        //    string[] myreport = { "" };
        //    string thismonth = getMonthName(month.ToString());
        //    string filename = year.ToString() + "_" + thismonth + ".txt";

        //    // first try to open the summary file
        //    try
        //    {
        //        myreport = FileSupport.ReadAllLines(@"c:/ooems/BillingFiles/MonthlySummaries/" + filename);

        //        return BillingSummary.DisplayBillingSummary(myreport);
        //    }
        //    // First catch a directory not found exception this means a directory does not exist for that location
        //    catch (DirectoryNotFoundException)
        //    {
        //        // Create directory.
        //        DirectoryInfo di = Directory.CreateDirectory(@"c:/ooems/BillingFiles/MonthlySummaries/");

        //        try
        //        {
        //            //If by some miracle that creating the directory and this call the file was placed there.
        //            myreport = FileSupport.ReadAllLines(@"c:/ooems/BillingFiles/MonthlySummaries/" + filename);
        //            return BillingSummary.DisplayBillingSummary(myreport);
        //        }
        //        // created the directory however the file does not exist, then we must read the response file, parse it, save the summary then
        //        // display the summary
        //        catch (FileNotFoundException)
        //        {
        //            try
        //            {
        //                myreport = FileSupport.ReadAllLines(@"c:/ooems/BillingFiles/MonthlyResponse/" + filename);

        //                BillingSummary.CalculateResponse(myreport, filename);
        //            }
        //            catch (FileNotFoundException)
        //            {
        //                Console.WriteLine("No response file found.\n");
        //                return false;
        //            }
        //            catch (Exception ex)
        //            {
        //                Console.WriteLine(ex.Message);
        //                return false;
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            Console.WriteLine(ex.Message);
        //            return false;
        //        }
        //    }
        //    // Basically does the same thing again as above
        //    catch (FileNotFoundException)
        //    {
        //        try
        //        {
        //            myreport = FileSupport.ReadAllLines(@"c:/ooems/BillingFiles/MonthlyResponse/" + filename);

        //            BillingSummary.CalculateResponse(myreport, filename);
        //        }
        //        catch
        //        {
        //            Console.WriteLine("No response file found.\n");
        //            return false;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex.Message);
        //        return false;
        //    }
        //    //this function always returns true.
        //    return true;
        //}

        /// <summary>
        /// Parses the billing record database, and pulls all of the records into a single monthly bill.
        /// </summary>
        /// <param name="month"> month for the bill to be made</param>
        private void GenerateMonthlyBillRecord()
        {
            // Billing accessor to add line to the
            BillingRecordsAccessor dal    = new BillingRecordsAccessor();
            BillingRecord          record = new BillingRecord();

            dal.InsertNewRecord(record);
        }
        public Task HandleAsync(OnCapitalBalanceChanged param)
        {
            BillingRecord billingRecord = new BillingRecord(
                _sequenceGenerator.Next("BR", new DateTimeSequenceAlgorithm()),
                param.AccountId,
                param.CapitalType,
                param.ChangedAmount,
                param.PayType,
                param.Desc,
                param.CardNo,
                param.BillingType,
                param.Balance);

            _billingRecordRepository.Insert(billingRecord);
            return(Task.FromResult(0));
        }
        public override async Task LoadResource()
        {
            this.user = await this.RequireUser();

            this.community = await this.Load <Community>(this.Id);

            this.member = await this.Load <Member>(m => m.UserId == this.user.Id && m.CommunityId == this.community.Id && m.State == MemberState.Active);

            if (this.member.Role != MemberRole.Manager)
            {
                throw new HttpError(HttpStatusCode.Forbidden);
            }

            if (this.community.BillingId == null)
            {
                throw new HttpError(HttpStatusCode.NotFound);
            }

            this.billing = await this.Load <BillingRecord>(this.community.BillingId);
        }
Ejemplo n.º 4
0
        public async Task Post()
        {
            var db    = Context.GetDatabase();
            var input = await Request.ReadJson <CommunityPutRequest>();

            var communityId = Guid.NewGuid().ToString();

            var populateDefaultBars = Request.Query.ContainsKey("populate_default_bars");

            var bar = new Bar()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Default",
                CommunityId = communityId,
                CreatedAt   = DateTime.Now,
                IsShared    = true
            };

            if (populateDefaultBars)
            {
                bar.Items = new BarItem[] {
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "label", "Email" },
                            { "image_url", "envelope-solid" },
                            { "url", "https://mail.google.com" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "label", "Calendar" },
                            { "image_url", "calendar-solid" },
                            { "url", "https://calendar.google.com" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "label", "Amazon" },
                            { "image_url", "amazon-brands" },
                            { "url", "https://amazon.com" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "label", "CNN" },
                            { "image_url", "newspaper-solid" },
                            { "url", "https://cnn.com" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Action,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "identifier", "screen-zoom" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "subkind", "skype" },
                            { "label", "Family Call" },
                            { "image_url", "video-solid" },
                            { "url", "https://join.skype.com/" },
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Action,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "identifier", "magnify" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Action,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "identifier", "volume" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Application,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "label", "Quick Assist" },
                            { "image_url", "question-solid" },
                            { "default", "quick-assist" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Action,
                        Configuration = new Dictionary <string, object?>()
                        {
                            { "identifier", "copy-paste" }
                        }
                    },
                };
            }
            await db.Save(bar);

            var plan = plans.Default;

            var memberId = Guid.NewGuid().ToString();

            var billing = new BillingRecord()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = communityId,
                PlanId      = plan.Id,
                // Trial if for 30 days, round it up to the end of the day.
                TrialEnd         = DateTime.Now.Date.AddDays(31).AddMinutes(-1),
                Status           = BillingStatus.Paid,
                ContactMemeberId = memberId
            };

            var community = new Community()
            {
                Id           = communityId,
                Name         = input.Name,
                DefaultBarId = bar.Id,
                CreatedAt    = DateTime.Now,
                BillingId    = billing.Id,
                MemberCount  = 0,
                MemberLimit  = plan.MemberLimit
            };
            await db.Save(community);

            await paymentProcessor.StartCommunitySubscription(community, billing, User);

            await db.Save(billing);

            // Everyone gets one free user, so we don't count this first one towards community.MemberCount
            var member = new Member()
            {
                Id          = memberId,
                CommunityId = community.Id,
                UserId      = User.Id,
                Role        = MemberRole.Manager,
                State       = MemberState.Active,
                CreatedAt   = DateTime.Now
            };

            member.FirstName.PlainText = User.FirstName?.PlainText;
            member.LastName.PlainText  = User.LastName?.PlainText;
            await db.Save(member);

            await Respond(new CommunityPutResponse()
            {
                Community = community
            });
        }
 public Task <Coupon?> ChangeCommunityCoupon(Community community, BillingRecord billing, string couponCode)
 {
     throw new NotImplementedException();
 }
 public Task ChangeCommunityCard(Community community, BillingRecord billing, object card)
 {
     ++ChangeCommunityCardCalls;
     return(Task.CompletedTask);
 }
 public Task ChangeCommunityContact(Community community, BillingRecord billing, User contact)
 {
     ++ChangeCommunityContactCalls;
     return(Task.CompletedTask);
 }
 public Task CancelCommunitySubscription(Community community, BillingRecord billing)
 {
     ++CancelCommunitySubscriptionCalls;
     return(Task.CompletedTask);
 }
 public Task StartCommunitySubscription(Community community, BillingRecord billing, User contact)
 {
     ++StartCommunitySubscriptionCalls;
     return(Task.CompletedTask);
 }
        private async Task CreateCommunity()
        {
            ManagerUserInfo = await CreateTestUser();

            OtherManagerUserInfo = await CreateTestUser();

            ActiveUserInfo = await CreateTestUser();

            InvitedUserInfo = await CreateTestUser();

            var communityId = Guid.NewGuid().ToString();
            var managerId   = Guid.NewGuid().ToString();

            DefaultBar = new Bar()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Default",
                IsShared    = true,
                CommunityId = communityId,
                CreatedAt   = DateTime.Now
            };
            await Database.Save(DefaultBar);

            Billing = new BillingRecord()
            {
                PlanId           = Server.Services.GetRequiredService <Plans>().Default.Id,
                TrialEnd         = DateTime.UnixEpoch.AddSeconds(1234567890.123),
                Status           = BillingStatus.Paid,
                CommunityId      = communityId,
                ContactMemeberId = managerId,
            };
            await Database.Save(Billing);

            Community = new Community()
            {
                Id           = communityId,
                Name         = "Test Community",
                DefaultBarId = DefaultBar.Id,
                BillingId    = Billing.Id
            };
            await Database.Save(Community);

            Manager = new Member()
            {
                Id          = managerId,
                CommunityId = Community.Id,
                UserId      = ManagerUserInfo.Id,
                State       = MemberState.Active,
                Role        = MemberRole.Manager
            };
            Manager.FirstName.PlainText = "Manager";
            Manager.LastName.PlainText  = "Tester";
            await Database.Save(Manager);

            OtherManager = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                UserId      = OtherManagerUserInfo.Id,
                State       = MemberState.Active,
                Role        = MemberRole.Manager
            };
            OtherManager.FirstName.PlainText = "Other";
            OtherManager.LastName.PlainText  = "Manager";
            await Database.Save(OtherManager);

            ActiveMember = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                UserId      = ActiveUserInfo.Id,
                State       = MemberState.Active,
                Role        = MemberRole.Member,
                BarId       = DefaultBar.Id
            };
            ActiveMember.FirstName.PlainText = "Active";
            ActiveMember.LastName.PlainText  = "Member";
            await Database.Save(ActiveMember);

            InvitedMember = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                UserId      = InvitedUserInfo.Id,
                State       = MemberState.Invited,
                Role        = MemberRole.Member
            };
            InvitedMember.FirstName.PlainText = "Invited";
            InvitedMember.LastName.PlainText  = "Person";
            await Database.Save(InvitedMember);
        }