@greatapps/common 1.1.740 → 1.1.741
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/utils/billing-data.ts"],"sourcesContent":["import type { Account } from '../types';\n\n/**\n * Gateway das contas cobradas em USD. Elas não têm CPF/CNPJ, bairro nem número —\n * mesmo critério usado no AddCardModal (`account.gateway === 'stripe_usd'`).\n */\nexport const INTERNATIONAL_GATEWAY = 'stripe_usd';\n\nexport type BillingDataSnapshot = Pick<\n Account,\n | 'gateway'\n | 'financial_document'\n | 'financial_name'\n | 'financial_email'\n | 'zipcode'\n | 'address'\n | 'address_number'\n | 'neighborhood'\n | 'city'\n | 'state'\n | 'country'\n>;\n\ntype BillingField = keyof Omit<BillingDataSnapshot, 'gateway'>;\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/utils/billing-data.ts"],"sourcesContent":["import type { Account } from '../types';\n\n/**\n * Gateway das contas cobradas em USD. Elas não têm CPF/CNPJ, bairro nem número —\n * mesmo critério usado no AddCardModal (`account.gateway === 'stripe_usd'`).\n */\nexport const INTERNATIONAL_GATEWAY = 'stripe_usd';\n\nexport type BillingDataSnapshot = Pick<\n Account,\n | 'gateway'\n | 'financial_document'\n | 'financial_name'\n | 'financial_email'\n | 'zipcode'\n | 'address'\n | 'address_number'\n | 'neighborhood'\n | 'city'\n | 'state'\n | 'country'\n>;\n\ntype BillingField = keyof Omit<BillingDataSnapshot, 'gateway'>;\n\n/**\n * Campos exigidos em qualquer país — sem eles a nota fiscal não sai.\n *\n * `financial_email` NÃO entra: o backend cai no e-mail do usuário quando ele está\n * vazio (`financial_email || userDocument.email`, accounts/services.js), então a\n * nota sai do mesmo jeito. Exigi-lo aqui bloquearia 4.7k contas pagantes da wl 1\n * em vez das ~460 que de fato estão sem cadastro fiscal. O campo continua no\n * formulário, pré-preenchido — só não é critério de bloqueio.\n */\nconst INTERNATIONAL_BILLING_FIELDS: readonly BillingField[] = [\n 'financial_name',\n 'zipcode',\n 'address',\n 'city',\n 'state',\n 'country',\n];\n\n/** No Brasil a NF-e também exige documento fiscal, número e bairro. */\nconst BR_BILLING_FIELDS: readonly BillingField[] = [\n ...INTERNATIONAL_BILLING_FIELDS,\n 'financial_document',\n 'address_number',\n 'neighborhood',\n];\n\nexport function isInternationalAccount(\n account: Pick<BillingDataSnapshot, 'gateway'> | null | undefined,\n): boolean {\n return account?.gateway === INTERNATIONAL_GATEWAY;\n}\n\nfunction isFilled(value: string | null | undefined): boolean {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\n/**\n * A conta tem todos os dados de cobrança/fiscais necessários pra emissão de nota.\n * Retorna `false` quando a conta ainda não carregou — quem decide bloquear é o\n * chamador, que checa o loading antes (ver `useRequiredBillingData`).\n */\nexport function hasCompleteBillingData(\n account: BillingDataSnapshot | null | undefined,\n): boolean {\n if (!account) return false;\n\n const fields = isInternationalAccount(account)\n ? INTERNATIONAL_BILLING_FIELDS\n : BR_BILLING_FIELDS;\n\n for (const field of fields) {\n if (!isFilled(account[field])) return false;\n }\n\n return true;\n}\n"],"mappings":"AAMO,MAAM,wBAAwB;AA4BrC,MAAM,+BAAwD;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,uBACd,SACS;AACT,SAAO,SAAS,YAAY;AAC9B;AAEA,SAAS,SAAS,OAA2C;AAC3D,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS;AAC5D;AAOO,SAAS,uBACd,SACS;AACT,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,SAAS,uBAAuB,OAAO,IACzC,+BACA;AAEJ,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,SAAS,QAAQ,KAAK,CAAC,EAAG,QAAO;AAAA,EACxC;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -23,10 +23,17 @@ export type BillingDataSnapshot = Pick<
|
|
|
23
23
|
|
|
24
24
|
type BillingField = keyof Omit<BillingDataSnapshot, 'gateway'>;
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Campos exigidos em qualquer país — sem eles a nota fiscal não sai.
|
|
28
|
+
*
|
|
29
|
+
* `financial_email` NÃO entra: o backend cai no e-mail do usuário quando ele está
|
|
30
|
+
* vazio (`financial_email || userDocument.email`, accounts/services.js), então a
|
|
31
|
+
* nota sai do mesmo jeito. Exigi-lo aqui bloquearia 4.7k contas pagantes da wl 1
|
|
32
|
+
* em vez das ~460 que de fato estão sem cadastro fiscal. O campo continua no
|
|
33
|
+
* formulário, pré-preenchido — só não é critério de bloqueio.
|
|
34
|
+
*/
|
|
27
35
|
const INTERNATIONAL_BILLING_FIELDS: readonly BillingField[] = [
|
|
28
36
|
'financial_name',
|
|
29
|
-
'financial_email',
|
|
30
37
|
'zipcode',
|
|
31
38
|
'address',
|
|
32
39
|
'city',
|