Skip to content

Instantly share code, notes, and snippets.

@connors511
Created February 18, 2013 16:41
Show Gist options
  • Save connors511/4978683 to your computer and use it in GitHub Desktop.
Save connors511/4978683 to your computer and use it in GitHub Desktop.
\DB::delete('transactions')
->where('updated_at', '=', $foodclub->closed_at->get_timestamp())
->where('type', 'in', array(\Accounting\Model_Transaction::$TYPE_DINNER_EAT,\Accounting\Model_Transaction::$TYPE_DINNER_CHEF))
->execute();
foreach($foodclub->participants as $p)
{
$trans = \Accounting\Model_Transaction::find('first', array(
'where' => array(
'user_id' => $p->user_id,
'kitchen_id' => $foodclub->kitchen_id,
'amount' => -1 * ($foodclub->get_total() / $foodclub->get_participants_count() * ($foodclub->get_guests_for_user($p->user) + 1)),
'type' => \Accounting\Model_Transaction::$TYPE_DINNER_EAT,
)
))->delete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment