feat: implement discount and transport features in the quote system
- Added maximum discount settings configurable by the administrator. - Implemented discount calculations in the quote confirmation process. - Introduced transport options with associated costs, including handling for exceeding maximum piece limits. - Updated frontend to display discounts and transport information in the quote summary. - Created new database migrations for storing discount and transport settings. - Developed a new Filament page for managing global discount settings. - Enhanced email templates to include discount and transport details. - Added tests to ensure proper functionality of discounts and transport calculations.
This commit is contained in:
@@ -14,6 +14,7 @@ class Cliente extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'username', 'password',
|
||||
'sconti_abilitati', 'sconto_max_1', 'sconto_max_2',
|
||||
'nome', 'cognome', 'ragione_sociale', 'email', 'telefono',
|
||||
'indirizzo', 'cap', 'citta', 'provincia', 'note',
|
||||
];
|
||||
@@ -24,8 +25,29 @@ class Cliente extends Model
|
||||
|
||||
protected $casts = [
|
||||
'password' => 'hashed',
|
||||
'sconti_abilitati' => 'boolean',
|
||||
'sconto_max_1' => 'decimal:2',
|
||||
'sconto_max_2' => 'decimal:2',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sconti massimi (%) che il cliente può applicare al preventivo: i suoi, se personalizzati,
|
||||
* altrimenti la regola base. Zero per entrambi se l'amministratore li ha disabilitati.
|
||||
*
|
||||
* @return array{max_1:float,max_2:float}
|
||||
*/
|
||||
public function scontiMassimi(): array
|
||||
{
|
||||
if (! $this->sconti_abilitati) {
|
||||
return ['max_1' => 0.0, 'max_2' => 0.0];
|
||||
}
|
||||
|
||||
return [
|
||||
'max_1' => (float) ($this->sconto_max_1 ?? Impostazione::scontiBase()['max_1']),
|
||||
'max_2' => (float) ($this->sconto_max_2 ?? Impostazione::scontiBase()['max_2']),
|
||||
];
|
||||
}
|
||||
|
||||
public function preventivi(): HasMany
|
||||
{
|
||||
return $this->hasMany(Preventivo::class);
|
||||
|
||||
Reference in New Issue
Block a user