Add contract management and invoice settings pages
- Created a new Blade view for managing brand contracts with forms for adding and editing contracts, including client and category selection. - Implemented success message notifications for contract actions. - Added a new Blade view for invoice settings, allowing customization of invoice number format, header branding, and default values for new invoices. - Introduced a new PDF view for generating rate cards with customizable styles based on user profile settings. - Developed a profile management page for rate cards, enabling users to update their identity, appearance, and visibility settings.
This commit is contained in:
54
app/Models/InvoiceSettings.php
Normal file
54
app/Models/InvoiceSettings.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InvoiceSettings extends Model
|
||||
{
|
||||
protected $table = 'invoice_settings';
|
||||
|
||||
protected $fillable = [
|
||||
'invoice_prefix',
|
||||
'invoice_next_number',
|
||||
'header_name',
|
||||
'header_title',
|
||||
'header_logo',
|
||||
'default_tax_rate',
|
||||
'default_currency',
|
||||
'default_service_description',
|
||||
'default_bank_name',
|
||||
'default_branch_name',
|
||||
'default_bank_account',
|
||||
'default_bank_holder',
|
||||
'default_notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'invoice_next_number' => 'integer',
|
||||
'default_tax_rate' => 'decimal:2',
|
||||
];
|
||||
|
||||
/** Always return the single settings row, creating it if absent. */
|
||||
public static function instance(): self
|
||||
{
|
||||
return static::firstOrCreate([], [
|
||||
'invoice_prefix' => 'INV',
|
||||
'invoice_next_number' => 1,
|
||||
'default_tax_rate' => 11,
|
||||
'default_currency' => 'IDR',
|
||||
]);
|
||||
}
|
||||
|
||||
/** Generate the next invoice number and increment the counter. */
|
||||
public static function generateNumber(): string
|
||||
{
|
||||
$settings = static::instance();
|
||||
$prefix = rtrim($settings->invoice_prefix, '-');
|
||||
$number = str_pad((string) $settings->invoice_next_number, 3, '0', STR_PAD_LEFT);
|
||||
$settings->increment('invoice_next_number');
|
||||
return $prefix . '-' . $number;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user