Merge pull request #166 from mchev/customer_tax_id

Include a Tax ID field in both customer creation and invoices
This commit is contained in:
mchev
2024-11-02 10:28:49 +01:00
committed by GitHub
11 changed files with 72 additions and 10 deletions

View File

@@ -49,8 +49,10 @@ class CustomerRequest extends FormRequest
'prefix' => [
'nullable',
],
'tax_id' => [
'nullable',
],
'enable_portal' => [
'boolean',
],
'currency_id' => [
@@ -133,6 +135,7 @@ class CustomerRequest extends FormRequest
'password',
'phone',
'prefix',
'tax_id',
'company_name',
'contact_name',
'website',

View File

@@ -30,6 +30,7 @@ class CustomerResource extends JsonResource
'formatted_created_at' => $this->formattedCreatedAt,
'avatar' => $this->avatar,
'prefix' => $this->prefix,
'tax_id' => $this->tax_id,
'billing' => $this->when($this->billingAddress()->exists(), function () {
return new AddressResource($this->billingAddress);
}),

View File

@@ -35,6 +35,7 @@ class CustomerResource extends JsonResource
'due_amount' => $this->due_amount,
'base_due_amount' => $this->base_due_amount,
'prefix' => $this->prefix,
'tax_id' => $this->tax_id,
'billing' => $this->when($this->billingAddress()->exists(), function () {
return new AddressResource($this->billingAddress);
}),

View File

@@ -145,6 +145,7 @@ trait GeneratesPdfTrait
'{CONTACT_EMAIL}' => $customer->email,
'{CONTACT_PHONE}' => $customer->phone,
'{CONTACT_WEBSITE}' => $customer->website,
'{CONTACT_TAX_ID}' => __('pdf_tax_id').': '.$customer->tax_id,
];
$customFields = $this->fields;

View File

@@ -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('customers', function (Blueprint $table) {
$table->string('tax_id')->nullable()->after('github_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('tax_id');
});
}
};

View File

@@ -172,6 +172,7 @@
"customers": {
"title": "Customers",
"prefix": "Prefix",
"tax_id": "Tax ID",
"add_customer": "Add Customer",
"contacts_list": "Customer List",
"name": "Name",

View File

@@ -116,6 +116,15 @@
/>
</BaseInputGroup>
</BaseInputGrid>
<BaseInputGroup :label="$t('customers.tax_id')">
<BaseInput
v-model="customerStore.currentCustomer.tax_id"
type="text"
class="mt-1 md:mt-0"
/>
</BaseInputGroup>
</BaseInputGrid>
</BaseTab>

View File

@@ -157,6 +157,24 @@
@input="v$.currentCustomer.prefix.$touch()"
/>
</BaseInputGroup>
<BaseInputGroup
:label="$t('customers.tax_id')"
:error="
v$.currentCustomer.tax_id.$error &&
v$.currentCustomer.tax_id.$errors[0].$message
"
:content-loading="isFetchingInitialData"
>
<BaseInput
v-model="customerStore.currentCustomer.tax_id"
:content-loading="isFetchingInitialData"
type="text"
name="tax_id"
:invalid="v$.currentCustomer.tax_id.$error"
@input="v$.currentCustomer.tax_id.$touch()"
/>
</BaseInputGroup>
</BaseInputGrid>
</div>
@@ -645,6 +663,9 @@ const rules = computed(() => {
minLength(3)
),
},
tax_id: {
required: helpers.withMessage(t('validation.required'), required),
},
currency_id: {
required: helpers.withMessage(t('validation.required'), required),
},

View File

@@ -180,6 +180,7 @@ async function getFields() {
{ label: 'Email', value: 'CONTACT_EMAIL' },
{ label: 'Phone', value: 'CONTACT_PHONE' },
{ label: 'Website', value: 'CONTACT_WEBSITE' },
{ label: 'Tax ID', value: 'CONTACT_TAX_ID' },
...customerFields.value.map((i) => ({
label: i.label,
value: i.slug,

View File

@@ -14,11 +14,10 @@ import.meta.glob([
window.pinia = pinia
window.Vuelidate = Vuelidate
import InvoiceShelf from './InvoiceShelf'
import InvoiceShelf from './InvoiceShelf.js'
window.Vue = Vue
window.router = router
window.VueRouter = VueRouter
window.InvoiceShelf = new InvoiceShelf()
window.InvoiceShelf = new InvoiceShelf()

9
vite.config.js vendored
View File

@@ -32,11 +32,8 @@ export default defineConfig({
},
},
}),
laravel({
input: [
'resources/scripts/main.js',
],
refresh: true,
})
laravel([
'resources/scripts/main.js'
])
]
});