Skip to content

Commit

Permalink
Merge pull request #61 from mazer-dev/60-add-invoice-payment-date
Browse files Browse the repository at this point in the history
feat(#60): added payment date to invoice and layout improvements
  • Loading branch information
nunomazer authored Sep 14, 2024
2 parents c082087 + 80d77ce commit fa5cb17
Showing 6 changed files with 65 additions and 15 deletions.
41 changes: 29 additions & 12 deletions app/Filament/App/Resources/InvoiceResource.php
Original file line number Diff line number Diff line change
@@ -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([
3 changes: 2 additions & 1 deletion app/Models/Invoice.php
Original file line number Diff line number Diff line change
@@ -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,
];
4 changes: 2 additions & 2 deletions app/Models/InvoiceItem.php
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->date('payment_date')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->dropColumn('payment_date');
});
}
};
2 changes: 2 additions & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
@@ -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",
2 changes: 2 additions & 0 deletions lang/pt_BR.json
Original file line number Diff line number Diff line change
@@ -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",

0 comments on commit fa5cb17

Please sign in to comment.