Exemple #1
0
        private DataRow MakeProviderBalanceDataRow(DateTime date, DataTable SourceSchema,
                                                   System.Collections.Hashtable htProvBalance,
                                                   System.Collections.Hashtable htCumulativeBalance,
                                                   string [] subcols, List <int> ProviderNums)
        {
            //MakeDTRow;
            DataRow dr3 = SourceSchema.NewRow();

            dr3[0] = date.ToShortDateString();
            for (int j = 0; j < ProviderNums.Count; j++)
            {
                object          o1            = htProvBalance["3"];
                ProviderBalance pb            = (ProviderBalance)htProvBalance[ProviderNums[j]];
                ProviderBalance pb_Cumulative = (ProviderBalance)htCumulativeBalance[ProviderNums[j]];
                for (int k = 0; k < subcols.Length - 1; k++)
                {
                    if (pb.Ammounts[k] != 0)
                    {
                        dr3[2 + j * 5 + k] = pb.Ammounts[k];
                    }
                }
                dr3[2 + j * 5 + subcols.Length - 1] = pb_Cumulative.BALANCE;
            }


            return(dr3);
        }
Exemple #2
0
        public int CompareTo(object obj)
        {
            ProviderBalance that = (ProviderBalance)obj;

            if (this.Date_of_Balance == that.Date_of_Balance)
            {
                return(this.ProvNum.CompareTo(that.ProvNum));
            }
            else
            {
                return(this.Date_of_Balance.CompareTo(that.Date_of_Balance));
            }
        }
Exemple #3
0
        /// <summary>
        /// Give returned value the date of the left hand operand. Exception if ProvNums are not the same
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        public static ProviderBalance operator +(ProviderBalance p1, ProviderBalance p2)
        {
            if (p1.ProvNum != p2.ProvNum)
            {
                PU.Ex = "Provider numbers not the same when operand + was applied to ProviderBalance Type";
            }
            ProviderBalance rVal = new ProviderBalance(p1.ProvNum, p1.Date_of_Balance);

            for (int i = 0; i < rVal.Ammounts.Length; i++)
            {
                rVal.Ammounts[i] = p1.Ammounts[i] + p2.Ammounts[i];
            }
            return(rVal);
        }
		/// <summary>
		/// Give returned value the date of the left hand operand. Exception if ProvNums are not the same
		/// </summary>
		/// <param name="p1"></param>
		/// <param name="p2"></param>
		/// <returns></returns>
		public static ProviderBalance operator + (ProviderBalance p1, ProviderBalance p2)
		{
			if (p1.ProvNum != p2.ProvNum)
				PU.Ex = "Provider numbers not the same when operand + was applied to ProviderBalance Type";
			ProviderBalance rVal = new ProviderBalance(p1.ProvNum, p1.Date_of_Balance);
			for (int i = 0; i < rVal.Ammounts.Length; i++)
				rVal.Ammounts[i] = p1.Ammounts[i] + p2.Ammounts[i];
			return rVal;
		}
		/// <summary>
		/// Provides a data table that gives a running balance for each provider.
		/// 
		/// Will run the EqualizeGuarantorPayments(guarantor) first if this instance has not 
		/// done so yet.
		/// 
		/// // Setup DataTable  
		/// 
		/// Date				   Provider #							 	      Provider #
		///			   Charges  Payments  Adjustments  Balances	    Charges  Payments  Adjustments Balances
		/// [ 0   ][1][   2   ][   3    ][     4     ][    5   ][6][    7  ][    8   ][  etc......  
		/// </summary>
		/// <param name="uGuarantor"></param>
		/// <returns></returns>
		public DataTable ProviderBalancesDetail()//uint uGuarantor)
		{
			DataTable dt = new DataTable();
			string [] cols = {"Date","Provider"};
			string[] subcols = { "Charges", "Payments", "Adjustment", "Balance" };
			if (Ledger == null)
				PU.Ex = "Guarantor not set in " + PU.Method;
			if (!Ledger.IS_FILLED)
				Ledger.Fill(false);			
			if (!Ledger.IS_EQUALIZED)
				Ledger.EqualizePaymentsV2();
			if (!Ledger.IS_FILLED || !Ledger.IS_EQUALIZED)
			{
				dt.Columns.Add("ERROR");
				dt.Rows.Add(dt.NewRow()[0] = "Error Getting table filled");
				return dt;
			}
			Ledger.FullLedger.Sort();

			// Generate List of Providers
			List<int> ProviderNums = new List<int>();
			foreach (PP_LedgerItem li in Ledger.FullLedger)
			{
				if (li is PP_PaymentItem)
				{
					foreach (PP_PaySplitItem psi in ((PP_PaymentItem)li).PAYMENT_SPLITS)
						if (!ProviderNums.Contains(psi.PROVNUM))
							ProviderNums.Add(psi.PROVNUM);
				}
				else
					if (!ProviderNums.Contains(li.PROVNUM))
						ProviderNums.Add(li.PROVNUM);
			}
			// Setup DataTable  
			/// 
			/// Date				   Provider #							 	      Provider #
			///			   Charges  Payments  Adjustments  Balances	    Charges  Payments  Adjustments Balances
			/// [ 0   ][1][   2   ][   3    ][     4     ][    5   ][6][    7  ][    8   ][  etc......  
			dt.Columns.Add(new DataColumn("Date"));
			System.Collections.Hashtable ht_dtProvNumOffsets = new System.Collections.Hashtable();
			for (int i = 0; i < ProviderNums.Count; i++)
			{
				dt.Columns.Add(new DataColumn("")); // Blank Column
				dt.Columns.Add(new DataColumn(""));
				dt.Columns.Add(new DataColumn(""));
				dt.Columns.Add(new DataColumn());
				dt.Columns.Add(new DataColumn(""));
				

			}
			// Add Header Rows
			DataRow dr1 = dt.NewRow();
			DataRow dr2 = dt.NewRow();
			dr2[0] = "Date";
			for (int i = 0; i < ProviderNums.Count; i++)
			{
				dr1[3+5*i] = "Provider";
				dr1[4+5*i] = "# " + ProviderNums[i].ToString() ;
				for (int j = 0; j < subcols.Length; j++)
					dr2[2 + 5 * i + j] = subcols[j]; // Charges, Payments, Adjustments, Balances
			}
			dt.Rows.Add(dr1);
			dt.Rows.Add(dr2);

			// Generate Provider Balances
			System.Collections.Hashtable htProvBalance = new System.Collections.Hashtable();
			System.Collections.Hashtable htProvBalance_Cummulative = new System.Collections.Hashtable();
			DateTime curDate = DateTime.MinValue;
			if (Ledger.FullLedger.Count != 0)
				curDate = Ledger.FullLedger[0].ITEMDATE;
			foreach (int ProvNum in ProviderNums)
			{
				htProvBalance[ProvNum] = new ProviderBalance(ProvNum, curDate);
				htProvBalance_Cummulative[ProvNum] = new ProviderBalance(ProvNum, curDate);
			}



			for (int i = 0; i < Ledger.FullLedger.Count; i++)
			{
				PP_LedgerItem li = Ledger.FullLedger[i];


				#region Making the DataRow
				if (curDate < li.ITEMDATE || i == Ledger.FullLedger.Count - 1)
				{

					DataRow dr3 = this.MakeProviderBalanceDataRow(curDate, dt, htProvBalance, htProvBalance_Cummulative, subcols, ProviderNums);
					dt.Rows.Add(dr3);

					foreach (int ProvNum in ProviderNums)
					{
						htProvBalance[ProvNum] = new ProviderBalance(ProvNum, li.ITEMDATE);
						((ProviderBalance)htProvBalance_Cummulative[ProvNum]).Date_of_Balance = li.ITEMDATE;
					}
					curDate = li.ITEMDATE;
				}
				#endregion

				#region Calculate Balances
				if (li is PP_PaymentItem)
				{
					foreach (PP_PaySplitItem psi in ((PP_PaymentItem)li).PAYMENT_SPLITS)
					{
						ProviderBalance pb = (ProviderBalance)htProvBalance[psi.PROVNUM];
						ProviderBalance pb_Cumulative = (ProviderBalance)htProvBalance_Cummulative[psi.PROVNUM];
						pb.Ammounts[(int)li.ITEMTYPE] += psi.AMMOUNT;
						pb_Cumulative.Ammounts[(int)li.ITEMTYPE] += psi.AMMOUNT;
					}
				}
				else
				{
					ProviderBalance pb = (ProviderBalance)htProvBalance[li.PROVNUM];
					ProviderBalance pb_Cumulative = (ProviderBalance)htProvBalance_Cummulative[li.PROVNUM];
					pb.Ammounts[(int)li.ITEMTYPE] += li.AMMOUNT;
					pb_Cumulative.Ammounts[(int)li.ITEMTYPE] += li.AMMOUNT;
				}

				#endregion

				
			}
			#region Adding the End DataRow
			
			{
				DataRow dr3 = this.MakeProviderBalanceDataRow(curDate,dt, htProvBalance, htProvBalance_Cummulative, subcols, ProviderNums);
				dt.Rows.Add(dr3);
			}
			#endregion

			return dt;
		}
Exemple #6
0
        /// <summary>
        /// Provides a data table that gives a running balance for each provider.
        ///
        /// Will run the EqualizeGuarantorPayments(guarantor) first if this instance has not
        /// done so yet.
        ///
        /// // Setup DataTable
        ///
        /// Date				   Provider #							          Provider #
        ///			   Charges  Payments  Adjustments  Balances	    Charges  Payments  Adjustments Balances
        /// [ 0   ][1][   2   ][   3    ][     4     ][    5   ][6][    7  ][    8   ][  etc......
        /// </summary>
        /// <param name="uGuarantor"></param>
        /// <returns></returns>
        public DataTable ProviderBalancesDetail()        //uint uGuarantor)
        {
            DataTable dt = new DataTable();

            string [] cols    = { "Date", "Provider" };
            string[]  subcols = { "Charges", "Payments", "Adjustment", "Balance" };
            if (Ledger == null)
            {
                PU.Ex = "Guarantor not set in " + PU.Method;
            }
            if (!Ledger.IS_FILLED)
            {
                Ledger.Fill(false);
            }
            if (!Ledger.IS_EQUALIZED)
            {
                Ledger.EqualizePaymentsV2();
            }
            if (!Ledger.IS_FILLED || !Ledger.IS_EQUALIZED)
            {
                dt.Columns.Add("ERROR");
                dt.Rows.Add(dt.NewRow()[0] = "Error Getting table filled");
                return(dt);
            }
            Ledger.FullLedger.Sort();

            // Generate List of Providers
            List <int> ProviderNums = new List <int>();

            foreach (PP_LedgerItem li in Ledger.FullLedger)
            {
                if (li is PP_PaymentItem)
                {
                    foreach (PP_PaySplitItem psi in ((PP_PaymentItem)li).PAYMENT_SPLITS)
                    {
                        if (!ProviderNums.Contains(psi.PROVNUM))
                        {
                            ProviderNums.Add(psi.PROVNUM);
                        }
                    }
                }
                else
                if (!ProviderNums.Contains(li.PROVNUM))
                {
                    ProviderNums.Add(li.PROVNUM);
                }
            }
            // Setup DataTable
            ///
            /// Date				   Provider #							          Provider #
            ///			   Charges  Payments  Adjustments  Balances	    Charges  Payments  Adjustments Balances
            /// [ 0   ][1][   2   ][   3    ][     4     ][    5   ][6][    7  ][    8   ][  etc......
            dt.Columns.Add(new DataColumn("Date"));
            System.Collections.Hashtable ht_dtProvNumOffsets = new System.Collections.Hashtable();
            for (int i = 0; i < ProviderNums.Count; i++)
            {
                dt.Columns.Add(new DataColumn(""));                 // Blank Column
                dt.Columns.Add(new DataColumn(""));
                dt.Columns.Add(new DataColumn(""));
                dt.Columns.Add(new DataColumn());
                dt.Columns.Add(new DataColumn(""));
            }
            // Add Header Rows
            DataRow dr1 = dt.NewRow();
            DataRow dr2 = dt.NewRow();

            dr2[0] = "Date";
            for (int i = 0; i < ProviderNums.Count; i++)
            {
                dr1[3 + 5 * i] = "Provider";
                dr1[4 + 5 * i] = "# " + ProviderNums[i].ToString();
                for (int j = 0; j < subcols.Length; j++)
                {
                    dr2[2 + 5 * i + j] = subcols[j];                     // Charges, Payments, Adjustments, Balances
                }
            }
            dt.Rows.Add(dr1);
            dt.Rows.Add(dr2);

            // Generate Provider Balances
            System.Collections.Hashtable htProvBalance             = new System.Collections.Hashtable();
            System.Collections.Hashtable htProvBalance_Cummulative = new System.Collections.Hashtable();
            DateTime curDate = DateTime.MinValue;

            if (Ledger.FullLedger.Count != 0)
            {
                curDate = Ledger.FullLedger[0].ITEMDATE;
            }
            foreach (int ProvNum in ProviderNums)
            {
                htProvBalance[ProvNum]             = new ProviderBalance(ProvNum, curDate);
                htProvBalance_Cummulative[ProvNum] = new ProviderBalance(ProvNum, curDate);
            }



            for (int i = 0; i < Ledger.FullLedger.Count; i++)
            {
                PP_LedgerItem li = Ledger.FullLedger[i];


                #region Making the DataRow
                if (curDate < li.ITEMDATE || i == Ledger.FullLedger.Count - 1)
                {
                    DataRow dr3 = this.MakeProviderBalanceDataRow(curDate, dt, htProvBalance, htProvBalance_Cummulative, subcols, ProviderNums);
                    dt.Rows.Add(dr3);

                    foreach (int ProvNum in ProviderNums)
                    {
                        htProvBalance[ProvNum] = new ProviderBalance(ProvNum, li.ITEMDATE);
                        ((ProviderBalance)htProvBalance_Cummulative[ProvNum]).Date_of_Balance = li.ITEMDATE;
                    }
                    curDate = li.ITEMDATE;
                }
                #endregion

                #region Calculate Balances
                if (li is PP_PaymentItem)
                {
                    foreach (PP_PaySplitItem psi in ((PP_PaymentItem)li).PAYMENT_SPLITS)
                    {
                        ProviderBalance pb            = (ProviderBalance)htProvBalance[psi.PROVNUM];
                        ProviderBalance pb_Cumulative = (ProviderBalance)htProvBalance_Cummulative[psi.PROVNUM];
                        pb.Ammounts[(int)li.ITEMTYPE]            += psi.AMMOUNT;
                        pb_Cumulative.Ammounts[(int)li.ITEMTYPE] += psi.AMMOUNT;
                    }
                }
                else
                {
                    ProviderBalance pb            = (ProviderBalance)htProvBalance[li.PROVNUM];
                    ProviderBalance pb_Cumulative = (ProviderBalance)htProvBalance_Cummulative[li.PROVNUM];
                    pb.Ammounts[(int)li.ITEMTYPE]            += li.AMMOUNT;
                    pb_Cumulative.Ammounts[(int)li.ITEMTYPE] += li.AMMOUNT;
                }

                #endregion
            }
            #region Adding the End DataRow

            {
                DataRow dr3 = this.MakeProviderBalanceDataRow(curDate, dt, htProvBalance, htProvBalance_Cummulative, subcols, ProviderNums);
                dt.Rows.Add(dr3);
            }
            #endregion

            return(dt);
        }