diff --git a/app/Filament/App/Resources/InvoiceResource.php b/app/Filament/App/Resources/InvoiceResource.php index ecf7eb1..ea760fc 100644 --- a/app/Filament/App/Resources/InvoiceResource.php +++ b/app/Filament/App/Resources/InvoiceResource.php @@ -39,7 +39,7 @@ public static function getModelLabel(): string public static function form(Form $form): Form { return $form - ->columns(3) + ->columns(4) ->schema([ Forms\Components\TextInput::make('number') ->translateLabel() @@ -48,10 +48,17 @@ public static function form(Form $form): Form Forms\Components\Select::make('status') ->options(InvoiceStatusEnum::class) ->default(fn() => InvoiceStatusEnum::DRAFT) - ->required(), + ->required() + ->live() + ->afterStateUpdated(fn(Forms\Set $set, $state) => $state == InvoiceStatusEnum::PAID->value ? $set('payment_date', now()->format(PejotaHelper::getUserDateFormat())) : null), Forms\Components\DatePicker::make('due_date') ->translateLabel() ->date(), + Forms\Components\DatePicker::make('payment_date') + ->translateLabel() + ->date() + ->live() + ->required(fn(Forms\Get $get) => $get('status') == InvoiceStatusEnum::PAID->value), Forms\Components\Select::make('client_id') ->translateLabel() ->required() @@ -68,14 +75,7 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('title') ->translateLabel() ->required() - ->columnSpanFull(), - Forms\Components\Textarea::make('extra_info') - ->translateLabel() - ->columnSpanFull(), - Forms\Components\Textarea::make('obs_internal') - ->label('Internal observations') - ->translateLabel() - ->columnSpanFull(), + ->columnSpan(2), Forms\Components\TextInput::make('discount') ->numeric() ->live() @@ -84,6 +84,15 @@ public static function form(Form $form): Form ->required() ->numeric() ->readOnly(), + Forms\Components\Textarea::make('extra_info') + ->translateLabel() + ->columnSpan(2) + ->rows(3), + Forms\Components\Textarea::make('obs_internal') + ->label('Internal observations') + ->translateLabel() + ->columnSpan(2) + ->rows(3), Forms\Components\Repeater::make('items') ->relationship() @@ -178,6 +187,12 @@ public static function table(Table $table): Table ->alignCenter() ->date(PejotaHelper::getUserDateFormat()) ->sortable(), + Tables\Columns\TextColumn::make('payment_date') + ->translateLabel() + ->wrapHeader() + ->alignCenter() + ->date(PejotaHelper::getUserDateFormat()) + ->sortable(), Tables\Columns\TextColumn::make('discount') ->translateLabel() ->numeric() @@ -207,8 +222,10 @@ public static function table(Table $table): Table // ]) ->actions([ - Tables\Actions\ViewAction::make(), - Tables\Actions\EditAction::make(), + Tables\Actions\ActionGroup::make([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index d0d945c..93cfeca 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -17,7 +17,8 @@ class Invoice extends Model protected $guarded = ['id']; protected $casts = [ - 'due_date' => 'date', + 'due_date' => 'date:Y-m-d', + 'payment_date' => 'date:Y-m-d', 'total' => MoneyCast::class, 'discount' => MoneyCast::class, ]; diff --git a/app/Models/InvoiceItem.php b/app/Models/InvoiceItem.php index 888fc35..b59a640 100644 --- a/app/Models/InvoiceItem.php +++ b/app/Models/InvoiceItem.php @@ -15,9 +15,9 @@ class InvoiceItem extends Model protected $guarded = ['id']; protected $casts = [ - 'due_date' => 'date', + 'price' => MoneyCast::class, 'total' => MoneyCast::class, - 'status' => InvoiceItem::class, + 'discount' => MoneyCast::class, ]; public function invoice(): BelongsTo diff --git a/database/migrations/2024_09_14_172735_add_payment_date_invoice_table.php b/database/migrations/2024_09_14_172735_add_payment_date_invoice_table.php new file mode 100644 index 0000000..23cc418 --- /dev/null +++ b/database/migrations/2024_09_14_172735_add_payment_date_invoice_table.php @@ -0,0 +1,28 @@ +date('payment_date')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('invoices', function (Blueprint $table) { + $table->dropColumn('payment_date'); + }); + } +}; diff --git a/lang/es.json b/lang/es.json index a4ebdad..b1dd78b 100644 --- a/lang/es.json +++ b/lang/es.json @@ -73,6 +73,7 @@ "If checked when a task is updated with a status of in progress phase, if the actual start date is not set, then it will be filled with the date of update.": "Si está marcado, cuando una tarea se actualice con un estado de fase en progreso, si no se establece la fecha de inicio real, se llenará con la fecha de actualización.", "If checked when a task is updated with a status of closed phase, if the actual end date is not set, then it will be filled with the date of update.": "Si está marcado, cuando una tarea se actualice con un estado de fase cerrada, si no se establece la fecha de fin real, se llenará con la fecha de actualización.", "If checked the tradename will be used as the name of the vendor. Otherwise, the name will be used.": "Si está marcado, se usará el nombre comercial como el nombre del proveedor. De lo contrario, se usará el nombre.", + "Internal observations": "Observaciones internas", "Is running": "Está corriendo", "Invoice": "Factura", "Invoices": "Facturas", @@ -92,6 +93,7 @@ "Order": "Orden", "Overall Numbers": "Números Generales", "Parent": "Padre", + "Payment date": "Fecha de pago", "Payment method": "Método de pago", "Payment extra-info": "Información adicional de pago", "Phase": "Fase", diff --git a/lang/pt_BR.json b/lang/pt_BR.json index efa9ae3..39743a9 100644 --- a/lang/pt_BR.json +++ b/lang/pt_BR.json @@ -74,6 +74,7 @@ "If checked when a task is updated with a status of in progress phase, if the actual start date is not set, then it will be filled with the date of update.": "Se marcado quando uma tarefa é atualizada com o status de fase em andamento, se a data de início real não estiver definida, ela será preenchida com a data de atualização.", "If checked when a task is updated with a status of closed phase, if the actual end date is not set, then it will be filled with the date of update.": "Se marcado quando uma tarefa é atualizada com o status de fase concluído, se a data de fim real não estiver definida, ela será preenchida com a data de atualização.", "If checked the tradename will be used as the name of the vendor. Otherwise, the name will be used.": "Se marcado, o nome fantasia será usado como o nome do fornecedor. Caso não, o nome será usado.", + "Internal observations": "Observações internas", "Is running": "Em andamento", "Invoice": "Fatura", "Invoices": "Faturas", @@ -93,6 +94,7 @@ "Order": "Ordem", "Overall Numbers": "Números Gerais", "Parent": "Pai", + "Payment date": "Data de pagamento", "Payment method": "Método de pagamento", "Payment extra-info": "Informações adicionais de pagamento", "Phase": "Fase",