Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Company VAT-ID and Tax-ID #54

Merged
merged 7 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Http/Requests/CompaniesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function getCompanyPayload()
return collect($this->validated())
->only([
'name',
'vat_id',
'tax_id',
])
->merge([
'owner_id' => $this->user()->id,
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Requests/CompanyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public function rules()
'required',
Rule::unique('companies')->ignore($this->header('company'), 'id'),
],
'vat_id' => [
'nullable',
],
'tax_id' => [
'nullable',
],
'slug' => [
'nullable',
],
Expand All @@ -44,6 +50,8 @@ public function getCompanyPayload()
->only([
'name',
'slug',
'vat_id',
'tax_id'
])
->toArray();
}
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Resources/CompanyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function toArray($request)
return [
'id' => $this->id,
'name' => $this->name,
'vat_id' => $this->vat_id,
'tax_id' => $this->tax_id,
'logo' => $this->logo,
'logo_path' => $this->logo_path,
'unique_hash' => $this->unique_hash,
Expand Down
32 changes: 32 additions & 0 deletions database/migrations/2024_04_12_162703_add_tax_ids_to_companies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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('companies', function (Blueprint $table) {
$table->after("unique_hash", function (Blueprint $table) {
$table->string("vat_id");
$table->string("tax_id");
});
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn("vat_id");
$table->dropColumn("tax_id");
});
}
};
6 changes: 5 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@
"company_info": {
"company_info": "Firmeninfo",
"company_name": "Name des Unternehmens",
"vat_id": "Umsatzsteuer-Identifikationsnummer",
"tax_id": "Steuernummer",
"company_logo": "Firmenlogo",
"section_description": "Informationen zu Ihrem Unternehmen, die auf Rechnungen, Angeboten und anderen von InvoiceShelf erstellten Dokumenten angezeigt werden.",
"phone": "Telefon",
Expand Down Expand Up @@ -1522,5 +1524,7 @@
"pdf_bill_to": "Rechnungsanschrift",
"pdf_ship_to": "Lieferanschrift",
"pdf_received_from": "Erhalten von:",
"pdf_tax_label": "Steuer"
"pdf_tax_label": "Steuer",
"pdf_tax_id": "Steuer-Nr.",
"pdf_vat_id": "USt.-ID"
}
6 changes: 5 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@
"company_info": {
"company_info": "Company info",
"company_name": "Company Name",
"tax_id": "Tax Identification Number",
"vat_id": "VAT Identification Number",
"company_logo": "Company Logo",
"section_description": "Information about your company that will be displayed on invoices, estimates and other documents created by InvoiceShelf.",
"phone": "Phone",
Expand Down Expand Up @@ -1522,5 +1524,7 @@
"pdf_bill_to": "Bill to,",
"pdf_ship_to": "Ship to,",
"pdf_received_from": "Received from:",
"pdf_tax_label": "Tax"
"pdf_tax_label": "Tax",
"pdf_tax_id": "Tax-ID",
"pdf_vat_id": "VAT-ID"
}
27 changes: 24 additions & 3 deletions resources/scripts/admin/views/installation/Step7CompanyInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@
/>
</BaseInputGroup>
</div>

<BaseInputGroup :label="$t('settings.company_info.tax_id')">
<BaseInput
v-model.trim="companyForm.tax_id"
type="text"
name="tax_id"
/>
</BaseInputGroup>

<BaseInputGroup
:label="$t('settings.company_info.vat_id')"
class="mt-4"
>
<BaseInput
v-model.trim="companyForm.vat_id"
type="text"
name="vat_id"
/>
</BaseInputGroup>
</div>

<BaseButton :loading="isSaving" :disabled="isSaving" class="mt-4">
Expand Down Expand Up @@ -162,6 +181,8 @@ let logoFileName = ref(null)

const companyForm = reactive({
name: null,
tax_id: null,
vat_id: null,
address: {
address_street_1: '',
address_street_2: '',
Expand Down Expand Up @@ -200,13 +221,13 @@ const rules = {
address_street_1: {
maxLength: helpers.withMessage(
t('validation.address_maxlength', { count: 255 }),
maxLength(255)
maxLength(255),
),
},
address_street_2: {
maxLength: helpers.withMessage(
t('validation.address_maxlength', { count: 255 }),
maxLength(255)
maxLength(255),
),
},
},
Expand Down Expand Up @@ -241,7 +262,7 @@ async function next() {
JSON.stringify({
name: logoFileName.value,
data: logoFileBlob.value,
})
}),
)
await companyStore.updateCompanyLogo(logoData)
}
Expand Down
37 changes: 16 additions & 21 deletions resources/scripts/admin/views/settings/CompanyInfoSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
class="mt-2"
/>
</div>

<div class="space-y-6">
<BaseInputGroup :label="$t('settings.company_info.tax_id')">
<BaseInput v-model="companyForm.tax_id" type="text" />
</BaseInputGroup>

<BaseInputGroup :label="$t('settings.company_info.vat_id')">
<BaseInput v-model="companyForm.vat_id" type="text" />
</BaseInputGroup>
</div>
</BaseInputGrid>

<BaseButton
Expand Down Expand Up @@ -111,24 +121,7 @@
<div class="mt-5">
<button
type="button"
class="
inline-flex
items-center
justify-center
px-4
py-2
border border-transparent
font-medium
rounded-md
text-red-700
bg-red-100
hover:bg-red-200
focus:outline-none
focus:ring-2
focus:ring-offset-2
focus:ring-red-500
sm:text-sm
"
class="inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-md text-red-700 bg-red-100 hover:bg-red-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:text-sm"
@click="removeCompany"
>
{{ $t('general.delete') }}
Expand Down Expand Up @@ -161,6 +154,8 @@ let isSaving = ref(false)
const companyForm = reactive({
name: null,
logo: null,
tax_id: null,
vat_id: null,
address: {
address_street_1: '',
address_street_2: '',
Expand Down Expand Up @@ -194,7 +189,7 @@ const rules = computed(() => {
required: helpers.withMessage(t('validation.required'), required),
minLength: helpers.withMessage(
t('validation.name_min_length'),
minLength(3)
minLength(3),
),
},
address: {
Expand All @@ -207,7 +202,7 @@ const rules = computed(() => {

const v$ = useVuelidate(
rules,
computed(() => companyForm)
computed(() => companyForm),
)

globalStore.fetchCountries()
Expand Down Expand Up @@ -243,7 +238,7 @@ async function updateCompanyData() {
JSON.stringify({
name: logoFileName.value,
data: logoFileBlob.value,
})
}),
)
}
logoData.append('is_company_logo_removed', isCompanyLogoRemoved.value)
Expand Down