Work to invoice
This commit is contained in:
parent
224bf9e951
commit
02e78e7255
101 changed files with 23483 additions and 154 deletions
60
app/Services/Invoice.php
Normal file
60
app/Services/Invoice.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\Util;
|
||||
use App\Models\Setting;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
||||
class Invoice
|
||||
{
|
||||
|
||||
public static function getInvoiceNumber(){
|
||||
return (int) Setting::getContentBySlug('invoice-number');
|
||||
}
|
||||
|
||||
public static function makeNextInvoiceNumber(){
|
||||
$invoice_number = self::getInvoiceNumber();
|
||||
$invoice_number = $invoice_number+1;
|
||||
Setting::setContentBySlug('invoice-number', $invoice_number, 'int');
|
||||
return $invoice_number;
|
||||
}
|
||||
|
||||
public static function createInvoiceNumber($invoice_number, $invoice_date){
|
||||
$prefix = \Carbon::parse($invoice_date)->format('Ym');
|
||||
return $prefix.$invoice_number;
|
||||
}
|
||||
|
||||
public static function getInvoiceStorageDir($invoice_date){
|
||||
return "/invoice/".\Carbon::parse($invoice_date)->format('Y/m/');
|
||||
}
|
||||
|
||||
public static function makeInvoiceFilename($invoice_number){
|
||||
|
||||
return "Rechnung-".$invoice_number.".pdf";
|
||||
}
|
||||
|
||||
public static function isInvoice(ShoppingOrder $shopping_order){
|
||||
return isset($shopping_order->invoice['filename']) ? true : false;
|
||||
}
|
||||
|
||||
public static function getFilename(ShoppingOrder $shopping_order){
|
||||
return isset($shopping_order->invoice['filename']) ? $shopping_order->invoice['filename'] : false;
|
||||
}
|
||||
|
||||
public static function getDir(ShoppingOrder $shopping_order){
|
||||
return isset($shopping_order->invoice['dir']) ? $shopping_order->invoice['dir'] : false;
|
||||
}
|
||||
|
||||
public static function getDownloadURL(ShoppingOrder $shopping_order, $do = false){
|
||||
return route('storage_file', [$shopping_order->id, 'cms_download_file', $do]);
|
||||
}
|
||||
|
||||
public static function getDownloadPath(ShoppingOrder $shopping_order, $full = false){
|
||||
$dir = self::getDir($shopping_order);
|
||||
$filename = self::getFilename($shopping_order);
|
||||
if(!$full){
|
||||
return $dir.$filename;
|
||||
}
|
||||
return \Storage::disk('public')->path($dir.$filename);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue