1
0
mirror of https://github.com/bitwarden/web synced 2025-12-15 07:43:16 +00:00

tax info collection zip + VAT

This commit is contained in:
Chad Scharf
2020-06-08 17:24:05 -04:00
parent 4309064804
commit b1c098614c
8 changed files with 675 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ import { PurgeVaultComponent } from '../../settings/purge-vault.component';
import { ApiKeyComponent } from './api-key.component';
import { DeleteOrganizationComponent } from './delete-organization.component';
import { RotateApiKeyComponent } from './rotate-api-key.component';
import { OrganizationTaxInfoUpdateRequest } from 'jslib/models/request/organizationTaxInfoUpdateRequest';
@Component({
selector: 'app-org-account',
@@ -36,6 +37,16 @@ export class AccountComponent {
canUseApi = false;
org: OrganizationResponse;
formPromise: Promise<any>;
taxInfo: any = {
taxId: null,
line1: null,
line2: null,
city: null,
state: null,
postalCode: null,
country: 'US',
includeTaxId: false,
};
private organizationId: string;
private modal: ModalComponent = null;
@@ -51,6 +62,23 @@ export class AccountComponent {
try {
this.org = await this.apiService.getOrganization(this.organizationId);
this.canUseApi = this.org.useApi;
const taxInfo = await this.apiService.getOrganizationTaxInfo(this.organizationId);
if (taxInfo) {
this.taxInfo.taxId = taxInfo.taxId;
this.taxInfo.state = taxInfo.state;
this.taxInfo.line1 = taxInfo.line1;
this.taxInfo.line2 = taxInfo.line2;
this.taxInfo.city = taxInfo.city;
this.taxInfo.state = taxInfo.state;
this.taxInfo.postalCode = taxInfo.postalCode;
this.taxInfo.country = taxInfo.country;
this.taxInfo.includeTaxId = taxInfo.country !== 'US' && (
!!taxInfo.taxId
|| !!taxInfo.line1
|| !!taxInfo.line2
|| !!taxInfo.city
|| !!taxInfo.state);
}
} catch { }
});
this.loading = false;
@@ -71,6 +99,22 @@ export class AccountComponent {
} catch { }
}
async submitTaxInfo() {
const request = new OrganizationTaxInfoUpdateRequest();
request.taxId = this.taxInfo.taxId;
request.state = this.taxInfo.state;
request.line1 = this.taxInfo.line1;
request.line2 = this.taxInfo.line2;
request.city = this.taxInfo.city;
request.state = this.taxInfo.state;
request.postalCode = this.taxInfo.postalCode;
request.country = this.taxInfo.country;
this.formPromise = this.apiService.putOrganizationTaxInfo(this.organizationId, request);
await this.formPromise;
this.analytics.eventTrack.next({ action: 'Updated Organization Tax Info' });
this.toasterService.popAsync('success', null, this.i18nService.t('taxInfoUpdated'));
}
deleteOrganization() {
if (this.modal != null) {
this.modal.close();
@@ -131,4 +175,15 @@ export class AccountComponent {
this.modal = null;
});
}
changeCountry() {
if (this.taxInfo.country === 'US') {
this.taxInfo.includeTaxId = false;
this.taxInfo.taxId = null;
this.taxInfo.line1 = null;
this.taxInfo.line2 = null;
this.taxInfo.city = null;
this.taxInfo.state = null;
}
}
}