Jobs billed by a fixed monthly fee get a monthly fee field, kept behind the quotes permission like the quoted amount. A billing material now has a billing month: a new draft adds every monthly fee job with something to bill, each on an invoice of its own, and bills one line for every unbilled month from the job's start up to the billing month (or its end or completion), so skipped months are caught up and no month is billed twice. Their expenses are billed alongside, their hours are covered by the fee and marked billed, and the job keeps running. Co-Authored-By: Claude Opus 5.5 <[email protected]>
55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Monthly fees (spec 5.5): a job's monthly fee, the month a billing
|
|
* material bills up to, that a monthly fee job is an invoice of its own,
|
|
* and the month of each monthly fee line, so no month is billed twice.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::table('customer_jobs', function (Blueprint $table) {
|
|
$table->unsignedInteger('monthly_fee_cents')->nullable()->after('quoted_amount_cents');
|
|
});
|
|
|
|
Schema::table('billing_exports', function (Blueprint $table) {
|
|
$table->char('period', 7)->nullable()->after('status');
|
|
});
|
|
|
|
Schema::table('billing_invoice_jobs', function (Blueprint $table) {
|
|
$table->boolean('own_invoice')->default(false)->after('customer_reference');
|
|
});
|
|
|
|
Schema::table('billing_lines', function (Blueprint $table) {
|
|
$table->char('period', 7)->nullable()->after('expense_id');
|
|
|
|
$table->index(['customer_job_id', 'kind', 'period']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('billing_lines', function (Blueprint $table) {
|
|
$table->dropIndex(['customer_job_id', 'kind', 'period']);
|
|
$table->dropColumn('period');
|
|
});
|
|
|
|
Schema::table('billing_invoice_jobs', function (Blueprint $table) {
|
|
$table->dropColumn('own_invoice');
|
|
});
|
|
|
|
Schema::table('billing_exports', function (Blueprint $table) {
|
|
$table->dropColumn('period');
|
|
});
|
|
|
|
Schema::table('customer_jobs', function (Blueprint $table) {
|
|
$table->dropColumn('monthly_fee_cents');
|
|
});
|
|
}
|
|
};
|