Skip to content

Commit

Permalink
siwapp/siwapp#3 repository class for abstractinvoice.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZ99 committed Dec 5, 2011
1 parent 5040d32 commit fce2343
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Siwapp/CoreBundle/Entity/AbstractInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public function preSave()
}

/**
* @OTM\PostRemove
* @ORM\PostRemove
*/
public function postDelete()
{
Expand Down
32 changes: 32 additions & 0 deletions src/Siwapp/CoreBundle/Repository/AbstractInvoiceRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Siwapp\CoreBundle\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\Common\Collections\ArrayCollection;


/**
* Repository class to be inherited by InvoiceRepository,
* RecurringInvoiceRepository and EstimateRepository
*/
class AbstractInvoiceRepository extends EntityRepository
{
/**
* Update totals for invoices, recurring or estimates
* @param ArrayCollection of entities
* @return AbstractInvoiceRepository
**/
public static function updateTotals(ArrayCollection $entities = new ArrayCollection())
{
$em = $this->getEntityManager();
foreach($entity in $entities)
{
$entity->setAmounts();
$em->persist($entity);
}
$em->flush();
return $this;
}

}

0 comments on commit fce2343

Please sign in to comment.