@zeniai/client-epic-state 5.0.49 → 5.0.50-betaAR1
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.
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +27 -5
- package/lib/entity/approvalRule/approvalRulePayload.js +87 -10
- package/lib/entity/approvalRule/approvalRuleSelector.d.ts +25 -1
- package/lib/entity/approvalRule/approvalRuleSelector.js +40 -0
- package/lib/entity/approvalRule/approvalRuleState.d.ts +48 -7
- package/lib/entity/project/projectPayload.d.ts +3 -3
- package/lib/entity/project/projectPayload.js +3 -3
- package/lib/entity/project/projectState.d.ts +4 -2
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -1
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +6 -0
- package/lib/entity/transaction/stateTypes/transaction.d.ts +2 -0
- package/lib/entity/transaction/stateTypes/transactionLine.d.ts +2 -2
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +87 -10
- package/lib/esm/entity/approvalRule/approvalRuleSelector.js +35 -0
- package/lib/esm/entity/project/projectPayload.js +1 -1
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +2 -2
- package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +6 -0
- package/lib/esm/index.js +2 -1
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +3 -0
- package/lib/esm/view/expenseAutomationView/helpers/saveTransactionHelper.js +1 -0
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +11 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +13 -4
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +7 -2
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +5 -7
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +46 -16
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +5 -7
- package/lib/index.d.ts +5 -4
- package/lib/index.js +22 -16
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +3 -0
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +1 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +11 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +13 -4
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +3 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +3 -0
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +4 -6
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +46 -16
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +15 -3
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +4 -6
- package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
- package/lib/view/transactionDetail/transactionDetailState.d.ts +2 -2
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { ApprovalRule } from './approvalRuleState';
|
|
2
|
+
/**
|
|
3
|
+
* Condition Payload — one entry inside criteria.conditions[].
|
|
4
|
+
*
|
|
5
|
+
* field examples: 'amount' | 'vendor_id' | 'department_id'
|
|
6
|
+
* type examples: 'gte' | 'lte' | 'eq' | 'in' | 'not_in'
|
|
7
|
+
* value: number for amount comparisons; string[] for in / not_in lookups.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConditionPayload {
|
|
10
|
+
field: string;
|
|
11
|
+
type: string;
|
|
12
|
+
value: number | string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Criteria Payload — list of conditions joined by `criteria_operator`.
|
|
16
|
+
*
|
|
17
|
+
* `currency_code` / `currency_symbol` apply to amount conditions inside
|
|
18
|
+
* `conditions[]`. Kept here pending confirmation that they should remain.
|
|
19
|
+
*/
|
|
2
20
|
export interface CriteriaPayload {
|
|
21
|
+
conditions: ConditionPayload[];
|
|
22
|
+
criteria_operator: string;
|
|
3
23
|
currency_code: string;
|
|
4
24
|
currency_symbol: string;
|
|
5
|
-
min: number;
|
|
6
|
-
range_entity: string;
|
|
7
|
-
type: string;
|
|
8
|
-
max?: number | null;
|
|
9
25
|
}
|
|
10
26
|
export interface ActorPayload {
|
|
11
27
|
type: string;
|
|
@@ -25,11 +41,17 @@ export interface StepPayload {
|
|
|
25
41
|
export interface ApprovalRulePayload {
|
|
26
42
|
approval_rule_id: string;
|
|
27
43
|
create_time: string;
|
|
28
|
-
criteria: CriteriaPayload
|
|
44
|
+
criteria: CriteriaPayload;
|
|
29
45
|
entity_type: string;
|
|
30
46
|
name: string | null;
|
|
31
47
|
steps: StepPayload[];
|
|
32
48
|
update_time: string;
|
|
49
|
+
are_approvals_serialized?: boolean;
|
|
50
|
+
description?: string | null;
|
|
51
|
+
is_fallback?: boolean;
|
|
52
|
+
pending_approvals_count?: number;
|
|
53
|
+
pending_entity_approval_update_status?: string;
|
|
54
|
+
priority?: number;
|
|
33
55
|
version?: number | string;
|
|
34
56
|
}
|
|
35
57
|
/**
|
|
@@ -17,19 +17,96 @@ const toApprovalRule = (payload) => ({
|
|
|
17
17
|
version: payload.version,
|
|
18
18
|
criteria: toApprovalCriteria(payload.criteria),
|
|
19
19
|
steps: toApprovalSteps(payload.steps),
|
|
20
|
+
description: payload.description ?? undefined,
|
|
21
|
+
priority: payload.priority,
|
|
22
|
+
isFallback: payload.is_fallback ?? false,
|
|
23
|
+
// separationOfDuties: backend doesn't ship this field yet; left undefined
|
|
24
|
+
// until the spec is finalized.
|
|
25
|
+
areApprovalsSerialized: payload.are_approvals_serialized,
|
|
26
|
+
pendingApprovalsCount: payload.pending_approvals_count,
|
|
27
|
+
pendingEntityApprovalUpdateStatus: payload.pending_entity_approval_update_status,
|
|
20
28
|
});
|
|
21
29
|
exports.toApprovalRule = toApprovalRule;
|
|
30
|
+
/**
|
|
31
|
+
* Maps the wire-level criteria block into the state-side discriminated
|
|
32
|
+
* `Criteria[]` union.
|
|
33
|
+
*
|
|
34
|
+
* The wire keeps each condition as a flat row inside `conditions[]`.
|
|
35
|
+
* Amount comparisons can show up as a `gte` only, a `lte` only, or a
|
|
36
|
+
* `gte` + `lte` pair — those collapse into a single AmountCriteria whose
|
|
37
|
+
* `comparator` is `greater_than`, `less_than`, or `range` respectively.
|
|
38
|
+
*
|
|
39
|
+
* Vendor and department conditions map one-to-one: `in` becomes `is`,
|
|
40
|
+
* `not_in` becomes `is_not`.
|
|
41
|
+
*/
|
|
22
42
|
const toApprovalCriteria = (payload) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
const results = [];
|
|
44
|
+
const amountCriteria = toAmountCriteria(payload);
|
|
45
|
+
if (amountCriteria != null) {
|
|
46
|
+
results.push(amountCriteria);
|
|
47
|
+
}
|
|
48
|
+
payload.conditions
|
|
49
|
+
.filter((condition) => condition.field === 'vendor_id')
|
|
50
|
+
.forEach((condition) => {
|
|
51
|
+
const vendor = toVendorCriteria(condition);
|
|
52
|
+
if (vendor != null) {
|
|
53
|
+
results.push(vendor);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
payload.conditions
|
|
57
|
+
.filter((condition) => condition.field === 'department_id')
|
|
58
|
+
.forEach((condition) => {
|
|
59
|
+
const department = toDepartmentCriteria(condition);
|
|
60
|
+
if (department != null) {
|
|
61
|
+
results.push(department);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return results;
|
|
65
|
+
};
|
|
66
|
+
const toAmountCriteria = (payload) => {
|
|
67
|
+
const amountConditions = payload.conditions.filter((condition) => condition.field === 'amount');
|
|
68
|
+
const gteCondition = amountConditions.find((condition) => condition.type === 'gte' || condition.type === 'eq');
|
|
69
|
+
const lteCondition = amountConditions.find((condition) => condition.type === 'lte');
|
|
70
|
+
if (gteCondition == null && lteCondition == null) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const min = typeof gteCondition?.value === 'number'
|
|
74
|
+
? (0, amount_1.toAmount)(gteCondition.value, payload.currency_code, payload.currency_symbol)
|
|
75
|
+
: undefined;
|
|
76
|
+
const max = typeof lteCondition?.value === 'number'
|
|
77
|
+
? (0, amount_1.toAmount)(lteCondition.value, payload.currency_code, payload.currency_symbol)
|
|
78
|
+
: undefined;
|
|
79
|
+
let comparator;
|
|
80
|
+
if (min != null && max != null) {
|
|
81
|
+
comparator = 'range';
|
|
82
|
+
}
|
|
83
|
+
else if (min != null) {
|
|
84
|
+
comparator = 'greater_than';
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
comparator = 'less_than';
|
|
88
|
+
}
|
|
89
|
+
return { type: 'amount', comparator, min, max };
|
|
90
|
+
};
|
|
91
|
+
const toVendorCriteria = (condition) => {
|
|
92
|
+
if (!Array.isArray(condition.value)) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
type: 'vendor',
|
|
97
|
+
operator: condition.type === 'not_in' ? 'is_not' : 'is',
|
|
98
|
+
vendorIds: condition.value,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const toDepartmentCriteria = (condition) => {
|
|
102
|
+
if (!Array.isArray(condition.value)) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
type: 'department',
|
|
107
|
+
operator: condition.type === 'not_in' ? 'is_not' : 'is',
|
|
108
|
+
departmentIds: condition.value,
|
|
109
|
+
};
|
|
33
110
|
};
|
|
34
111
|
const toApprovalSteps = (payload) => {
|
|
35
112
|
return payload.map((step) => ({
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { ID } from '../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityType } from '../entityApprovalStatus/entityApprovalStatusState';
|
|
3
|
+
import { AmountCriteria, ApprovalRule, ApprovalRuleState, Criteria, DepartmentCriteria, VendorCriteria } from './approvalRuleState';
|
|
3
4
|
export declare function getApprovalRuleById(approvalRuleState: ApprovalRuleState, approvalRuleId: ID): ApprovalRule | undefined;
|
|
4
5
|
export declare function getApprovalRulesByIds(approvalRuleState: ApprovalRuleState, approvalRuleIds: ID[]): ApprovalRule[];
|
|
6
|
+
/**
|
|
7
|
+
* Returns the amount-range portion of a rule's criteria, if any.
|
|
8
|
+
*
|
|
9
|
+
* Use this whenever a caller needs to read amount min/max from the new
|
|
10
|
+
* discriminated `Criteria` union without inlining a type guard.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAmountCriteria(criteria: Criteria[]): AmountCriteria | undefined;
|
|
13
|
+
export declare function getVendorCriteria(criteria: Criteria[]): VendorCriteria | undefined;
|
|
14
|
+
export declare function getDepartmentCriteria(criteria: Criteria[]): DepartmentCriteria | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Returns all rules of the given entityType, sorted by `priority` ascending.
|
|
17
|
+
*
|
|
18
|
+
* Rules without a `priority` value sort to the end (treated as Infinity).
|
|
19
|
+
* Use this for the list page where rules render in evaluation order.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getApprovalRulesByEntityType(approvalRuleState: ApprovalRuleState, entityType: EntityType): ApprovalRule[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns the tenant's fallback rule for the given entityType, if one exists.
|
|
24
|
+
*
|
|
25
|
+
* The fallback rule is shown by the "fallback engine active" banner on the
|
|
26
|
+
* list page and is used to handle bills/reimbursements that match no other rule.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getFallbackApprovalRule(approvalRuleState: ApprovalRuleState, entityType: EntityType): ApprovalRule | undefined;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getApprovalRuleById = getApprovalRuleById;
|
|
4
4
|
exports.getApprovalRulesByIds = getApprovalRulesByIds;
|
|
5
|
+
exports.getAmountCriteria = getAmountCriteria;
|
|
6
|
+
exports.getVendorCriteria = getVendorCriteria;
|
|
7
|
+
exports.getDepartmentCriteria = getDepartmentCriteria;
|
|
8
|
+
exports.getApprovalRulesByEntityType = getApprovalRulesByEntityType;
|
|
9
|
+
exports.getFallbackApprovalRule = getFallbackApprovalRule;
|
|
5
10
|
function getApprovalRuleById(approvalRuleState, approvalRuleId) {
|
|
6
11
|
return approvalRuleState.approvalRuleById[approvalRuleId] ?? undefined;
|
|
7
12
|
}
|
|
@@ -11,3 +16,38 @@ function getApprovalRulesByIds(approvalRuleState, approvalRuleIds) {
|
|
|
11
16
|
.filter((value) => value != null);
|
|
12
17
|
return approvalRulesByIds;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the amount-range portion of a rule's criteria, if any.
|
|
21
|
+
*
|
|
22
|
+
* Use this whenever a caller needs to read amount min/max from the new
|
|
23
|
+
* discriminated `Criteria` union without inlining a type guard.
|
|
24
|
+
*/
|
|
25
|
+
function getAmountCriteria(criteria) {
|
|
26
|
+
return criteria.find((c) => c.type === 'amount');
|
|
27
|
+
}
|
|
28
|
+
function getVendorCriteria(criteria) {
|
|
29
|
+
return criteria.find((c) => c.type === 'vendor');
|
|
30
|
+
}
|
|
31
|
+
function getDepartmentCriteria(criteria) {
|
|
32
|
+
return criteria.find((c) => c.type === 'department');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns all rules of the given entityType, sorted by `priority` ascending.
|
|
36
|
+
*
|
|
37
|
+
* Rules without a `priority` value sort to the end (treated as Infinity).
|
|
38
|
+
* Use this for the list page where rules render in evaluation order.
|
|
39
|
+
*/
|
|
40
|
+
function getApprovalRulesByEntityType(approvalRuleState, entityType) {
|
|
41
|
+
return Object.values(approvalRuleState.approvalRuleById)
|
|
42
|
+
.filter((rule) => rule.entityType === entityType)
|
|
43
|
+
.sort((a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the tenant's fallback rule for the given entityType, if one exists.
|
|
47
|
+
*
|
|
48
|
+
* The fallback rule is shown by the "fallback engine active" banner on the
|
|
49
|
+
* list page and is used to handle bills/reimbursements that match no other rule.
|
|
50
|
+
*/
|
|
51
|
+
function getFallbackApprovalRule(approvalRuleState, entityType) {
|
|
52
|
+
return Object.values(approvalRuleState.approvalRuleById).find((rule) => rule.entityType === entityType && rule.isFallback === true);
|
|
53
|
+
}
|
|
@@ -25,14 +25,37 @@ export interface Actor {
|
|
|
25
25
|
subType?: AttributeType | RoleType;
|
|
26
26
|
userId?: ID;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Approval rule criteria — discriminated union over the three condition
|
|
30
|
+
* types the wire format supports: amount, vendor, and department.
|
|
31
|
+
*
|
|
32
|
+
* State-side, each rule carries a `Criteria[]` with at most one variant of
|
|
33
|
+
* each kind (e.g. one AmountCriteria + one VendorCriteria + one DepartmentCriteria).
|
|
34
|
+
*
|
|
35
|
+
* Form-side, the rule create/edit form uses `ApprovalRuleFormCriteria`
|
|
36
|
+
* (defined in commonState) — a structured object with named slots for
|
|
37
|
+
* amount/vendor/department. Epics translate between the two.
|
|
38
|
+
*/
|
|
39
|
+
export type AmountComparator = 'greater_than' | 'less_than' | 'range';
|
|
40
|
+
export interface AmountCriteria {
|
|
41
|
+
comparator: AmountComparator;
|
|
42
|
+
type: 'amount';
|
|
43
|
+
/** Upper bound. Present for `less_than` and `range`. */
|
|
44
|
+
max?: Amount;
|
|
45
|
+
/** Lower bound. Present for `greater_than` and `range`. */
|
|
46
|
+
min?: Amount;
|
|
47
|
+
}
|
|
48
|
+
export interface VendorCriteria {
|
|
49
|
+
operator: 'is' | 'is_not';
|
|
50
|
+
type: 'vendor';
|
|
51
|
+
vendorIds: ID[];
|
|
52
|
+
}
|
|
53
|
+
export interface DepartmentCriteria {
|
|
54
|
+
departmentIds: ID[];
|
|
55
|
+
operator: 'is' | 'is_not';
|
|
56
|
+
type: 'department';
|
|
35
57
|
}
|
|
58
|
+
export type Criteria = AmountCriteria | VendorCriteria | DepartmentCriteria;
|
|
36
59
|
export interface Step {
|
|
37
60
|
actors: Actor[];
|
|
38
61
|
operator: StepOperatorType;
|
|
@@ -51,7 +74,25 @@ export interface ApprovalRule {
|
|
|
51
74
|
entityType: EntityType;
|
|
52
75
|
steps: Step[];
|
|
53
76
|
updateTime: ZeniDate;
|
|
77
|
+
/** Backend bookkeeping: whether approval steps must run serialized. */
|
|
78
|
+
areApprovalsSerialized?: boolean;
|
|
79
|
+
/** Free-text description shown beneath the rule name on the list page. */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** True when this rule is the tenant's default fallback rule. */
|
|
82
|
+
isFallback?: boolean;
|
|
54
83
|
name?: string;
|
|
84
|
+
/** Backend bookkeeping: number of entities currently pending against this rule. */
|
|
85
|
+
pendingApprovalsCount?: number;
|
|
86
|
+
/** Backend bookkeeping: status of background updates against this rule. */
|
|
87
|
+
pendingEntityApprovalUpdateStatus?: string;
|
|
88
|
+
/** Rule's position in the evaluation order; lower number = higher priority. */
|
|
89
|
+
priority?: number;
|
|
90
|
+
/**
|
|
91
|
+
* When on, the creator of a bill/reimbursement cannot auto-approve
|
|
92
|
+
* their own request even if they are also an approver. Backend spec
|
|
93
|
+
* is still pending — kept optional for now.
|
|
94
|
+
*/
|
|
95
|
+
separationOfDuties?: boolean;
|
|
55
96
|
version?: number | string;
|
|
56
97
|
}
|
|
57
98
|
export interface Approvers {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Project } from './projectState';
|
|
1
|
+
import { Project, ProjectBase } from './projectState';
|
|
2
2
|
export interface ProjectMetadataPayload {
|
|
3
3
|
accounting_provider_project_customer_id: string | null;
|
|
4
4
|
accounting_provider_project_id: string | null;
|
|
@@ -15,6 +15,6 @@ export interface ProjectBasePayload {
|
|
|
15
15
|
accounting_provider_project_id?: string | null;
|
|
16
16
|
project_name?: string;
|
|
17
17
|
}
|
|
18
|
-
export declare const toProjectBasePayload: (project:
|
|
19
|
-
export declare const
|
|
18
|
+
export declare const toProjectBasePayload: (project: ProjectBase | undefined) => ProjectBasePayload;
|
|
19
|
+
export declare const mapProjectBasePayloadToProjectBase: (payload: ProjectBasePayload) => ProjectBase;
|
|
20
20
|
export declare const mapProjectMetadataPayloadToProject: (payload: ProjectMetadataPayload) => Project;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapProjectMetadataPayloadToProject = exports.
|
|
3
|
+
exports.mapProjectMetadataPayloadToProject = exports.mapProjectBasePayloadToProjectBase = exports.toProjectBasePayload = void 0;
|
|
4
4
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
5
5
|
const toProjectBasePayload = (project) => ({
|
|
6
6
|
zeni_project_id: project?.projectId ?? '',
|
|
@@ -8,14 +8,14 @@ const toProjectBasePayload = (project) => ({
|
|
|
8
8
|
project_name: project?.projectName ?? '',
|
|
9
9
|
});
|
|
10
10
|
exports.toProjectBasePayload = toProjectBasePayload;
|
|
11
|
-
const
|
|
11
|
+
const mapProjectBasePayloadToProjectBase = (payload) => ({
|
|
12
12
|
projectId: payload.zeni_project_id,
|
|
13
13
|
projectName: payload.project_name ?? '',
|
|
14
14
|
...(payload.accounting_provider_project_id != null
|
|
15
15
|
? { accountingProviderProjectId: payload.accounting_provider_project_id }
|
|
16
16
|
: {}),
|
|
17
17
|
});
|
|
18
|
-
exports.
|
|
18
|
+
exports.mapProjectBasePayloadToProjectBase = mapProjectBasePayloadToProjectBase;
|
|
19
19
|
const mapProjectMetadataPayloadToProject = (payload) => ({
|
|
20
20
|
projectId: payload.zeni_project_id,
|
|
21
21
|
projectName: payload.project_name,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ID } from '../../commonStateTypes/common';
|
|
2
2
|
import { ZeniDate } from '../../zeniDayJS';
|
|
3
|
-
export interface
|
|
3
|
+
export interface ProjectBase {
|
|
4
4
|
projectId: ID;
|
|
5
5
|
projectName: string;
|
|
6
|
-
accountingProviderProjectCustomerId?: ID;
|
|
7
6
|
accountingProviderProjectId?: ID;
|
|
7
|
+
}
|
|
8
|
+
export interface Project extends ProjectBase {
|
|
9
|
+
accountingProviderProjectCustomerId?: ID;
|
|
8
10
|
parentCustomerAccountingProviderId?: ID;
|
|
9
11
|
startDate?: ZeniDate;
|
|
10
12
|
status?: string;
|
|
@@ -47,7 +47,7 @@ const toTransactionWithAccountAndClassLine = (payload, currency, type = 'transac
|
|
|
47
47
|
project: payload.line_detail.project != null &&
|
|
48
48
|
payload.line_detail.project.zeni_project_id != null &&
|
|
49
49
|
payload.line_detail.project.zeni_project_id !== ''
|
|
50
|
-
? (0, projectPayload_1.
|
|
50
|
+
? (0, projectPayload_1.mapProjectBasePayloadToProjectBase)(payload.line_detail.project)
|
|
51
51
|
: undefined,
|
|
52
52
|
billable: payload.line_detail.billable_status ?? 'not_billable',
|
|
53
53
|
isCategoryMiscategorized: payload.is_category_miscategorized ?? false,
|
|
@@ -33,6 +33,7 @@ export interface TransactionPayload extends TransactionIDPayload, AccountBasePay
|
|
|
33
33
|
logo?: URLPayload;
|
|
34
34
|
payment_type?: string;
|
|
35
35
|
payment_type_name?: string;
|
|
36
|
+
project_name?: string | null;
|
|
36
37
|
recipient_currency_code?: string;
|
|
37
38
|
recipient_currency_symbol?: string;
|
|
38
39
|
recipient_total_amount?: number;
|
|
@@ -49,6 +50,7 @@ export interface TransactionPayload extends TransactionIDPayload, AccountBasePay
|
|
|
49
50
|
transaction_update_time?: string;
|
|
50
51
|
vendor_id?: string | null;
|
|
51
52
|
vendor_name?: string | null;
|
|
53
|
+
zeni_project_id?: string | null;
|
|
52
54
|
}
|
|
53
55
|
type LinesWithCOTTracking = LinePayload & {
|
|
54
56
|
cot_viewing_flags?: {
|
|
@@ -101,6 +101,12 @@ const toTransaction = (payload) => {
|
|
|
101
101
|
...(payload.class_name != null && payload.class_name !== ''
|
|
102
102
|
? { className: payload.class_name }
|
|
103
103
|
: {}),
|
|
104
|
+
...(payload.zeni_project_id != null && payload.zeni_project_id !== ''
|
|
105
|
+
? { projectId: payload.zeni_project_id }
|
|
106
|
+
: {}),
|
|
107
|
+
...(payload.project_name != null && payload.project_name !== ''
|
|
108
|
+
? { projectName: payload.project_name }
|
|
109
|
+
: {}),
|
|
104
110
|
...(payload.category_name != null && payload.category_name !== ''
|
|
105
111
|
? { categoryName: payload.category_name }
|
|
106
112
|
: {}),
|
|
@@ -4,7 +4,7 @@ import { COTLineItemTracking } from '../../../commonStateTypes/recommendationBas
|
|
|
4
4
|
import { AccountBase } from '../../account/accountState';
|
|
5
5
|
import { ClassBase } from '../../class/classState';
|
|
6
6
|
import { CustomerBase } from '../../customer/customerState';
|
|
7
|
-
import {
|
|
7
|
+
import { ProjectBase } from '../../project/projectState';
|
|
8
8
|
import { VendorBase } from '../../vendor/vendorState';
|
|
9
9
|
import { TransactionID } from './transaction';
|
|
10
10
|
import { TransactionCategory, TransactionType } from './transactionType';
|
|
@@ -40,7 +40,7 @@ export interface TransactionWithAccountAndClassLine extends TransactionLineBase
|
|
|
40
40
|
isClassMiscategorized: boolean;
|
|
41
41
|
class?: ClassBase;
|
|
42
42
|
customer?: CustomerBase;
|
|
43
|
-
project?:
|
|
43
|
+
project?: ProjectBase;
|
|
44
44
|
vendor?: VendorBase;
|
|
45
45
|
}
|
|
46
46
|
export interface TransactionWithAccountAndClassLineWithCOTTracking extends TransactionWithAccountAndClassLine {
|
|
@@ -14,18 +14,95 @@ export const toApprovalRule = (payload) => ({
|
|
|
14
14
|
version: payload.version,
|
|
15
15
|
criteria: toApprovalCriteria(payload.criteria),
|
|
16
16
|
steps: toApprovalSteps(payload.steps),
|
|
17
|
+
description: payload.description ?? undefined,
|
|
18
|
+
priority: payload.priority,
|
|
19
|
+
isFallback: payload.is_fallback ?? false,
|
|
20
|
+
// separationOfDuties: backend doesn't ship this field yet; left undefined
|
|
21
|
+
// until the spec is finalized.
|
|
22
|
+
areApprovalsSerialized: payload.are_approvals_serialized,
|
|
23
|
+
pendingApprovalsCount: payload.pending_approvals_count,
|
|
24
|
+
pendingEntityApprovalUpdateStatus: payload.pending_entity_approval_update_status,
|
|
17
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Maps the wire-level criteria block into the state-side discriminated
|
|
28
|
+
* `Criteria[]` union.
|
|
29
|
+
*
|
|
30
|
+
* The wire keeps each condition as a flat row inside `conditions[]`.
|
|
31
|
+
* Amount comparisons can show up as a `gte` only, a `lte` only, or a
|
|
32
|
+
* `gte` + `lte` pair — those collapse into a single AmountCriteria whose
|
|
33
|
+
* `comparator` is `greater_than`, `less_than`, or `range` respectively.
|
|
34
|
+
*
|
|
35
|
+
* Vendor and department conditions map one-to-one: `in` becomes `is`,
|
|
36
|
+
* `not_in` becomes `is_not`.
|
|
37
|
+
*/
|
|
18
38
|
const toApprovalCriteria = (payload) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
const results = [];
|
|
40
|
+
const amountCriteria = toAmountCriteria(payload);
|
|
41
|
+
if (amountCriteria != null) {
|
|
42
|
+
results.push(amountCriteria);
|
|
43
|
+
}
|
|
44
|
+
payload.conditions
|
|
45
|
+
.filter((condition) => condition.field === 'vendor_id')
|
|
46
|
+
.forEach((condition) => {
|
|
47
|
+
const vendor = toVendorCriteria(condition);
|
|
48
|
+
if (vendor != null) {
|
|
49
|
+
results.push(vendor);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
payload.conditions
|
|
53
|
+
.filter((condition) => condition.field === 'department_id')
|
|
54
|
+
.forEach((condition) => {
|
|
55
|
+
const department = toDepartmentCriteria(condition);
|
|
56
|
+
if (department != null) {
|
|
57
|
+
results.push(department);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return results;
|
|
61
|
+
};
|
|
62
|
+
const toAmountCriteria = (payload) => {
|
|
63
|
+
const amountConditions = payload.conditions.filter((condition) => condition.field === 'amount');
|
|
64
|
+
const gteCondition = amountConditions.find((condition) => condition.type === 'gte' || condition.type === 'eq');
|
|
65
|
+
const lteCondition = amountConditions.find((condition) => condition.type === 'lte');
|
|
66
|
+
if (gteCondition == null && lteCondition == null) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const min = typeof gteCondition?.value === 'number'
|
|
70
|
+
? toAmount(gteCondition.value, payload.currency_code, payload.currency_symbol)
|
|
71
|
+
: undefined;
|
|
72
|
+
const max = typeof lteCondition?.value === 'number'
|
|
73
|
+
? toAmount(lteCondition.value, payload.currency_code, payload.currency_symbol)
|
|
74
|
+
: undefined;
|
|
75
|
+
let comparator;
|
|
76
|
+
if (min != null && max != null) {
|
|
77
|
+
comparator = 'range';
|
|
78
|
+
}
|
|
79
|
+
else if (min != null) {
|
|
80
|
+
comparator = 'greater_than';
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
comparator = 'less_than';
|
|
84
|
+
}
|
|
85
|
+
return { type: 'amount', comparator, min, max };
|
|
86
|
+
};
|
|
87
|
+
const toVendorCriteria = (condition) => {
|
|
88
|
+
if (!Array.isArray(condition.value)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
type: 'vendor',
|
|
93
|
+
operator: condition.type === 'not_in' ? 'is_not' : 'is',
|
|
94
|
+
vendorIds: condition.value,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const toDepartmentCriteria = (condition) => {
|
|
98
|
+
if (!Array.isArray(condition.value)) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
type: 'department',
|
|
103
|
+
operator: condition.type === 'not_in' ? 'is_not' : 'is',
|
|
104
|
+
departmentIds: condition.value,
|
|
105
|
+
};
|
|
29
106
|
};
|
|
30
107
|
const toApprovalSteps = (payload) => {
|
|
31
108
|
return payload.map((step) => ({
|
|
@@ -7,3 +7,38 @@ export function getApprovalRulesByIds(approvalRuleState, approvalRuleIds) {
|
|
|
7
7
|
.filter((value) => value != null);
|
|
8
8
|
return approvalRulesByIds;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns the amount-range portion of a rule's criteria, if any.
|
|
12
|
+
*
|
|
13
|
+
* Use this whenever a caller needs to read amount min/max from the new
|
|
14
|
+
* discriminated `Criteria` union without inlining a type guard.
|
|
15
|
+
*/
|
|
16
|
+
export function getAmountCriteria(criteria) {
|
|
17
|
+
return criteria.find((c) => c.type === 'amount');
|
|
18
|
+
}
|
|
19
|
+
export function getVendorCriteria(criteria) {
|
|
20
|
+
return criteria.find((c) => c.type === 'vendor');
|
|
21
|
+
}
|
|
22
|
+
export function getDepartmentCriteria(criteria) {
|
|
23
|
+
return criteria.find((c) => c.type === 'department');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns all rules of the given entityType, sorted by `priority` ascending.
|
|
27
|
+
*
|
|
28
|
+
* Rules without a `priority` value sort to the end (treated as Infinity).
|
|
29
|
+
* Use this for the list page where rules render in evaluation order.
|
|
30
|
+
*/
|
|
31
|
+
export function getApprovalRulesByEntityType(approvalRuleState, entityType) {
|
|
32
|
+
return Object.values(approvalRuleState.approvalRuleById)
|
|
33
|
+
.filter((rule) => rule.entityType === entityType)
|
|
34
|
+
.sort((a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the tenant's fallback rule for the given entityType, if one exists.
|
|
38
|
+
*
|
|
39
|
+
* The fallback rule is shown by the "fallback engine active" banner on the
|
|
40
|
+
* list page and is used to handle bills/reimbursements that match no other rule.
|
|
41
|
+
*/
|
|
42
|
+
export function getFallbackApprovalRule(approvalRuleState, entityType) {
|
|
43
|
+
return Object.values(approvalRuleState.approvalRuleById).find((rule) => rule.entityType === entityType && rule.isFallback === true);
|
|
44
|
+
}
|
|
@@ -4,7 +4,7 @@ export const toProjectBasePayload = (project) => ({
|
|
|
4
4
|
accounting_provider_project_id: project?.accountingProviderProjectId ?? null,
|
|
5
5
|
project_name: project?.projectName ?? '',
|
|
6
6
|
});
|
|
7
|
-
export const
|
|
7
|
+
export const mapProjectBasePayloadToProjectBase = (payload) => ({
|
|
8
8
|
projectId: payload.zeni_project_id,
|
|
9
9
|
projectName: payload.project_name ?? '',
|
|
10
10
|
...(payload.accounting_provider_project_id != null
|
|
@@ -2,7 +2,7 @@ import { toAmountWC } from '../../../commonStateTypes/amount';
|
|
|
2
2
|
import { mapAccountBasePayloadToAccountBase, toAccountPayload, } from '../../account/accountPayload';
|
|
3
3
|
import { mapClassBasePayloadToClassBase, toClassBasePayload, } from '../../class/classPayload';
|
|
4
4
|
import { toCustomerBase, toCustomerBasePayload, } from '../../customer/customerPayload';
|
|
5
|
-
import {
|
|
5
|
+
import { mapProjectBasePayloadToProjectBase, toProjectBasePayload, } from '../../project/projectPayload';
|
|
6
6
|
import { mapVendorBasePayloadToVendorBase, toVendorBasePayload, } from '../../vendor/vendorPayload';
|
|
7
7
|
import { toCategorizationStatusType, toPlatformLineDetailType, } from '../stateTypes/transactionLine';
|
|
8
8
|
import { toTransactionCategory, toTransactionType, } from '../stateTypes/transactionType';
|
|
@@ -43,7 +43,7 @@ export const toTransactionWithAccountAndClassLine = (payload, currency, type = '
|
|
|
43
43
|
project: payload.line_detail.project != null &&
|
|
44
44
|
payload.line_detail.project.zeni_project_id != null &&
|
|
45
45
|
payload.line_detail.project.zeni_project_id !== ''
|
|
46
|
-
?
|
|
46
|
+
? mapProjectBasePayloadToProjectBase(payload.line_detail.project)
|
|
47
47
|
: undefined,
|
|
48
48
|
billable: payload.line_detail.billable_status ?? 'not_billable',
|
|
49
49
|
isCategoryMiscategorized: payload.is_category_miscategorized ?? false,
|
|
@@ -97,6 +97,12 @@ export const toTransaction = (payload) => {
|
|
|
97
97
|
...(payload.class_name != null && payload.class_name !== ''
|
|
98
98
|
? { className: payload.class_name }
|
|
99
99
|
: {}),
|
|
100
|
+
...(payload.zeni_project_id != null && payload.zeni_project_id !== ''
|
|
101
|
+
? { projectId: payload.zeni_project_id }
|
|
102
|
+
: {}),
|
|
103
|
+
...(payload.project_name != null && payload.project_name !== ''
|
|
104
|
+
? { projectName: payload.project_name }
|
|
105
|
+
: {}),
|
|
100
106
|
...(payload.category_name != null && payload.category_name !== ''
|
|
101
107
|
? { categoryName: payload.category_name }
|
|
102
108
|
: {}),
|
package/lib/esm/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import { getAccountGroupKey, toAccountGroupType, } from './entity/accountGroup/a
|
|
|
31
31
|
import { getAccountReconByAccountIdAndSelectedPeriod, } from './entity/accountRecon/accountReconSelector';
|
|
32
32
|
import { getAddressByAddressId } from './entity/address/addressSelector';
|
|
33
33
|
import { toAttributeOrRoleTypeStrict, toAttributeTypeStrict, toRoleTypeStrict, } from './entity/approvalRule/approvalRuleState';
|
|
34
|
+
import { getAmountCriteria, getApprovalRulesByEntityType, getDepartmentCriteria, getFallbackApprovalRule, getVendorCriteria, } from './entity/approvalRule/approvalRuleSelector';
|
|
34
35
|
import { toOutsideZeniPaymentModeType, } from './entity/billPay/billTransaction/billTransactionState';
|
|
35
36
|
import { toRecurringBillFrequency, toRecurringBillFrequencyStrict, } from './entity/billPay/recurringBills/recurringBillsState';
|
|
36
37
|
import { toCardAddressType, toCardType, toCreditLimitFrequencyCodeType, toShippingAddressType, } from './entity/chargeCard/chargeCard';
|
|
@@ -559,7 +560,7 @@ export { getUserFinancialAccount };
|
|
|
559
560
|
export { fetchRemiSetupView, updateMileageDetails, saveRemiSetupViewDataInLocalStore, acceptRemiTerms, acceptEmployeeRemiTerms, clearRemiSetupView, getRemiSetupViewDetails, getRemiBusinessVerificationDetails, };
|
|
560
561
|
export { VERIFIED_PAYMENT_ACCOUNT_PROVIDER_VERIFICATION_STATUS, };
|
|
561
562
|
export { isSuccessResponse, isInvalidSessionError, isAccessDeniedError, };
|
|
562
|
-
export { toAttributeTypeStrict, toAttributeOrRoleTypeStrict, toRoleTypeStrict, };
|
|
563
|
+
export { getAmountCriteria, getApprovalRulesByEntityType, getDepartmentCriteria, getFallbackApprovalRule, getVendorCriteria, toAttributeTypeStrict, toAttributeOrRoleTypeStrict, toRoleTypeStrict, };
|
|
563
564
|
export { getBillPaySetupApproverView, getBillPaySetupApproverUpdateDataView, fetchBillPaySetupApproverView, fetchBillPayApproversDetails, fetchBillPayApproversList, deleteBillPayApprovalRule, saveBillPaySetupApproverViewUpdateData, saveBillPaySetupApproverViewUpdates, setBillsSetupApproverViewListeningToPusherEvent, initializeBillPaySetupApproverViewUpdateData, clearBillPaySetupApproverViewUpdateData, clearBillPaySetupApproverView, };
|
|
564
565
|
export { getRemiSetupApproverView, getRemiSetupApproverUpdateDataView, fetchRemiSetupApproverView, fetchRemiApproversList, fetchRemiApproversDetails, deleteRemiApprovalRule, saveRemiSetupApproverViewUpdateData, saveRemiSetupApproverViewUpdates, initializeRemiSetupApproverViewUpdateData, setRemiSetupApproverViewListeningToPusherEvent, clearRemiSetupApproverViewUpdateData, clearRemiSetupApproverView, };
|
|
565
566
|
export { getRemiDetailView, checkApproveRejectBtnShowForRemi, };
|