Skip to content

Commit

Permalink
Merge pull request #85 from pierredup/invoice-paid
Browse files Browse the repository at this point in the history
Don't allow paid invoices to be edited
  • Loading branch information
pierredup committed Oct 26, 2015
2 parents 235ba6c + 7593a70 commit 84e0312
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/CSBill/InvoiceBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public function createAction(Request $request, Client $client = null)
*/
public function editAction(Request $request, Invoice $invoice)
{
if ($invoice->getStatus() === Graph::STATUS_PAID) {
$this->flash($this->trans('invoice.edit.paid'), 'warning');

return $this->redirectToRoute('_invoices_index');
}

$form = $this->createForm('invoice', $invoice);

$form->handleRequest($request);
Expand Down
7 changes: 6 additions & 1 deletion src/CSBill/InvoiceBundle/Grid/InvoiceGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ public function getRowActions(Collection $collection)
$editAction = new ActionColumn();
$editAction->setIcon('edit')
->setTitle('invoice.action.edit')
->setRoute('_invoices_edit');
->setRoute('_invoices_edit')
->setCallback(function (RowAction $rowAction, Row $row) {
if (Graph::STATUS_PAID !== $row->getField('status')) {
return $rowAction;
}
});

$payAction = new ActionColumn();
$payAction->setIcon('credit-card')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ invoice:
success: Invoice created successfully
edit:
success: Invoice updated successfully
paid: "You can't edit invoices that is already paid"
item:
add: Add Item
remove: Remove Item
Expand Down

0 comments on commit 84e0312

Please sign in to comment.