Add option to disable invoicing to settings page

Addresses #98
This commit is contained in:
Matt Young 2024-12-26 16:35:38 -06:00
parent bc7bd6fb44
commit cc5afc0635
3 changed files with 49 additions and 4 deletions

View File

@ -40,6 +40,9 @@ class AuditionSettings extends Controller
// Judging Enabled Switch // Judging Enabled Switch
$validData['judging_enabled'] = $request->get('judging_enabled') == '1'; $validData['judging_enabled'] = $request->get('judging_enabled') == '1';
// Enable Invoicing Switch
$validData['invoicing_enabled'] = $request->get('invoicing_enabled') == '1';
// Store currency values as cents // Store currency values as cents
$validData['late_fee'] = $validData['late_fee'] * 100; $validData['late_fee'] = $validData['late_fee'] * 100;
$validData['school_fee'] = $validData['school_fee'] * 100; $validData['school_fee'] = $validData['school_fee'] * 100;

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Check if invoicing_enabled setting exists
$exists = DB::table('site_settings')
->where('setting_key', 'invoicing_enabled')
->exists();
// If it doesn't insert the new row
if (! $exists) {
DB::table('site_settings')->insert([
'setting_key' => 'invoicing_enabled',
'setting_value' => '1',
]);
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -42,9 +42,16 @@
<x-layout.page-section> <x-layout.page-section>
<x-slot:section_name>Financial Settings</x-slot:section_name> <x-slot:section_name>Financial Settings</x-slot:section_name>
<x-form.body-grid columns="12" class="m-3"> <x-form.body-grid columns="12" class="m-3" x-data="{ show_invoicing_options: {{ auditionSetting('invoicing_enabled') ? 'true':'false'}} }">
<div class="col-span-12 flex space-x-3">
<x-form.toggle-checkbox
x-model="show_invoicing_options"
checked="{{ auditionSetting('invoicing_enabled') }}"
name="invoicing_enabled"/>
<span>Enable Invoicing</span>
</div>
<x-form.select name="fee_structure" colspan="6"> <x-form.select name="fee_structure" colspan="6" x-show="show_invoicing_options">
<x-slot:label>Fee Structure</x-slot:label> <x-slot:label>Fee Structure</x-slot:label>
{{-- Values should be one of the options in the boot method InvoiceDataServiceProvider --}} {{-- Values should be one of the options in the boot method InvoiceDataServiceProvider --}}
<option value="oneFeePerEntry" {{ auditionSetting('fee_structure') === 'oneFeePerEntry' ? 'selected':'' }}> <option value="oneFeePerEntry" {{ auditionSetting('fee_structure') === 'oneFeePerEntry' ? 'selected':'' }}>
@ -58,11 +65,13 @@
<x-form.field label_text="Late Fee" <x-form.field label_text="Late Fee"
name="late_fee" name="late_fee"
colspan="3" colspan="3"
:value="number_format(auditionSetting('late_fee') / 100,2) "/> :value="number_format(auditionSetting('late_fee') / 100,2) "
x-show="show_invoicing_options"/>
<x-form.field label_text="School Membership Fee" <x-form.field label_text="School Membership Fee"
name="school_fee" name="school_fee"
colspan="3" colspan="3"
:value="number_format(auditionSetting('school_fee') / 100,2)"/> :value="number_format(auditionSetting('school_fee') / 100,2)"
x-show="show_invoicing_options"/>
</x-form.body-grid> </x-form.body-grid>
</x-layout.page-section> </x-layout.page-section>