我必须创建一个报告,其中分解会员费用在财政年度。
本财年从7月31日开始,会员年限为1年或2年。
我想要按比例对会员进行评分,以确定他们在哪个财政年度应缴纳多少费用。
例如,一年的会员资格取决于会员开始的时间,将跨越两个会计年度。
即365天,第一财年为50天,第二财年为315天。因此,第1年和第2年的总和为(费用/365)x 50。
我如何在我的报告中反映这一点?
谢谢!
编辑:
这是一个来自当前成员的实际示例。财政年度是在7月31日
会员1,会员费50美元,2009年9月10日收到,天数为730天,故障Fy2010 20.82,fy2011 25.00,fy2012 4.18
发布于 2011-07-14 02:29:28
Jon,这是一个获取下一个发票日期的例程- http://www.php.net/manual/en/function.date.php#103196,您可以修改它来获得下两个会计年度的结束日期,因为它们总是在相同的日期结束,但是不同的年份。
将它与date diff结合起来,比如这里的http://php.net/manual/en/function.date-diff.php函数,您应该能够计算出每个会计年度还剩下多少时间。
发布于 2011-07-14 06:46:07
感谢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;
?>https://stackoverflow.com/questions/6679799
复制相似问题