You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
283 lines
11 KiB
283 lines
11 KiB
using Swift.DAL.Remittance.Partner;
|
|
using Swift.web.Library;
|
|
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace Swift.web.Remit.AgeingReport
|
|
{
|
|
public partial class OustandingReport : System.Web.UI.Page
|
|
{
|
|
protected PartnerDao _dao = new PartnerDao();
|
|
private readonly SwiftLibrary sl = new SwiftLibrary();
|
|
private const string ViewFunctionId = "43000000";
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
Authenticate();
|
|
if (!IsPostBack)
|
|
{
|
|
PopulateReport();
|
|
}
|
|
}
|
|
|
|
private void Authenticate()
|
|
{
|
|
sl.CheckAuthentication(ViewFunctionId);
|
|
}
|
|
|
|
private void PopulateReport()
|
|
{
|
|
string asOnDate = GetStatic.ReadQueryString("asOnDate", "");
|
|
|
|
DataTable drTbl = _dao.GetOutstandingReport(GetStatic.GetUser(), asOnDate);
|
|
|
|
if (drTbl == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
int sNo = 0;
|
|
string accNum = "";
|
|
double belowOneDayTotal = 0;
|
|
double aboveOneToThreeDaysTotal = 0;
|
|
double aboveThreetoSevenDays = 0;
|
|
double aboveSevenDaysTotal = 0;
|
|
double outStandingTotal = 0;
|
|
|
|
//double negAboveSeven = 0;
|
|
//double negAboveToSeven = 0;
|
|
//double negAboveOneToThree = 0;
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (DataRow item in drTbl.Rows)
|
|
{
|
|
sNo++;
|
|
accNum = item["ACCOUNT_NUMBER"].ToString();
|
|
double[] amt = GetAmountArrayNew(item);
|
|
//double[] amtAboveSevenDays = GetAmountArrayForAboveSevenDays(item, GetDoubleValue(rows[0][0].ToString()));
|
|
|
|
if (amt[0] != 0)
|
|
{
|
|
sb.AppendLine("<tr>");
|
|
sb.AppendLine("<td>" + sNo.ToString() + "</td>");
|
|
sb.AppendLine("<td>" + item["AGENT_NAME"].ToString() + "</td>");
|
|
sb.AppendLine("<td align='right'>" + GetStatic.GetNegativeFigureOnBrac((amt[0]).ToString()) + "</td>");
|
|
sb.AppendLine("<td align='right'>" + GetStatic.GetNegativeFigureOnBrac((amt[4]).ToString()) + "</td>");
|
|
sb.AppendLine("<td align='right'>" + GetStatic.GetNegativeFigureOnBrac((amt[3]).ToString()) + "</td>");
|
|
sb.AppendLine("<td align='right'>" + GetStatic.GetNegativeFigureOnBrac((amt[2]).ToString()) + "</td>");
|
|
sb.AppendLine("<td align='right'>" + GetStatic.GetNegativeFigureOnBrac((amt[1]).ToString()) + "</td>");
|
|
sb.AppendLine("</tr>");
|
|
|
|
outStandingTotal += (amt[0]);
|
|
belowOneDayTotal += (amt[4]);
|
|
aboveOneToThreeDaysTotal += (amt[3]);
|
|
aboveThreetoSevenDays += (amt[2]);
|
|
aboveSevenDaysTotal += (amt[1]);
|
|
|
|
//if(aboveSevenDaysTotal < 0)
|
|
//{
|
|
// negAboveToSeven = aboveSevenDaysTotal + aboveThreetoSevenDays;
|
|
//}
|
|
}
|
|
}
|
|
sb.AppendLine("<tr>");
|
|
sb.AppendLine("<td align='right' colspan='2'><b>Grand Total</b></td>");
|
|
sb.AppendLine("<td align='right'><b>" + GetStatic.GetNegativeFigureOnBrac(outStandingTotal.ToString()) + "</b></td>");
|
|
sb.AppendLine("<td align='right'><b>" + GetStatic.GetNegativeFigureOnBrac(belowOneDayTotal.ToString()) + "</b></td>");
|
|
sb.AppendLine("<td align='right'><b>" + GetStatic.GetNegativeFigureOnBrac(aboveOneToThreeDaysTotal.ToString()) + "</b></td>");
|
|
sb.AppendLine("<td align='right'><b>" + GetStatic.GetNegativeFigureOnBrac(aboveThreetoSevenDays.ToString()) + "</b></td>");
|
|
sb.AppendLine("<td align='right'><b>" + GetStatic.GetNegativeFigureOnBrac(aboveSevenDaysTotal.ToString()) + "</b></td>");
|
|
sb.AppendLine("</tr>");
|
|
ageingRptBody.InnerHtml = sb.ToString();
|
|
}
|
|
|
|
private double[] GetAmountArrayNew(DataRow item)
|
|
{
|
|
double[] amt = new double[6];
|
|
|
|
amt[0] = GetDoubleValue(item["TOTAL_OUT_STANDING"].ToString());
|
|
amt[1] = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString());
|
|
if (amt[1] < 0)
|
|
{
|
|
|
|
amt[2] = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) + GetDoubleValue(item["FOUR_TO_SEVEN_DAYS"].ToString());
|
|
amt[1] = 0;
|
|
if (amt[2] < 0)
|
|
{
|
|
amt[3] = amt[2] + GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
amt[2] = 0;
|
|
if (amt[3] < 0)
|
|
{
|
|
amt[4] = amt[3] + GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
amt[3] = 0;
|
|
if (amt[4] < 0)
|
|
{
|
|
amt[4] = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[4] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[3] = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
if (amt[3] < 0)
|
|
{
|
|
amt[4] = amt[3] + GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
amt[3] = 0;
|
|
if (amt[4] < 0)
|
|
{
|
|
amt[4] = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[4] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[1] = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString());
|
|
amt[2] = GetDoubleValue(item["FOUR_TO_SEVEN_DAYS"].ToString());
|
|
if (amt[2] < 0)
|
|
{
|
|
amt[3] = amt[2] + GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
amt[2] = 0;
|
|
if (amt[3] < 0)
|
|
{
|
|
amt[4] = amt[3] + GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
amt[3] = 0;
|
|
if (amt[4] < 0)
|
|
{
|
|
amt[4] = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[4] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[3] = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
if (amt[3] < 0)
|
|
{
|
|
amt[4] = amt[3] + GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
amt[3] = 0;
|
|
if (amt[4] < 0)
|
|
{
|
|
amt[4] = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[4] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
}
|
|
}
|
|
return amt;
|
|
}
|
|
|
|
//private double[] GetAmountArrayForAboveSevenDays(DataRow item, double crAmount)
|
|
//{
|
|
// double[] amt = new double[3];
|
|
|
|
// amt[0] = GetDoubleValue(item["TOTAL_OUT_STANDING"].ToString()) - crAmount;
|
|
// crAmount = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) - crAmount;
|
|
// if (crAmount < 0)
|
|
// {
|
|
// amt[2] = 0;
|
|
// amt[1] = GetDoubleValue(item["ABOVE_THREE_TO_SEVEN_DAYS"].ToString()) + crAmount;
|
|
// }
|
|
// else
|
|
// {
|
|
// amt[2] = crAmount;
|
|
// amt[1] = GetDoubleValue(item["ABOVE_THREE_TO_SEVEN_DAYS"].ToString());
|
|
// }
|
|
|
|
// if (GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) < crAmount)
|
|
// {
|
|
// amt[2] = 0;
|
|
// amt[1] = GetDoubleValue(item["ABOVE_THREE_TO_SEVEN_DAYS"].ToString()) - crAmount;
|
|
// }
|
|
// else
|
|
// {
|
|
// amt[2] = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) - crAmount;
|
|
// amt[1] = GetDoubleValue(item["ABOVE_THREE_TO_SEVEN_DAYS"].ToString());
|
|
// }
|
|
|
|
// return amt;
|
|
//}
|
|
|
|
|
|
|
|
private double[] GetAmountArray(DataRow item, double crAmount)
|
|
{
|
|
double[] amt = new double[6];
|
|
|
|
amt[0] = GetDoubleValue(item["TOTAL_OUT_STANDING"].ToString()) - crAmount;
|
|
if (GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) < crAmount)
|
|
{
|
|
crAmount = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString()) - crAmount;
|
|
if (crAmount < 0)
|
|
{
|
|
amt[4] = 0;
|
|
crAmount = GetDoubleValue(item["FOUR_TO_SEVEN_DAYS"].ToString()) + crAmount;
|
|
if (crAmount < 0)
|
|
{
|
|
amt[3] = 0;
|
|
crAmount = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString()) + crAmount;
|
|
if (crAmount < 0)
|
|
{
|
|
amt[2] = 0;
|
|
crAmount = GetDoubleValue(item["BELOW_ONE_DAY"].ToString()) + crAmount;
|
|
//if (crAmount < 0)++++
|
|
//{
|
|
// amt[2] = 0;
|
|
// amt[1] = GetDoubleValue(item["BELOW_FOUR_DAYS"].ToString()) + crAmount;
|
|
//}
|
|
//else
|
|
//{
|
|
// amt[2] = crAmount;
|
|
// amt[1] = GetDoubleValue(item["BELOW_FOUR_DAYS"].ToString());
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
amt[3] = crAmount;
|
|
amt[2] = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
amt[1] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
amt[4] = crAmount;
|
|
amt[3] = GetDoubleValue(item["FOUR_TO_SEVEN_DAYS"].ToString());
|
|
amt[2] = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
amt[1] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
amt[4] = crAmount;
|
|
amt[3] = GetDoubleValue(item["ABOVE_SEVEN_DAYS"].ToString());
|
|
amt[2] = GetDoubleValue(item["FOUR_TO_SEVEN_DAYS"].ToString());
|
|
amt[2] = GetDoubleValue(item["ONE_TO_THREE_DAYS"].ToString());
|
|
amt[1] = GetDoubleValue(item["BELOW_ONE_DAY"].ToString());
|
|
}
|
|
return amt;
|
|
}
|
|
|
|
public double GetDoubleValue(string inPutVal)
|
|
{
|
|
double outPut = 0;
|
|
Double.TryParse(inPutVal, out outPut);
|
|
return outPut;
|
|
}
|
|
}
|
|
}
|