resolution field for all forms

This commit is contained in:
Sebastian 2023-05-25 18:23:38 -03:00
parent 64e3705669
commit 562067a287
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069
10 changed files with 127 additions and 72 deletions

View File

@ -1,7 +1,13 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_11.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_11.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -114,6 +120,7 @@ export const v1 = (current: State): FlexibleForm<Form902_11.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_11.Form>, v: Partial<Form902_11.Form>,
@ -137,12 +144,11 @@ namespace Form902_11 {
firstName: string; firstName: string;
address: string; address: string;
} }
export interface Form { export interface Form extends Simplest.WithResolution {
contractingPartner: string; contractingPartner: string;
declares: "25-or-more" | "controlling-in-other-ways" | "managing-director"; declares: "25-or-more" | "controlling-in-other-ways" | "managing-director";
person: Person[]; person: Person[];
fiduciaryAssets: "no" | "yes"; fiduciaryAssets: "no" | "yes";
when: AbsoluteTime;
signature: string; signature: string;
} }
} }

View File

@ -1,7 +1,13 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_12.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_12.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -363,6 +369,7 @@ export const v1 = (current: State): FlexibleForm<Form902_12.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_12.Form>, v: Partial<Form902_12.Form>,
@ -419,7 +426,7 @@ namespace Form902_12 {
type Founder = WithRevoke<WithDeath<Person>>; type Founder = WithRevoke<WithDeath<Person>>;
type Beneficiary = WithClaim<Person>; type Beneficiary = WithClaim<Person>;
export interface Form { export interface Form extends Simplest.WithResolution {
contractingPartner: string; contractingPartner: string;
knownAs: string; knownAs: string;
boardMember: string; boardMember: string;
@ -429,6 +436,5 @@ namespace Form902_12 {
beneficiaryWhenSigning: Array<Beneficiary>; beneficiaryWhenSigning: Array<Beneficiary>;
beneficiaryExtra: Array<Beneficiary>; beneficiaryExtra: Array<Beneficiary>;
withRightToNominate: Array<WithRevoke<Person>>; withRightToNominate: Array<WithRevoke<Person>>;
when: AbsoluteTime;
} }
} }

View File

@ -1,7 +1,13 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_13.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_13.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -440,6 +446,7 @@ export const v1 = (current: State): FlexibleForm<Form902_13.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_13.Form>, v: Partial<Form902_13.Form>,
@ -505,7 +512,7 @@ namespace Form902_13 {
type Founder = WithRevoke<WithDeath<Person>>; type Founder = WithRevoke<WithDeath<Person>>;
type Beneficiary = WithClaim<Person>; type Beneficiary = WithClaim<Person>;
export interface Form { export interface Form extends Simplest.WithResolution {
contractingPartner: string; contractingPartner: string;
knownAs: string; knownAs: string;
boardMember: string; boardMember: string;
@ -516,6 +523,5 @@ namespace Form902_13 {
beneficiaryExtra: Array<Beneficiary>; beneficiaryExtra: Array<Beneficiary>;
protectors: Array<WithRevoke<Person>>; protectors: Array<WithRevoke<Person>>;
furtherPersons: Array<WithRevoke<Person>>; furtherPersons: Array<WithRevoke<Person>>;
when: AbsoluteTime;
} }
} }

View File

@ -1,7 +1,13 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_15.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_15.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -159,6 +165,7 @@ export const v1 = (current: State): FlexibleForm<Form902_15.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_15.Form>, v: Partial<Form902_15.Form>,
@ -179,13 +186,12 @@ namespace Form902_15 {
nationality: string; nationality: string;
} }
export interface Form { export interface Form extends Simplest.WithResolution {
contractingPartner: string; contractingPartner: string;
contractualRelationship: string; contractualRelationship: string;
insurancePolicy: string; insurancePolicy: string;
holder: Person; holder: Person;
premiumsPayer: Person; premiumsPayer: Person;
when: AbsoluteTime;
signature: string; signature: string;
} }
} }

View File

@ -1,7 +1,15 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
Amounts,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FlexibleForm, languageList } from "./index.js"; import { FlexibleForm, languageList } from "./index.js";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { amlStateConverter } from "../pages/AccountDetails.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_1.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_1.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -511,6 +519,7 @@ export const v1 = (current: State): FlexibleForm<Form902_1.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_1.Form>, v: Partial<Form902_1.Form>,
@ -671,8 +680,7 @@ namespace Form902_1 {
purpose: string; purpose: string;
} }
export interface Form { export interface Form extends Simplest.WithResolution {
when: AbsoluteTime;
fullName: string; fullName: string;
customerType: "natural" | "legal"; customerType: "natural" | "legal";
naturalCustomer: NaturalCustomer; naturalCustomer: NaturalCustomer;

View File

@ -1,10 +1,18 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
Amounts,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { ArrowRightIcon } from "@heroicons/react/24/outline"; import { ArrowRightIcon } from "@heroicons/react/24/outline";
import { h as create } from "preact"; import { h as create } from "preact";
import { ChevronRightIcon } from "@heroicons/react/24/solid"; import { ChevronRightIcon } from "@heroicons/react/24/solid";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { amlStateConverter } from "../pages/AccountDetails.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_4.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_4.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -736,6 +744,7 @@ export const v1 = (current: State): FlexibleForm<Form902_4.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_4.Form>, v: Partial<Form902_4.Form>,
@ -749,10 +758,9 @@ export const v1 = (current: State): FlexibleForm<Form902_4.Form> => ({
}); });
namespace Form902_4 { namespace Form902_4 {
export interface Form { export interface Form extends Simplest.WithResolution {
customer: string; customer: string;
fullName: string; fullName: string;
when: AbsoluteTime;
pep: { pep: {
foreign: "yes" | "no"; foreign: "yes" | "no";
domestic: "yes" | "no" | "yes-but-no-risk"; domestic: "yes" | "no" | "yes-but-no-risk";

View File

@ -6,6 +6,8 @@ import {
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm, currencyList } from "./index.js"; import { FlexibleForm, currencyList } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_5.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_5.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -229,6 +231,7 @@ export const v1 = (current: State): FlexibleForm<Form902_5.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_5.Form>, v: Partial<Form902_5.Form>,
@ -247,10 +250,9 @@ export const v1 = (current: State): FlexibleForm<Form902_5.Form> => ({
}); });
namespace Form902_5 { namespace Form902_5 {
export interface Form { export interface Form extends Simplest.WithResolution {
customer: string; customer: string;
fullName: string; fullName: string;
when: AbsoluteTime;
businessActivity: string; businessActivity: string;
financial: string; financial: string;
originOfAssets: { originOfAssets: {

View File

@ -1,7 +1,13 @@
import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
AmountJson,
TranslatedString,
} from "@gnu-taler/taler-util";
import { FormState } from "../handlers/FormProvider.js"; import { FormState } from "../handlers/FormProvider.js";
import { FlexibleForm } from "./index.js"; import { FlexibleForm } from "./index.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { AmlState } from "../types.js";
import { Simplest, resolutionSection } from "./simplest.js";
export const v1 = (current: State): FlexibleForm<Form902_9.Form> => ({ export const v1 = (current: State): FlexibleForm<Form902_9.Form> => ({
versionId: "2023-05-15", versionId: "2023-05-15",
@ -103,6 +109,7 @@ export const v1 = (current: State): FlexibleForm<Form902_9.Form> => ({
}, },
], ],
}, },
resolutionSection(current),
], ],
behavior: function formBehavior( behavior: function formBehavior(
v: Partial<Form902_9.Form>, v: Partial<Form902_9.Form>,
@ -123,10 +130,9 @@ namespace Form902_9 {
nationality: string; nationality: string;
address: string; address: string;
} }
export interface Form { export interface Form extends Simplest.WithResolution {
contractingPartner: string; contractingPartner: string;
persons: Person; persons: Person;
when: AbsoluteTime;
signature: string; signature: string;
} }
} }

View File

@ -9,6 +9,7 @@ import { FlexibleForm } from "./index.js";
import { AmlState } from "../types.js"; import { AmlState } from "../types.js";
import { amlStateConverter } from "../pages/AccountDetails.js"; import { amlStateConverter } from "../pages/AccountDetails.js";
import { State } from "../pages/AntiMoneyLaunderingForm.js"; import { State } from "../pages/AntiMoneyLaunderingForm.js";
import { DoubleColumnFormSection, UIFormField } from "../handlers/forms.js";
export const v1 = (current: State): FlexibleForm<Simplest.Form> => ({ export const v1 = (current: State): FlexibleForm<Simplest.Form> => ({
versionId: "2023-05-25", versionId: "2023-05-25",
@ -25,7 +26,35 @@ export const v1 = (current: State): FlexibleForm<Simplest.Form> => ({
}, },
], ],
}, },
{ resolutionSection(current),
],
behavior: function formBehavior(
v: Partial<Simplest.Form>,
): FormState<Simplest.Form> {
return {
when: {
disabled: true,
},
threshold: {
disabled: v.state === AmlState.frozen,
},
};
},
});
export namespace Simplest {
export interface WithResolution {
when: AbsoluteTime;
threshold: AmountJson;
state: AmlState;
}
export interface Form extends WithResolution {
comment: string;
}
}
export function resolutionSection(current: State): DoubleColumnFormSection {
return {
title: "Resolution" as TranslatedString, title: "Resolution" as TranslatedString,
description: `Current state is ${amlStateConverter.toStringUI( description: `Current state is ${amlStateConverter.toStringUI(
current.state, current.state,
@ -70,27 +99,5 @@ export const v1 = (current: State): FlexibleForm<Simplest.Form> => ({
}, },
}, },
], ],
},
],
behavior: function formBehavior(
v: Partial<Simplest.Form>,
): FormState<Simplest.Form> {
return {
when: {
disabled: true,
},
threshold: {
disabled: v.state === AmlState.frozen,
},
}; };
},
});
namespace Simplest {
export interface Form {
when: AbsoluteTime;
threshold: AmountJson;
state: AmlState;
comment: string;
}
} }

View File

@ -18,7 +18,7 @@ import { InputChoiceHorizontal } from "./InputChoiceHorizontal.js";
export type DoubleColumnForm = Array<DoubleColumnFormSection | undefined>; export type DoubleColumnForm = Array<DoubleColumnFormSection | undefined>;
type DoubleColumnFormSection = { export type DoubleColumnFormSection = {
title: TranslatedString; title: TranslatedString;
description?: TranslatedString; description?: TranslatedString;
fields: UIFormField[]; fields: UIFormField[];