mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
Delete invoice
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
@@ -70,5 +71,9 @@ class Invoice extends Model
|
||||
|
||||
$invoice->currency = 'CZK';
|
||||
});
|
||||
|
||||
static::deleting(function ($invoice) {
|
||||
Storage::delete(invoice_path($invoice));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user