Example #1
0
        private void FillSummaryGrid(BillingPeriod period)
        {
            var startDate             = period.startDate.ToString("dd.MM.yyyy");
            var endDate               = period.endDate.ToString("dd.MM.yyyy");
            var net                   = period.GetSumOfIncomes(Income.IncomeType.Salary);
            var incSum                = period.GetSumOfIncomes();
            var add                   = incSum - net;
            var expSum                = period.GetSumOfExpenses();
            var monthlyExpSum         = period.GetSumOfMonthlyExpenses();
            var dailyExpSum           = expSum - monthlyExpSum;
            var savings               = period.plannedSavings;
            var balance               = incSum - expSum - savings;
            var isActualBillingPeriod = (DateTime.Today - period.startDate).Days >= 0 && (period.endDate - DateTime.Today).Days >= 0;
            var daysLeft              = (period.endDate - DateTime.Today).Days + 1;
            var balanceWithoutToday   = balance + period.GetSumOfAllExpensesOfDate(DateTime.Today);
            var estimatedExpense      = isActualBillingPeriod ? Math.Round(balanceWithoutToday / daysLeft, 2) : Math.Round(balance, 2);
            var todayExpenses         = period.GetSumOfDailyExpensesOfDate(DateTime.Today);
            var todayExpensesPercent  = todayExpenses / estimatedExpense * 100;

            PeriodDatesTextBlock.Text           = "Podsumowanie dla " + startDate + "-" + endDate + ":";
            NetIncomeTextBlock.Text             = net.ToString("F") + " zł";
            AddIncomeTextBlock.Text             = add.ToString("F") + " zł";
            IncomeSumTextBlock.Text             = incSum.ToString("F") + " zł";
            IncomeSumTextBlock2.Text            = incSum.ToString("F") + " zł";
            DailyExpensesSumTextBlock.Text      = dailyExpSum.ToString("F") + " zł";
            MonthlyExpensesSumTextBlock.Text    = monthlyExpSum.ToString("F") + " zł";
            ExpensesSumTextBlock.Text           = expSum.ToString("F") + " zł";
            ExpensesSumTextBlock2.Text          = expSum.ToString("F") + " zł";
            PlannedSavingsTextBlock.Text        = savings.ToString("F") + " zł";
            BalanceTextBlock.Text               = (balance > 0 ? "+" : "") + balance.ToString("F") + " zł";
            DaysLeftTextBlock.Text              = isActualBillingPeriod ? daysLeft.ToString() : "-";
            EstimatedDailyExpenseTextBlock.Text = isActualBillingPeriod ? estimatedExpense.ToString("F") + " zł" : "-";
            SumOfTodayExpenses.Text             = isActualBillingPeriod ? todayExpenses.ToString("F") + " zł" : "-";
            PercentOfTodayExpenses.Text         = isActualBillingPeriod ? todayExpensesPercent.ToString("F0") + "%" : "-";
        }
Example #2
0
        public void FillTable(BillingPeriod period = null)
        {
            if (period != null)
            {
                billingPeriod = period;
            }
            else if (billingPeriod == null)
            {
                return;
            }

            foreach (var grid in new Grid[] { DaysGrid, DaySumsGrid, CategoriesGrid, CategorySumsGrid, ExpensesGrid })
            {
                grid.Children.Clear();
                grid.RowDefinitions.Clear();
                grid.ColumnDefinitions.Clear();
            }
            FillDaysGrid(DaysGrid, billingPeriod);
            FillDaySumsGrid(DaySumsGrid, billingPeriod);
            FillCategoriesGrid(CategoriesGrid);
            FillCategorySumsGrid(CategorySumsGrid, billingPeriod);
            FillExpensesGrid(ExpensesGrid, billingPeriod);

            if (isHeatMapEnabled)
            {
                GenerateHeatMap();
            }
        }
        public async Task PaymentSuccess(string tenantId, string tenantName, BillingPeriod billingPeriod, decimal amount, PaymentMethod paymentMethod, string planName)
        {
            //TODO: Should billing info be saved in default tenant only, in the tenant's db, or both ?

            // Retrieve settings for speficified tenant.
            var settingsList = await _shellSettingsManager.LoadSettingsAsync();

            if (settingsList.Any())
            {
                var settings   = settingsList.SingleOrDefault(s => string.Equals(s.Name, tenantName, StringComparison.OrdinalIgnoreCase));
                var shellScope = await _shellHost.GetScopeAsync(settings);

                await shellScope.UsingAsync(async scope =>
                {
                    //Check if billing history exists
                    var tenantBillingRepo    = scope.ServiceProvider.GetServices <ITenantBillingHistoryRepository>().FirstOrDefault();
                    var tenantBillingHistory = await tenantBillingRepo.GetTenantBillingDetailsByNameAsync(tenantName);
                    if (tenantBillingHistory == null)
                    {
                        tenantBillingHistory = new TenantBillingDetails(tenantId, tenantName, planName);
                    }

                    if (tenantBillingHistory.IsNewPaymentMethod(paymentMethod))
                    {
                        tenantBillingHistory.AddNewPaymentMethod(paymentMethod);
                    }

                    tenantBillingHistory.AddMonthlyBill(billingPeriod, PaymentStatus.Success, amount, paymentMethod.CreditCardInfo);



                    await tenantBillingRepo.CreateAsync(tenantBillingHistory);
                });
            }
        }
Example #4
0
        private void FillDaySumsGrid(Grid grid, BillingPeriod period)
        {
            var numOfDays = (period.endDate - period.startDate).Days + 1;

            AddColumnDefinitionsForDays(grid, numOfDays);

            AddWeekendsRectangles(grid, period);
            AddTodayRectangle(grid, period);

            for (var i = 0; i < numOfDays; i++)
            {
                var date     = period.startDate.AddDays(i);
                var sum      = period.GetSumOfDailyExpensesOfDate(date);
                var sumStr   = sum != 0 ? Decimal.Round(sum).ToString() : "";
                var txtBlock = new TextBlock
                {
                    Text                = sumStr,
                    Height              = rowHeight,
                    FontSize            = fontSize,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                AddUIElementToGrid(txtBlock, 0, i, grid);
            }

            AddStretchColumn(grid);
        }
Example #5
0
        private void FillDaysGrid(Grid grid, BillingPeriod period)
        {
            var numOfDays = (period.endDate - period.startDate).Days + 1;

            AddColumnDefinitionsForDays(grid, numOfDays);

            AddWeekendsRectangles(grid, period);
            AddTodayRectangle(grid, period);

            for (var i = 0; i < numOfDays; i++)
            {
                var date = period.startDate.AddDays(i);
                var btn  = new Button
                {
                    Content         = date.ToString("d.MM"),
                    BorderThickness = new Thickness(0),
                    Background      = Brushes.Transparent,
                    MaxWidth        = 40,
                    MinWidth        = 40,
                    Padding         = new Thickness(0)
                };
                btn.Click += (sender, e) =>
                {
                    _ = OpenExpensesListDialog(null, date);
                };
                AddUIElementToGrid(btn, 0, i, grid);

                if (i == 0)
                {
                    SetupTextBlocksBasedOnButton(btn);
                }
            }

            AddStretchColumn(grid);
        }
 public BillingPeriodDataItem(BillingPeriod bp)
 {
     startDate             = bp.startDate;
     endDate               = bp.endDate;
     incomes               = Utilities.EmptyIfZero(bp.GetSumOfIncomes(), " zł");
     plannedSavings        = Utilities.EmptyIfZero(bp.plannedSavings, " zł");
     originalBillingPeriod = bp;
 }
        public void CastFromBadString()
        {
            // Arrange
            const string invalid = "2015-04-12";

            // Act/Assert
            invalid.Invoking(i => { BillingPeriod p = i; }).ShouldThrow <InvalidCastException>();
        }
        public void EqualsOk()
        {
            BillingPeriod.CreatePeriod(2015, 4)
            .Should().Be(BillingPeriod.CreatePeriod(2015, 04));

            BillingPeriod.CreatePeriod(2015, 3)
            .Should().NotBe(BillingPeriod.CreatePeriod(2015, 04));
        }
Example #9
0
 public async Task <IEnumerable <ResourceUsageRate> > GetResourceUsageRates(BillingPeriod period)
 {
     return(await _context.ResourceUsageRates
            .Where(r => r.PeriodStart <= period.PeriodStart &&
                   r.PeriodEnd >= period.PeriodEnd)
            .Select(r => r)
            .ToListAsync());
 }
Example #10
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 49, Configuration.FieldSeparator),
                       Id,
                       ProviderProductServiceLineItemNumber?.ToDelimitedString(),
                       PayerProductServiceLineItemNumber?.ToDelimitedString(),
                       ProductServiceLineItemSequenceNumber.HasValue ? ProductServiceLineItemSequenceNumber.Value.ToString(culture) : null,
                       ProviderTrackingId?.ToDelimitedString(),
                       PayerTrackingId?.ToDelimitedString(),
                       ProductServiceLineItemStatus?.ToDelimitedString(),
                       ProductServiceCode?.ToDelimitedString(),
                       ProductServiceCodeModifier?.ToDelimitedString(),
                       ProductServiceCodeDescription,
                       ProductServiceEffectiveDate.HasValue ? ProductServiceEffectiveDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProductServiceExpirationDate.HasValue ? ProductServiceExpirationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProductServiceQuantity?.ToDelimitedString(),
                       ProductServiceUnitCost?.ToDelimitedString(),
                       NumberOfItemsPerUnit.HasValue ? NumberOfItemsPerUnit.Value.ToString(Consts.NumericFormat, culture) : null,
                       ProductServiceGrossAmount?.ToDelimitedString(),
                       ProductServiceBilledAmount?.ToDelimitedString(),
                       ProductServiceClarificationCodeType?.ToDelimitedString(),
                       ProductServiceClarificationCodeValue,
                       HealthDocumentReferenceIdentifier?.ToDelimitedString(),
                       ProcessingConsiderationCode?.ToDelimitedString(),
                       RestrictedDisclosureIndicator,
                       RelatedProductServiceCodeIndicator?.ToDelimitedString(),
                       ProductServiceAmountForPhysician?.ToDelimitedString(),
                       ProductServiceCostFactor.HasValue ? ProductServiceCostFactor.Value.ToString(Consts.NumericFormat, culture) : null,
                       CostCenter?.ToDelimitedString(),
                       BillingPeriod?.ToDelimitedString(),
                       DaysWithoutBilling.HasValue ? DaysWithoutBilling.Value.ToString(Consts.NumericFormat, culture) : null,
                       SessionNo.HasValue ? SessionNo.Value.ToString(Consts.NumericFormat, culture) : null,
                       ExecutingPhysicianId?.ToDelimitedString(),
                       ResponsiblePhysicianId?.ToDelimitedString(),
                       RoleExecutingPhysician?.ToDelimitedString(),
                       MedicalRoleExecutingPhysician?.ToDelimitedString(),
                       SideOfBody?.ToDelimitedString(),
                       NumberOfTpsPp.HasValue ? NumberOfTpsPp.Value.ToString(Consts.NumericFormat, culture) : null,
                       TpValuePp?.ToDelimitedString(),
                       InternalScalingFactorPp.HasValue ? InternalScalingFactorPp.Value.ToString(Consts.NumericFormat, culture) : null,
                       ExternalScalingFactorPp.HasValue ? ExternalScalingFactorPp.Value.ToString(Consts.NumericFormat, culture) : null,
                       AmountPp?.ToDelimitedString(),
                       NumberOfTpsTechnicalPart.HasValue ? NumberOfTpsTechnicalPart.Value.ToString(Consts.NumericFormat, culture) : null,
                       TpValueTechnicalPart?.ToDelimitedString(),
                       InternalScalingFactorTechnicalPart.HasValue ? InternalScalingFactorTechnicalPart.Value.ToString(Consts.NumericFormat, culture) : null,
                       ExternalScalingFactorTechnicalPart.HasValue ? ExternalScalingFactorTechnicalPart.Value.ToString(Consts.NumericFormat, culture) : null,
                       AmountTechnicalPart?.ToDelimitedString(),
                       TotalAmountProfessionalPartTechnicalPart?.ToDelimitedString(),
                       VatRate.HasValue ? VatRate.Value.ToString(Consts.NumericFormat, culture) : null,
                       MainService,
                       Validation,
                       Comment
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
 private void FillPage()
 {
     if (AppData.IsNotEmpty())
     {
         period  = AppData.billingPeriods.ElementAt(AppData.currentPeriod);
         nOfDays = (period.endDate - period.startDate).Days + 2;
         Plot();
     }
 }
        public static bool IsCompleted(this BillingPeriod billingPeriod)
        {
            if (billingPeriod == null)
            {
                return(false);
            }

            return(billingPeriod.End != null && billingPeriod.End <= DateTime.Now);
        }
Example #13
0
 public BillingDetails(string memberName, string subscriptionPlanName, BillingActivityVerb actionVerbPastTense, BillingPeriod billingPeriod, DateTime date, decimal amount = 0)
 {
     Amount               = amount;
     MemberName           = memberName;
     SubscriptionPlanName = subscriptionPlanName;
     ActionVerbPastTense  = actionVerbPastTense;
     BillingPeriod        = billingPeriod;
     Date = date;
 }
        public void Update(Int32 Id, DateTime OpenUntil)
        {
            BillingPeriod item = new BillingPeriod(Id);

            item.Openuntil = OpenUntil;

            item.MarkOld();

            item.Save(UserName);
        }
Example #15
0
        private void FillTable(BillingPeriod p)
        {
            var incomesCollection = new ObservableCollection <IncomeDataItem>();

            foreach (var inc in p.incomes)
            {
                incomesCollection.Add(new IncomeDataItem(inc));
            }
            IncomesDataGrid.ItemsSource = incomesCollection;
        }
        public ActionResult RemovePeriodTable(FormCollection frm)
        {
            int           parsedID = int.Parse(frm["ID"]);
            BillingPeriod period   = db.BillingPeriod.Find(parsedID);

            db.BillingPeriod.Remove(period);
            db.SaveChanges();
            SL.LogInfo(User.Identity.Name, Request.RawUrl, "Maintenance Period Table - Period Table Removed  - from Terminal: " + ipaddress);
            return(RedirectToAction("ViewPeriodTable"));
        }
Example #17
0
 public static BillingPeriodDto ToData(this BillingPeriod obj)
 {
     return(new BillingPeriodDto
     {
         GroupId = obj.GroupId,
         Id = obj.Id,
         PeriodBegin = obj.PeriodBegin,
         PeriodEnd = obj.PeriodEnd
     });
 }
Example #18
0
        public async Task <BillingPeriod> UpdateAsync(BillingPeriod item)
        {
            using (var uow = new UnitOfWork(_databaseContextProvider.Create()))
            {
                BillingPeriodDto operation = await uow.BillingPeriods.UpdateAsync(item.ToData());

                await uow.SaveChangesAsync();

                return(operation?.ToCore());
            }
        }
        public void CastFromString()
        {
            // Arrange
            string s = "2015-04";

            // Act
            BillingPeriod p = s;

            // Assert
            p.PeriodId.Should().Be("2015-04");
        }
        public void CastToString()
        {
            // Arrange
            BillingPeriod p = BillingPeriod.CreatePeriod(2015, 04);

            // Act
            string s = p;

            // Assert
            s.Should().Be("2015-04");
        }
Example #21
0
        public async Task HandleAsync(UserMessageInfo userMessageInfo)
        {
            ReceiptMainInfo data = userMessageInfo.Message.ReceiptInfo;

            if (data == null)
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.ParsePhotoError, true);

                Logger.Trace(Resources.ParsePhotoError);
                return;
            }

            BillingPeriod lastBillingPeriod = await _billingPeriodService.GetLastByGroupIdAsync(userMessageInfo.Group.Id);

            if (lastBillingPeriod == null)
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.BillingPeriodNotCreated, true);

                return;
            }

            var receipt = new Receipt
            {
                BillingPeriodId = lastBillingPeriod.Id,
                TotalAmount     = data.TotalAmount,
                FiscalSign      = data.FiscalSign,
                FiscalDocument  = data.FiscalDocument,
                FiscalNumber    = data.FiscalNumber,
                PurchaseTime    = data.PurchaseTime,
                Status          = ReceiptStatus.New,
                Comment         = "Чек",
            };

            if (await ReceiptService.IsReceiptExists(receipt))
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.ReceiptAlredyAdded, true);

                return;
            }

            var newReceipt = await ReceiptService.AddAsync(receipt);

            IMenu menu = MenuProvider.GetMenu(userMessageInfo, new AddReceiptQueryData
            {
                MenuType            = MenuType.NewReceiptSelectCustomer,
                ReceiptId           = newReceipt.Id,
                SelectedCustomerId  = null,
                SelectedConsumerIds = new long[0],
                TargetId            = null,
                Version             = AddReceiptQueryData.ServerVersion,
            });
            await Messenger.SendMessageAsync(userMessageInfo, Resources.SelectCustomer, true, menu);
        }
Example #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReconciliationLineItemCollectionOperations"/> class.
        /// </summary>
        /// <param name="rootPartnerOperations">The partner operations.</param>
        /// <param name="invoiceId">The invoice identifier.</param>
        /// <param name="billingProvider">The billing provider type.</param>
        /// <param name="invoiceLineItemType">The invoice line item type.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <param name="period">The period for unbilled recon.</param>
        /// <param name="size">The page size.</param>
        public ReconciliationLineItemCollectionOperations(IPartner rootPartnerOperations, string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType, string currencyCode, BillingPeriod period, int?size = null)
            : base(rootPartnerOperations, invoiceId)
        {
            invoiceId.AssertNotEmpty(nameof(invoiceId));
            currencyCode.AssertNotEmpty(nameof(currencyCode));

            this.billingProvider     = billingProvider;
            this.currencyCode        = currencyCode;
            this.invoiceLineItemType = invoiceLineItemType;
            pageSize    = size ?? maxPageSizeReconLineItems;
            this.period = period;
        }
Example #23
0
        private static BillingPeriod SetBillingPeriod(this BillingPeriod billingPeriod, DateTime start, DateTime end)
        {
            if (billingPeriod == null)
            {
                billingPeriod = new BillingPeriod()
                {
                    Begin = start,
                    End   = end
                };
            }

            return(billingPeriod);
        }
Example #24
0
 private void AddTodayRectangle(Grid grid, BillingPeriod period)
 {
     if (DateTime.Today.Date > period.endDate.Date)
     {
         return;
     }
     var row     = 0;
     var rowSpan = grid.RowDefinitions.Count + 1;
     var col     = (DateTime.Now - period.startDate).Days;
     var colSpan = 1;
     var fill    = (Brush)FindResource("Alpha-Green");
     var rect    = AddRectangleAt(row, col, rowSpan, colSpan, fill, grid);
 }
Example #25
0
        private void PrepareForm()
        {
            cboBillingPeriod.DataSource    = BillingPeriod.GetBillingPeriods();
            cboBillingPeriod.DisplayMember = "Name";
            cboBillingPeriod.ValueMember   = "PeriodId";

            cboCurrency.DataSource    = CurrenciesRepo.GetAll();
            cboCurrency.DisplayMember = "Name";
            cboCurrency.ValueMember   = "Id";

            cboSettlementModel.DataSource    = SettlementModelsRepo.GetAll();
            cboSettlementModel.DisplayMember = "Name";
            cboSettlementModel.ValueMember   = "Id";
        }
Example #26
0
        public static string ToDisplayText(this BillingPeriod billingPeriod)
        {
            switch (billingPeriod)
            {
            case BillingPeriod.Month: return("monthly");

            case BillingPeriod.Quarter: return("quarterly");

            case BillingPeriod.Week: return("weekly");

            case BillingPeriod.Year: return("annually");
            }

            return(string.Empty);
        }
Example #27
0
        public void TestToFormatedString()
        {
            var target = new BillingPeriod()
            {
                Begin = new DateTime(2017, 1, 2, 3, 4, 5, DateTimeKind.Local),
                End   = null
            };

            Assert.IsFalse(target.IsCompleted());

            target.End = DateTime.Now.AddYears(1);
            Assert.IsFalse(target.IsCompleted());

            target.End = DateTime.Now.AddDays(-3);
            Assert.IsTrue(target.IsCompleted());
        }
Example #28
0
        public static BillingPeriod NewBillingPeriod(AptMgmtDbContext context)
        {
            var period   = new BillingPeriod();
            var timeSpan = new TimeSpan(0, 0, 5);

            // All test data is 2 years into the future.
            var testPeriod = new TimeSpan(730, 0, 0, 0);

            period.PeriodStart = DateTime.Now + testPeriod - timeSpan;
            period.PeriodEnd   = DateTime.Now + testPeriod + timeSpan;

            context.Add(period);
            context.SaveChanges();

            return(period);
        }
Example #29
0
        public async Task <IEnumerable <Payment> > GetPayments(int tenantId,
                                                               ResourceType resource,
                                                               BillingPeriod period)
        {
            if (period == null)
            {
                return(new List <Payment>());
            }

            return(await _context.Payments
                   .Where(p => p.TenantId == tenantId)
                   .Where(p => p.ResourceType == resource)
                   .Where(p => p.BillingPeriodId == period.BillingPeriodId)
                   .Select(p => p)
                   .ToListAsync());
        }
Example #30
0
        public BillingPeriodPage(ContentDialog dialog, BillingPeriod p)
        {
            InitializeComponent();
            parent = dialog;
            period = p;

            if (p != null)
            {
                FillForExistingPeriod(p);
            }
            else
            {
                FillForNewPeriod();
            }
            SetupButtons();
        }
Example #31
0
 public UserBillingViewModel(List <BillingActivity> billingActivities,
                             int totalSubscribedDays,
                             string subscriptionPlanName,
                             BillingPeriod billingPeriod,
                             DateTime currentSubscriptionEndDate,
                             DateTime graduationDate,
                             MemberSubscription currentSubscription)
 {
     BillingActivities          = billingActivities;
     TotalSubscribedDays        = totalSubscribedDays;
     SubscriptionPlanName       = subscriptionPlanName;
     BillingPeriod              = billingPeriod;
     CurrentSubscriptionEndDate = currentSubscriptionEndDate;
     GraduationDate             = graduationDate;
     CurrentSubscription        = currentSubscription;
 }
	    public void Insert(int Month,int Year,DateTime Openuntil,bool IsDeleted,DateTime? CreatedOn,string CreatedBy,DateTime? ModifiedOn,string ModifiedBy)
	    {
		    BillingPeriod item = new BillingPeriod();
		    
            item.Month = Month;
            
            item.Year = Year;
            
            item.Openuntil = Openuntil;
            
            item.IsDeleted = IsDeleted;
            
            item.CreatedOn = CreatedOn;
            
            item.CreatedBy = CreatedBy;
            
            item.ModifiedOn = ModifiedOn;
            
            item.ModifiedBy = ModifiedBy;
            
	    
		    item.Save(UserName);
	    }