Skip to content

Instantly share code, notes, and snippets.

@connors511
Created February 18, 2013 15:48
Show Gist options
  • Save connors511/4978339 to your computer and use it in GitHub Desktop.
Save connors511/4978339 to your computer and use it in GitHub Desktop.
protected static $tax_cache = array();
public function get_tax($start,$end)
{
if (!isset(self::$tax_cache[$start->get_timestamp()][$end->get_timestamp()])) {
// This should account for multiple users, kitchen->tax_interval and temporal edits
$days = \Date::range_to_array($start, $end, "+1 day");
$tax_days = 0;
foreach($days as $d) {
if (((int)$d->format('%d')) == $this->kitchen->report_day)
$tax_days++;
}
self::$tax_cache[$start->get_timestamp()][$end->get_timestamp()] = $tax_days;
}
return $this->kitchen->tax * self::$tax_cache[$start->get_timestamp()][$end->get_timestamp()] * $this->tax_payers * -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment