|
@@ -56,92 +56,107 @@ class OfferingResource extends Resource
|
56
|
56
|
|
57
|
57
|
return new HtmlString($output);
|
58
|
58
|
}),
|
59
|
|
- Forms\Components\Section::make('General')
|
60
|
|
- ->schema([
|
61
|
|
- RadioDeck::make('type')
|
62
|
|
- ->options(OfferingType::class)
|
63
|
|
- ->default(OfferingType::Product)
|
64
|
|
- ->icons(OfferingType::class)
|
65
|
|
- ->color('primary')
|
66
|
|
- ->columns()
|
67
|
|
- ->required(),
|
68
|
|
- Forms\Components\TextInput::make('name')
|
69
|
|
- ->autofocus()
|
70
|
|
- ->required()
|
71
|
|
- ->columnStart(1)
|
72
|
|
- ->maxLength(255),
|
73
|
|
- Forms\Components\TextInput::make('price')
|
74
|
|
- ->required()
|
75
|
|
- ->money(),
|
76
|
|
- Forms\Components\Textarea::make('description')
|
77
|
|
- ->label('Description')
|
78
|
|
- ->columnSpan(2)
|
79
|
|
- ->rows(3),
|
80
|
|
- Forms\Components\CheckboxList::make('attributes')
|
81
|
|
- ->options([
|
82
|
|
- 'Sellable' => 'Sellable',
|
83
|
|
- 'Purchasable' => 'Purchasable',
|
84
|
|
- ])
|
85
|
|
- ->hiddenLabel()
|
86
|
|
- ->required()
|
87
|
|
- ->live()
|
88
|
|
- ->bulkToggleable()
|
89
|
|
- ->validationMessages([
|
90
|
|
- 'required' => 'The offering must be either sellable or purchasable.',
|
91
|
|
- ]),
|
92
|
|
- ])->columns(),
|
|
59
|
+ static::getGeneralSection(),
|
93
|
60
|
// Sellable Section
|
94
|
|
- Forms\Components\Section::make('Sale Information')
|
95
|
|
- ->schema([
|
96
|
|
- CreateAccountSelect::make('income_account_id')
|
97
|
|
- ->label('Income account')
|
98
|
|
- ->category(AccountCategory::Revenue)
|
99
|
|
- ->type(AccountType::OperatingRevenue)
|
100
|
|
- ->required()
|
101
|
|
- ->validationMessages([
|
102
|
|
- 'required' => 'The income account is required for sellable offerings.',
|
103
|
|
- ]),
|
104
|
|
- CreateAdjustmentSelect::make('salesTaxes')
|
105
|
|
- ->label('Sales tax')
|
106
|
|
- ->category(AdjustmentCategory::Tax)
|
107
|
|
- ->type(AdjustmentType::Sales)
|
108
|
|
- ->multiple(),
|
109
|
|
- CreateAdjustmentSelect::make('salesDiscounts')
|
110
|
|
- ->label('Sales discount')
|
111
|
|
- ->category(AdjustmentCategory::Discount)
|
112
|
|
- ->type(AdjustmentType::Sales)
|
113
|
|
- ->multiple(),
|
114
|
|
- ])
|
115
|
|
- ->columns()
|
116
|
|
- ->visible(static fn (Forms\Get $get) => in_array('Sellable', $get('attributes') ?? [])),
|
117
|
|
-
|
|
61
|
+ static::getSellableSection(),
|
118
|
62
|
// Purchasable Section
|
119
|
|
- Forms\Components\Section::make('Purchase Information')
|
120
|
|
- ->schema([
|
121
|
|
- CreateAccountSelect::make('expense_account_id')
|
122
|
|
- ->label('Expense account')
|
123
|
|
- ->category(AccountCategory::Expense)
|
124
|
|
- ->type(AccountType::OperatingExpense)
|
125
|
|
- ->required()
|
126
|
|
- ->validationMessages([
|
127
|
|
- 'required' => 'The expense account is required for purchasable offerings.',
|
128
|
|
- ]),
|
129
|
|
- CreateAdjustmentSelect::make('purchaseTaxes')
|
130
|
|
- ->label('Purchase tax')
|
131
|
|
- ->category(AdjustmentCategory::Tax)
|
132
|
|
- ->type(AdjustmentType::Purchase)
|
133
|
|
- ->multiple(),
|
134
|
|
- CreateAdjustmentSelect::make('purchaseDiscounts')
|
135
|
|
- ->label('Purchase discount')
|
136
|
|
- ->category(AdjustmentCategory::Discount)
|
137
|
|
- ->type(AdjustmentType::Purchase)
|
138
|
|
- ->multiple(),
|
139
|
|
- ])
|
|
63
|
+ static::getPurchasableSection(),
|
|
64
|
+ ])->columns();
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ public static function getGeneralSection(bool $hasAttributeChoices = true): Forms\Components\Section
|
|
68
|
+ {
|
|
69
|
+ return Forms\Components\Section::make('General')
|
|
70
|
+ ->schema([
|
|
71
|
+ RadioDeck::make('type')
|
|
72
|
+ ->options(OfferingType::class)
|
|
73
|
+ ->default(OfferingType::Product)
|
|
74
|
+ ->icons(OfferingType::class)
|
|
75
|
+ ->color('primary')
|
140
|
76
|
->columns()
|
141
|
|
- ->visible(static fn (Forms\Get $get) => in_array('Purchasable', $get('attributes') ?? [])),
|
|
77
|
+ ->required(),
|
|
78
|
+ Forms\Components\TextInput::make('name')
|
|
79
|
+ ->autofocus()
|
|
80
|
+ ->required()
|
|
81
|
+ ->columnStart(1)
|
|
82
|
+ ->maxLength(255),
|
|
83
|
+ Forms\Components\TextInput::make('price')
|
|
84
|
+ ->required()
|
|
85
|
+ ->money(),
|
|
86
|
+ Forms\Components\Textarea::make('description')
|
|
87
|
+ ->label('Description')
|
|
88
|
+ ->columnSpan(2)
|
|
89
|
+ ->rows(3),
|
|
90
|
+ Forms\Components\CheckboxList::make('attributes')
|
|
91
|
+ ->options([
|
|
92
|
+ 'Sellable' => 'Sellable',
|
|
93
|
+ 'Purchasable' => 'Purchasable',
|
|
94
|
+ ])
|
|
95
|
+ ->visible($hasAttributeChoices)
|
|
96
|
+ ->hiddenLabel()
|
|
97
|
+ ->required()
|
|
98
|
+ ->live()
|
|
99
|
+ ->bulkToggleable()
|
|
100
|
+ ->validationMessages([
|
|
101
|
+ 'required' => 'The offering must be either sellable or purchasable.',
|
|
102
|
+ ]),
|
142
|
103
|
])->columns();
|
143
|
104
|
}
|
144
|
105
|
|
|
106
|
+ public static function getSellableSection(bool $showByDefault = false): Forms\Components\Section
|
|
107
|
+ {
|
|
108
|
+ return Forms\Components\Section::make('Sale Information')
|
|
109
|
+ ->schema([
|
|
110
|
+ CreateAccountSelect::make('income_account_id')
|
|
111
|
+ ->label('Income account')
|
|
112
|
+ ->category(AccountCategory::Revenue)
|
|
113
|
+ ->type(AccountType::OperatingRevenue)
|
|
114
|
+ ->required()
|
|
115
|
+ ->validationMessages([
|
|
116
|
+ 'required' => 'The income account is required for sellable offerings.',
|
|
117
|
+ ]),
|
|
118
|
+ CreateAdjustmentSelect::make('salesTaxes')
|
|
119
|
+ ->label('Sales tax')
|
|
120
|
+ ->category(AdjustmentCategory::Tax)
|
|
121
|
+ ->type(AdjustmentType::Sales)
|
|
122
|
+ ->multiple(),
|
|
123
|
+ CreateAdjustmentSelect::make('salesDiscounts')
|
|
124
|
+ ->label('Sales discount')
|
|
125
|
+ ->category(AdjustmentCategory::Discount)
|
|
126
|
+ ->type(AdjustmentType::Sales)
|
|
127
|
+ ->multiple(),
|
|
128
|
+ ])
|
|
129
|
+ ->columns()
|
|
130
|
+ ->visible(static fn (Forms\Get $get) => in_array('Sellable', $get('attributes') ?? []));
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ public static function getPurchasableSection(): Forms\Components\Section
|
|
134
|
+ {
|
|
135
|
+ return Forms\Components\Section::make('Purchase Information')
|
|
136
|
+ ->schema([
|
|
137
|
+ CreateAccountSelect::make('expense_account_id')
|
|
138
|
+ ->label('Expense account')
|
|
139
|
+ ->category(AccountCategory::Expense)
|
|
140
|
+ ->type(AccountType::OperatingExpense)
|
|
141
|
+ ->required()
|
|
142
|
+ ->validationMessages([
|
|
143
|
+ 'required' => 'The expense account is required for purchasable offerings.',
|
|
144
|
+ ]),
|
|
145
|
+ CreateAdjustmentSelect::make('purchaseTaxes')
|
|
146
|
+ ->label('Purchase tax')
|
|
147
|
+ ->category(AdjustmentCategory::Tax)
|
|
148
|
+ ->type(AdjustmentType::Purchase)
|
|
149
|
+ ->multiple(),
|
|
150
|
+ CreateAdjustmentSelect::make('purchaseDiscounts')
|
|
151
|
+ ->label('Purchase discount')
|
|
152
|
+ ->category(AdjustmentCategory::Discount)
|
|
153
|
+ ->type(AdjustmentType::Purchase)
|
|
154
|
+ ->multiple(),
|
|
155
|
+ ])
|
|
156
|
+ ->columns()
|
|
157
|
+ ->visible(static fn (Forms\Get $get) => in_array('Purchasable', $get('attributes') ?? []));
|
|
158
|
+ }
|
|
159
|
+
|
145
|
160
|
public static function table(Table $table): Table
|
146
|
161
|
{
|
147
|
162
|
return $table
|