Delete invoice

This commit is contained in:
Peter Papp
2021-04-28 18:44:42 +02:00
parent 248825f2d1
commit 13ec1257e1
7 changed files with 72 additions and 6 deletions

View File

@@ -73,10 +73,8 @@ class ClientController extends Controller
*/
public function destroy(Client $client)
{
if ($client->user_id === Auth::id()) {
$client->delete();
$client->delete();
return response('Done', 204);
}
return response('Done', 204);
}
}

View File

@@ -127,6 +127,17 @@ class InvoiceController extends Controller
);
}
/**
* @param Invoice $invoice
* @throws \Exception
*/
public function destroy(Invoice $invoice)
{
$invoice->delete();
return response('Done', 204);
}
/**
* @param StoreInvoiceRequest $request
* @return mixed

View File

@@ -85,7 +85,7 @@ function invoice_total_discount($invoice, $format = false)
// Percent discount
if ($invoice['discount_type'] === 'percent') {
$discount = (invoice_total_net($invoice) + invoice_total_tax($invoice)) * ($invoice['discount_rate'] / 100);
$discount = (int) (invoice_total_net($invoice) + invoice_total_tax($invoice)) * ($invoice['discount_rate'] / 100);
if ($format) {
return Cashier::formatAmount($discount * 100, $invoice['currency'], 'cs');
@@ -153,5 +153,5 @@ function invoice_total_tax($invoice, $format = false)
*/
function format_to_currency($value, $currency = 'CZK', $locale = 'cs')
{
return Cashier::formatAmount(($value * 100), $currency, $locale);
return Cashier::formatAmount(((int) $value * 100), $currency, $locale);
}