From 23056bcd63d9419eb888dff367489d340fafb007 Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Mon, 8 Jun 2020 17:24:05 -0400 Subject: [PATCH 1/9] tax info collection zip + VAT --- .../settings/account.component.html | 322 +++++++++++++++++- .../settings/account.component.ts | 55 +++ src/app/services/services.module.ts | 4 +- .../settings/adjust-payment.component.html | 265 ++++++++++++++ src/app/settings/adjust-payment.component.ts | 17 + src/app/settings/payment.component.ts | 6 +- src/locales/en/messages.json | 14 +- 7 files changed, 674 insertions(+), 9 deletions(-) diff --git a/src/app/organizations/settings/account.component.html b/src/app/organizations/settings/account.component.html index 7ef7ce28c5..b5adb00f6c 100644 --- a/src/app/organizations/settings/account.component.html +++ b/src/app/organizations/settings/account.component.html @@ -49,9 +49,325 @@

{{'taxInformation' | i18n}}

{{'taxInformationDesc' | i18n}}

- - {{'contactSupport' | i18n}} - +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +

{{'dangerZone' | i18n}}

diff --git a/src/app/organizations/settings/account.component.ts b/src/app/organizations/settings/account.component.ts index 87c85625c6..65a252810b 100644 --- a/src/app/organizations/settings/account.component.ts +++ b/src/app/organizations/settings/account.component.ts @@ -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; + 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; + } + } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index c74261dd31..c3da3d9566 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -143,8 +143,8 @@ export function initFactory(): Function { } apiService.setUrls({ base: isDev ? null : window.location.origin, - api: isDev ? 'http://localhost:4000' : null, - identity: isDev ? 'http://localhost:33656' : null, + api: isDev ? 'http://localhost:7064' : null, + identity: isDev ? 'http://localhost:5000' : null, events: isDev ? 'http://localhost:46273' : null, // Uncomment these (and comment out the above) if you want to target production diff --git a/src/app/settings/adjust-payment.component.html b/src/app/settings/adjust-payment.component.html index aad11828f0..9c219a04a1 100644 --- a/src/app/settings/adjust-payment.component.html +++ b/src/app/settings/adjust-payment.component.html @@ -4,6 +4,271 @@ aria-hidden="true">×

{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}

+
+
+ + + {{'countryPostalCodeRequiredDesc' | i18n}} +
+
+ + +
+
diff --git a/src/app/organizations/settings/account.component.ts b/src/app/organizations/settings/account.component.ts index 65a252810b..80430ac14c 100644 --- a/src/app/organizations/settings/account.component.ts +++ b/src/app/organizations/settings/account.component.ts @@ -18,10 +18,10 @@ import { OrganizationResponse } from 'jslib/models/response/organizationResponse import { ModalComponent } from '../../modal.component'; import { PurgeVaultComponent } from '../../settings/purge-vault.component'; +import { TaxInfoComponent } from '../../settings/tax-info.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', @@ -32,21 +32,12 @@ export class AccountComponent { @ViewChild('purgeOrganizationTemplate', { read: ViewContainerRef }) purgeModalRef: ViewContainerRef; @ViewChild('apiKeyTemplate', { read: ViewContainerRef }) apiKeyModalRef: ViewContainerRef; @ViewChild('rotateApiKeyTemplate', { read: ViewContainerRef }) rotateApiKeyModalRef: ViewContainerRef; + @ViewChild(TaxInfoComponent) taxInfo: TaxInfoComponent; loading = true; canUseApi = false; org: OrganizationResponse; formPromise: Promise; - 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; @@ -62,23 +53,6 @@ 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; @@ -100,16 +74,7 @@ export class AccountComponent { } 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); + this.formPromise = this.taxInfo.submitTaxInfo(); await this.formPromise; this.analytics.eventTrack.next({ action: 'Updated Organization Tax Info' }); this.toasterService.popAsync('success', null, this.i18nService.t('taxInfoUpdated')); @@ -175,15 +140,4 @@ 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; - } - } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index c3da3d9566..e0911bc55b 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -143,9 +143,9 @@ export function initFactory(): Function { } apiService.setUrls({ base: isDev ? null : window.location.origin, - api: isDev ? 'http://localhost:7064' : null, - identity: isDev ? 'http://localhost:5000' : null, - events: isDev ? 'http://localhost:46273' : null, + api: isDev ? 'http://localhost:5000' : null, + identity: isDev ? 'http://localhost:33657' : null, + events: isDev ? 'http://localhost:46274' : null, // Uncomment these (and comment out the above) if you want to target production // servers for local development. diff --git a/src/app/settings/add-credit.component.html b/src/app/settings/add-credit.component.html index 7ec14b9944..2e3a0e67d6 100644 --- a/src/app/settings/add-credit.component.html +++ b/src/app/settings/add-credit.component.html @@ -30,6 +30,7 @@ {{'creditDelayed' | i18n}} +

{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}

-
-
- - - {{'countryPostalCodeRequiredDesc' | i18n}} -
-
- - -
-
+ +

{{'dangerZone' | i18n}}

diff --git a/src/app/organizations/settings/account.component.ts b/src/app/organizations/settings/account.component.ts index 87c85625c6..65a252810b 100644 --- a/src/app/organizations/settings/account.component.ts +++ b/src/app/organizations/settings/account.component.ts @@ -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; + 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; + } + } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index e64240ad87..6937e91cd6 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -145,8 +145,8 @@ export function initFactory(): Function { } apiService.setUrls({ base: isDev ? null : window.location.origin, - api: isDev ? 'http://localhost:4000' : null, - identity: isDev ? 'http://localhost:33656' : null, + api: isDev ? 'http://localhost:7064' : null, + identity: isDev ? 'http://localhost:5000' : null, events: isDev ? 'http://localhost:46273' : null, // Uncomment these (and comment out the above) if you want to target production diff --git a/src/app/settings/adjust-payment.component.html b/src/app/settings/adjust-payment.component.html index aad11828f0..9c219a04a1 100644 --- a/src/app/settings/adjust-payment.component.html +++ b/src/app/settings/adjust-payment.component.html @@ -4,6 +4,271 @@ aria-hidden="true">×

{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}

+
+
+ + + {{'countryPostalCodeRequiredDesc' | i18n}} +
+
+ + +
+
diff --git a/src/app/organizations/settings/account.component.ts b/src/app/organizations/settings/account.component.ts index 65a252810b..80430ac14c 100644 --- a/src/app/organizations/settings/account.component.ts +++ b/src/app/organizations/settings/account.component.ts @@ -18,10 +18,10 @@ import { OrganizationResponse } from 'jslib/models/response/organizationResponse import { ModalComponent } from '../../modal.component'; import { PurgeVaultComponent } from '../../settings/purge-vault.component'; +import { TaxInfoComponent } from '../../settings/tax-info.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', @@ -32,21 +32,12 @@ export class AccountComponent { @ViewChild('purgeOrganizationTemplate', { read: ViewContainerRef }) purgeModalRef: ViewContainerRef; @ViewChild('apiKeyTemplate', { read: ViewContainerRef }) apiKeyModalRef: ViewContainerRef; @ViewChild('rotateApiKeyTemplate', { read: ViewContainerRef }) rotateApiKeyModalRef: ViewContainerRef; + @ViewChild(TaxInfoComponent) taxInfo: TaxInfoComponent; loading = true; canUseApi = false; org: OrganizationResponse; formPromise: Promise; - 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; @@ -62,23 +53,6 @@ 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; @@ -100,16 +74,7 @@ export class AccountComponent { } 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); + this.formPromise = this.taxInfo.submitTaxInfo(); await this.formPromise; this.analytics.eventTrack.next({ action: 'Updated Organization Tax Info' }); this.toasterService.popAsync('success', null, this.i18nService.t('taxInfoUpdated')); @@ -175,15 +140,4 @@ 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; - } - } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 6937e91cd6..2c5fa4481b 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -145,9 +145,9 @@ export function initFactory(): Function { } apiService.setUrls({ base: isDev ? null : window.location.origin, - api: isDev ? 'http://localhost:7064' : null, - identity: isDev ? 'http://localhost:5000' : null, - events: isDev ? 'http://localhost:46273' : null, + api: isDev ? 'http://localhost:5000' : null, + identity: isDev ? 'http://localhost:33657' : null, + events: isDev ? 'http://localhost:46274' : null, // Uncomment these (and comment out the above) if you want to target production // servers for local development. diff --git a/src/app/settings/add-credit.component.html b/src/app/settings/add-credit.component.html index 7ec14b9944..2e3a0e67d6 100644 --- a/src/app/settings/add-credit.component.html +++ b/src/app/settings/add-credit.component.html @@ -30,6 +30,7 @@ {{'creditDelayed' | i18n}} +

{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}

-
-
- - - {{'countryPostalCodeRequiredDesc' | i18n}} -
-
- - -
-
+