我必须创建一份报告,在会计年度内分解会员费。
财政年度从7月31日开始 会员资格长度为1年或2年。
我想对会员资格进行评分,以确定他们的会费中有多少属于哪个会计年度。
例如,根据成员何时开始,1年的会员资格将超过2个会计年度。即365天,第1财年为50天,第二财年为315天。所以总计将是(Dues / 365)x 50第1年和(Dues / 365)第2年。
我怎样才能在报告中反映出来?
谢谢!
编辑:
这是当前成员资格的实际示例。财政年度是7月31日
会员1,会费50美元,收到09/10/2009,第730天, 细分FY2010 20.82,2011财年25.00,fy2012 4.18
答案 0 :(得分:1)
乔恩, 这是获取下一个发票日期的例程 - http://www.php.net/manual/en/function.date.php#103196,您可以修改该日期以获得接下来的两个会计年度结束日期,因为它们总是在同一天结束但不同年份结束。
将其与日期差异(例如此处的函数http://php.net/manual/en/function.date-diff.php)相结合,您应该能够计算每个会计年度剩余的时间。
答案 1 :(得分:0)
感谢Brian Hoover带领我了解正确的信息。
我希望为其他人显示代码,以便了解如何对事情进行评分(这很棘手!) 如果您对使代码更清洁有任何建议,请告知。我只是一个新手。
<?php
//setup of the dates and values to play with
$now = $row->Membership_Date;
$membership_date = strtotime($now);
$fy2010 = strtotime("2010-07-31");
$fy2011 = strtotime("2011-07-31");
$fy2012 = strtotime("2012-07-31");
$fy2013 = strtotime("2013-07-31");
$fy2014 = strtotime("2014-07-31");
//doing the math to determine time span in unix timecode
$datedifffy2010 = $fy2010 - $membership_date;
$datedifffy2011 = $fy2011 - $membership_date;
$datedifffy2012 = $fy2012 - $membership_date;
$datedifffy2013 = $fy2013 - $membership_date;
$datedifffy2014 = $fy2014 - $membership_date;
//doing the math to transform it into full days
$fulldays2010 = floor($datedifffy2010/(60*60*24));
$fulldays2011 = floor($datedifffy2011/(60*60*24));
$fulldays2012 = floor($datedifffy2012/(60*60*24));
$fulldays2013 = floor($datedifffy2013/(60*60*24));
$fulldays2014 = floor($datedifffy2014/(60*60*24));
//Some values come back as negative, so we are making those zero
if ($fulldays2010 <= 0)
{
$fulldays2010 = 0;
};
if ($fulldays2011 <= 0)
{
$fulldays2011 = 0;
};
if ($fulldays2012 <= 0)
{
$fulldays2012 = 0;
};
if ($fulldays2013 <= 0)
{
$fulldays2013 = 0;
};
if ($fulldays2014 <= 0)
{
$fulldays2014 = 0;
};
//arithmetic to determine how many days belong to which fiscal year
if ($row->Membership_Length == 2)
{
$fy11remainder = 730 - $fulldays2010;
if ($fy11remainder >= 365) $fy11remainder = 365;
$fy12remainder = 730 - $fy11remainder - $fulldays2010;
if ($fy12remainder >= 365) $fy12remainder = 365;
$fy13remainder = 730 - $fy12remainder - $fy11remainder - $fulldays2010;
if ($fy13remainder >= 365) $fy13remainder = 365;
$fy14remainder = 730 - $fy13remainder - $fy12remainder - $fy11remainder - $fulldays2010;
}
else
{
$fy11remainder = 365 - $fulldays2010;
if ($fy11remainder >= 365) $fy11remainder = 365;
$fy12remainder = 365 - $fy11remainder - $fulldays2010;
if ($fy12remainder >= 365) $fy12remainder = 365;
$fy13remainder = 365 - $fy12remainder - $fy11remainder - $fulldays2010;
if ($fy13remainder >= 365) $fy13remainder = 365;
$fy14remainder = 365 - $fy13remainder - $fy12remainder - $fy11remainder - $fulldays2010;
};
//determining the mill rate for days (our organization has discounts for 2 year memberships, and different types of memberships have different prices
if ($length == 2)
{
$income = $row->Dues_Paid;
$daily_income = $income / 730;
}
else
{
$income = $row->Dues_Paid;
$daily_income = $income / 365;
};
//Mutiplying days by the mill rate for that specific entry or member
$fy10inc = $fulldays2010 * $daily_income;
$fy11inc = $fy11remainder * $daily_income;
$fy12inc = $fy12remainder * $daily_income;
$fy13inc = $fy13remainder * $daily_income;
$fy14inc = $fy14remainder * $daily_income;
//display pro-rate for fiscal year
echo $fy10inc;
?>