@rentman/rm-core 63.4.1-blr-01 → 63.4.1

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.
Files changed (74) hide show
  1. package/dist/rm-core.js +1 -1
  2. package/dist/rm-core.js.map +1 -1
  3. package/dist/types/src/classes/BusinessLogicManager/AantalBusinessLogicRuleBase.d.ts +11 -9
  4. package/dist/types/src/classes/BusinessLogicManager/AantaltotaalBusinessLogicRuleBase.d.ts +11 -12
  5. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicManager.d.ts +7 -6
  6. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRule.d.ts +9 -2
  7. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleApplyContext.d.ts +10 -3
  8. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleConditionContext.d.ts +17 -5
  9. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleContextBase.d.ts +55 -4
  10. package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldLinkedItemTypeBusinessLogicRule.d.ts +1 -2
  11. package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldTypeBusinessLogicRule.d.ts +1 -2
  12. package/dist/types/src/classes/BusinessLogicManager/DefaultContactPersonUpdateBusinessLogicRule.d.ts +13 -34
  13. package/dist/types/src/classes/BusinessLogicManager/Documents/DocumentTemplateBusinessLogicRule.d.ts +2 -3
  14. package/dist/types/src/classes/BusinessLogicManager/Exemplaar/ExemplaarAanschafdatumBusinessLogicRule.d.ts +1 -2
  15. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurBetalingsconditieBusinessLogicRule.d.ts +6 -11
  16. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurDatumBusinessLogicRule.d.ts +4 -5
  17. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurNumberseriesBusinessLogicRule.d.ts +1 -2
  18. package/dist/types/src/classes/BusinessLogicManager/Files/FilesNameExtensionBusinessLogicRule.d.ts +2 -3
  19. package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieNaaminternBusinessLogicRule.d.ts +1 -2
  20. package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieTwowayBusinessLogicRule.d.ts +1 -2
  21. package/dist/types/src/classes/BusinessLogicManager/Functie/functieTravelDistanceUtils.d.ts +1 -1
  22. package/dist/types/src/classes/BusinessLogicManager/Functiegroep/FunctiegroepSubprojectBusinessLogicRule.d.ts +3 -9
  23. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalBulkToSerialBusinessLogicRule.d.ts +2 -4
  24. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalSerialToBulkBusinessLogicRule.d.ts +2 -4
  25. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalVerhuurBusinessLogicRule.d.ts +2 -2
  26. package/dist/types/src/classes/BusinessLogicManager/Materiaal/SurfaceArticleSizeBusinessLogicRule.d.ts +10 -2
  27. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemBusinessLogicRuleBase.d.ts +17 -10
  28. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemDurationBusinessLogicRule.d.ts +4 -4
  29. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemMateriaalCatBusinessLogicRule.d.ts +7 -6
  30. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemSubprojectBusinessLogicRule.d.ts +20 -5
  31. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeBusinessLogicRule.d.ts +5 -7
  32. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeStartBusinessLogicRule.d.ts +5 -7
  33. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeValueStartBusinessLogicRule.d.ts +5 -6
  34. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/TimeColumnUtil.d.ts +1 -1
  35. package/dist/types/src/classes/BusinessLogicManager/OfferteContract/OfferteContractDatumBusinessLogicRule.d.ts +2 -3
  36. package/dist/types/src/classes/BusinessLogicManager/PlanningPersoneelTransport/PlanningPersoneelTransportBusinessLogicRule.d.ts +4 -6
  37. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalOptieBusinessLogicRule.d.ts +1 -1
  38. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalParentBusinessLogicRule.d.ts +3 -1
  39. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalStaysAtLocationBusinessLogicRule.d.ts +10 -3
  40. package/dist/types/src/classes/BusinessLogicManager/Project/ProjectContactProjectNoteBusinessLogicRule.d.ts +3 -5
  41. package/dist/types/src/classes/BusinessLogicManager/Project/ProjectOneSubLocationAlignBusinessRule.d.ts +2 -4
  42. package/dist/types/src/classes/BusinessLogicManager/Rate/RateDeactivateExistingOnCreateBusinessLogicRule.d.ts +1 -2
  43. package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieExemplaarAantalBusinessLogicRule.d.ts +1 -2
  44. package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieLostItemExemplaarLocationBusinessLogicRule.d.ts +1 -2
  45. package/dist/types/src/classes/BusinessLogicManager/Rol/RolEditOwnDataBusinessLogicRule.d.ts +3 -2
  46. package/dist/types/src/classes/BusinessLogicManager/Rol/RolPersoneelsplannerToegangBusinessLogicRule.d.ts +3 -2
  47. package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenBewerkenBusinessLogicRule.d.ts +3 -2
  48. package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenToegangBusinessLogicRule.d.ts +4 -2
  49. package/dist/types/src/classes/BusinessLogicManager/Rol/RolVisibilityFinancialsBusinessLogicRule.d.ts +7 -2
  50. package/dist/types/src/classes/BusinessLogicManager/Rol/RolWarehosueTrackingLogAccessBusinessLogicRule.d.ts +3 -2
  51. package/dist/types/src/classes/BusinessLogicManager/Setinhoud/SetinhoudCreateFixedBusinessLogicRule.d.ts +4 -4
  52. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectInPlanningBusinessLogicRule.d.ts +1 -2
  53. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubLocationAlignBusinessRule.d.ts +2 -4
  54. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubNameAlignBusinessRule.d.ts +2 -4
  55. package/dist/types/src/classes/BusinessLogicManager/Taak/TaakDeadlineOffsetBusinessLogicRule.d.ts +2 -2
  56. package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdPropagateNameToFunctiegroepBusinessLogicRule.d.ts +2 -4
  57. package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdSubprojectChangedBusinessLogicRule.d.ts +2 -6
  58. package/dist/types/src/classes/BusinessLogicManager/Uren/HoursTypeBusinessLogicRuleBase.d.ts +2 -1
  59. package/dist/types/src/classes/ChangesDelta.d.ts +9 -7
  60. package/dist/types/src/classes/ChangesDeltaBase.d.ts +14 -11
  61. package/dist/types/src/classes/ChangesProcessor.d.ts +3 -3
  62. package/dist/types/src/classes/ChildChangesDelta.d.ts +7 -18
  63. package/dist/types/src/classes/CreatedChangesDelta.d.ts +2 -2
  64. package/dist/types/src/classes/ParentChangesDelta.d.ts +6 -7
  65. package/dist/types/src/classes/SocketMessageHandler.d.ts +2 -4
  66. package/dist/types/src/classes/Util.d.ts +0 -1
  67. package/dist/types/src/classes/cache/AbstractCache.d.ts +6 -1
  68. package/dist/types/src/classes/cache/server/ServerCache.d.ts +2 -4
  69. package/dist/types/src/classes/cache/transaction/TransactionCache.d.ts +23 -69
  70. package/dist/types/src/core.d.ts +2 -0
  71. package/dist/types/src/factories/ChangesCompilationFactory.d.ts +5 -0
  72. package/dist/types/src/interfaces/ServerCacheDependencyInterface.d.ts +2 -1
  73. package/dist/types/src/internal.d.ts +1 -0
  74. package/package.json +2 -2
@@ -2,22 +2,24 @@ import { ItemId } from '@rentman/backend-types';
2
2
  import { ItemResource } from '../../models/ItemResource';
3
3
  import { GetFieldValueType } from '../../types/ItemTypesCollection';
4
4
  import { TransactionCache } from '../cache/transaction/TransactionCache';
5
+ import { ChangesDeltaItemCreateDelta } from '../CreatedChangesDelta';
5
6
  import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
6
7
  import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
7
8
  import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
8
9
  import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
9
10
  export declare const commonEquipmentColumns: readonly ["id", "aantal", "parent", "materiaal"];
10
- type MateriaalPropertiesMap = {
11
- [equipmentId: number]: {
12
- is_physical: GetFieldValueType<'Materiaal', 'is_physical'>;
13
- is_combination: GetFieldValueType<'Materiaal', 'is_combination'>;
14
- };
11
+ type MateriaalTypeMap = {
12
+ [equipmentId: number]: GetFieldValueType<'Materiaal', 'type'>;
15
13
  };
16
14
  type MateriaalType = 'Planningmateriaal' | 'Inhuurmateriaal';
17
- type ConditionResult<ItemTypeType extends MateriaalType> = ItemId<ItemTypeType>[];
15
+ type ConditionResult<ItemTypeType extends MateriaalType> = {
16
+ created: ChangesDeltaItemCreateDelta<ItemTypeType>[];
17
+ updated: ItemId[];
18
+ };
18
19
  type Dependency<ItemTypeType extends MateriaalType> = {
19
- itemResources: ItemResource<ItemTypeType, typeof commonEquipmentColumns>[];
20
- materiaalPropertiesMap: MateriaalPropertiesMap;
20
+ createdTuples: ChangesDeltaItemCreateDelta<ItemTypeType>[];
21
+ updatedItemResources: ItemResource<ItemTypeType, typeof commonEquipmentColumns>[];
22
+ materiaalTypeMap: MateriaalTypeMap;
21
23
  };
22
24
  /**
23
25
  * @description
@@ -29,6 +31,6 @@ export declare abstract class AantalBusinessLogicRuleBase<ItemTypeType extends M
29
31
  condition({ previousChangesDelta, transaction, }: BusinessLogicRuleConditionContext): ConditionResult<ItemTypeType> | typeof BLR_SKIP_RULE;
30
32
  dependency(transaction: TransactionCache, conditionResult: ConditionResult<ItemTypeType>, context: BusinessLogicRuleContextBase): Promise<Dependency<ItemTypeType>>;
31
33
  apply(context: BusinessLogicRuleApplyContext, dependency: Dependency<ItemTypeType>): void;
32
- private getMateriaalPropertiesMap;
34
+ private getMateriaalTypeMap;
33
35
  }
34
36
  export {};
@@ -1,20 +1,19 @@
1
1
  import { ItemId } from '@rentman/backend-types';
2
- import { ItemResource } from '../../models/ItemResource';
3
2
  import { TransactionCache } from '../cache/transaction/TransactionCache';
4
3
  import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
5
4
  import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
6
5
  import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
7
- import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
6
+ import { BusinessLogicRuleContextBase, LatestItem } from './BusinessLogicRuleContextBase';
8
7
  declare const commonEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal"];
9
8
  export declare const plannedEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal", "categorie"];
10
9
  export declare const subhireEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal", "inhuurgroep"];
11
10
  type PlannedEquipmentItemType = 'Planningmateriaal' | 'Inhuurmateriaal';
12
- type PlannedEquipmentItem<ItemTypeType extends PlannedEquipmentItemType> = {
13
- Planningmateriaal: ItemResource<'Planningmateriaal', typeof commonEquipmentColumns>;
14
- Inhuurmateriaal: ItemResource<'Inhuurmateriaal', typeof commonEquipmentColumns>;
11
+ type LatestEquipmentItem<ItemTypeType extends PlannedEquipmentItemType> = {
12
+ Planningmateriaal: LatestItem<'Planningmateriaal', typeof commonEquipmentColumns>;
13
+ Inhuurmateriaal: LatestItem<'Inhuurmateriaal', typeof commonEquipmentColumns>;
15
14
  }[ItemTypeType];
16
- type PlannedEquipmentItemIdMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId, PlannedEquipmentItem<ItemTypeType>>;
17
- type PlannedEquipmentItemParentMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId | null, PlannedEquipmentItem<ItemTypeType>[]>;
15
+ type LatestEquipmentItemIdMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId, LatestEquipmentItem<ItemTypeType>>;
16
+ type LatestEquipmentItemParentMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId | null, LatestEquipmentItem<ItemTypeType>[]>;
18
17
  type EquipmentIsPhysicalMap = Map<ItemId<'Materiaal'> | null, boolean>;
19
18
  interface Dependency<ItemTypeType extends PlannedEquipmentItemType> {
20
19
  /**
@@ -27,8 +26,8 @@ interface Dependency<ItemTypeType extends PlannedEquipmentItemType> {
27
26
  * descendants of the created / updated items. The ancestors to determine the root items, and the descendants
28
27
  * because their total quantity will change as well.
29
28
  */
30
- affectedEquipmentItemsByParent: PlannedEquipmentItemParentMap<ItemTypeType>;
31
- affectedEquipmentItemsById: PlannedEquipmentItemIdMap<ItemTypeType>;
29
+ affectedEquipmentItemsByParent: LatestEquipmentItemParentMap<ItemTypeType>;
30
+ affectedEquipmentItemsById: LatestEquipmentItemIdMap<ItemTypeType>;
32
31
  equipmentIsPhysicalMap: EquipmentIsPhysicalMap;
33
32
  }
34
33
  /**
@@ -36,7 +35,7 @@ interface Dependency<ItemTypeType extends PlannedEquipmentItemType> {
36
35
  * If Planningmateriaal total is changed recalculate the fields
37
36
  * Note: We're assuming 'aantal' is fractional only for sets here.
38
37
  */
39
- export declare abstract class AantaltotaalBusinessLogicRuleBase<ItemTypeType extends PlannedEquipmentItemType> extends BusinessLogicRule<ItemId<ItemTypeType>[], Dependency<ItemTypeType>> {
38
+ export declare abstract class AantaltotaalBusinessLogicRuleBase<ItemTypeType extends PlannedEquipmentItemType> extends BusinessLogicRule<LatestEquipmentItem<ItemTypeType>[], Dependency<ItemTypeType>> {
40
39
  protected abstract readonly itemType: ItemTypeType;
41
40
  protected abstract readonly groupingProperties: {
42
41
  Planningmateriaal: {
@@ -52,8 +51,8 @@ export declare abstract class AantaltotaalBusinessLogicRuleBase<ItemTypeType ext
52
51
  Planningmateriaal: typeof plannedEquipmentColumns;
53
52
  Inhuurmateriaal: typeof subhireEquipmentColumns;
54
53
  }[ItemTypeType];
55
- condition(context: BusinessLogicRuleConditionContext): ItemId<ItemTypeType>[] | typeof BLR_SKIP_RULE;
56
- dependency(transaction: TransactionCache, affectedEquipmentItemIds: ItemId<ItemTypeType>[], context: BusinessLogicRuleContextBase): Promise<Dependency<ItemTypeType>>;
54
+ condition(context: BusinessLogicRuleConditionContext): Promise<LatestEquipmentItem<ItemTypeType>[] | typeof BLR_SKIP_RULE>;
55
+ dependency(transaction: TransactionCache, affectedEquipmentItems: LatestEquipmentItem<ItemTypeType>[], context: BusinessLogicRuleContextBase): Promise<Dependency<ItemTypeType>>;
57
56
  apply(context: BusinessLogicRuleApplyContext, dependency: Dependency<ItemTypeType>): void;
58
57
  private fetchEquipmentIsPhysicalMap;
59
58
  private updatePlannedEquipmentItem;
@@ -50,14 +50,15 @@ export declare class BusinessLogicManager {
50
50
  * - In a third iteration (2nd recursive call) the `Functie.kilometerprijs` has no business logic, so the function
51
51
  * exits early (`rulesToRun.size === 0`) and the recursion ends
52
52
  *
53
- * @param businessLogicTransaction The transaction the ChangesDelta will be applied on.
54
- * @param changesDelta - A changes delta containing source changes.
53
+ * @param transaction The transaction the ChangesDelta will be applied on
54
+ * @param mergedChangesDelta - A changes delta containing the source changes, plus the changes made during *all*
55
+ * previous rule application cycles.
56
+ * @param previousChangesDelta - A changes delta containing source changes, *or* the changes made during the last
57
+ * rule application cycle only. Should be used to determine whether the business logic rule should run.
55
58
  *
56
- * @returns A child transaction where the business logic has been applied.
57
- *
58
- * @private Should only be called by the core.
59
+ * @private should only be called by the core
59
60
  */
60
- handleBusinessLogic(transaction: TransactionCache, changesDelta: ChangesDelta): Promise<TransactionCache | null>;
61
+ handleBusinessLogic(transaction: TransactionCache, mergedChangesDelta: ChangesDelta, previousChangesDelta?: ChangesDelta): Promise<ChangesDelta | null>;
61
62
  private findBusinessLogicRuleInstance;
62
63
  private applyRules;
63
64
  private waitForRuleDependencies;
@@ -1,5 +1,6 @@
1
- import { ApiModuleFunctionResponse } from '@rentman/backend-types';
2
- import { GetAccountSettignsFn, HasFlagFn } from '../../types/ItemTypesCollection';
1
+ import { ApiItemType, ApiModuleFunctionResponse, ResponseColumn } from '@rentman/backend-types';
2
+ import { ItemEntry } from '../../models/ItemEntry';
3
+ import { GetAccountSettignsFn, GetFieldValueType, HasFlagFn, ItemTypeColumnId } from '../../types/ItemTypesCollection';
3
4
  import { TransactionCache } from '../cache/transaction/TransactionCache';
4
5
  import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
5
6
  import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
@@ -23,6 +24,12 @@ export interface RuleDependencyResultTuple extends RuleConditionResultTuple {
23
24
  type MaybePromise<T> = T | Promise<T>;
24
25
  export type BusinessLogicRuleConditionConfirmFn<ConditionResult, ConfirmResult> = (conditionResult: ConditionResult, transaction: TransactionCache) => MaybePromise<ConfirmResult | typeof BLR_SKIP_RULE | typeof BLR_ABANDON_CHANGES | typeof BLR_CONTINUE_WITH_DEFAULTS>;
25
26
  export type BusinessLogicRuleConfirmFnWithDependency<ConditionResult, Dependency, ConfirmResult> = (conditionResult: ConditionResult, dependency: Dependency, transaction: TransactionCache) => MaybePromise<ConfirmResult | typeof BLR_SKIP_RULE | typeof BLR_ABANDON_CHANGES | typeof BLR_CONTINUE_WITH_DEFAULTS>;
27
+ export type BusinessLogicConditionResult<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>> = {
28
+ itemEntry: ItemEntry<ItemTypeType>;
29
+ responseColumn: ResponseColumn<ItemTypeType, ColumnId>;
30
+ oldValue: GetFieldValueType<ItemTypeType, ColumnId>;
31
+ newValue: GetFieldValueType<ItemTypeType, ColumnId>;
32
+ };
26
33
  /**
27
34
  * @description
28
35
  * A business rule is a class that does some data transformation depending on other fields.
@@ -1,9 +1,8 @@
1
1
  import { ApiItemType } from '@rentman/backend-types';
2
2
  import { ItemEntry } from '../../models/ItemEntry';
3
- import { FieldMap } from '../../types/ItemTypesCollection';
3
+ import { FieldMap, GetFieldValueType, ItemTypeColumnId } from '../../types/ItemTypesCollection';
4
4
  import { TransactionCache } from '../cache/transaction/TransactionCache';
5
5
  import { ChangesDelta } from '../ChangesDelta';
6
- import { ParentChangesDelta } from '../ParentChangesDelta';
7
6
  import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
8
7
  /**
9
8
  * Class that represents the context for the business logic rule `apply()` function.
@@ -13,13 +12,21 @@ export declare class BusinessLogicRuleApplyContext extends BusinessLogicRuleCont
13
12
  /**
14
13
  * @param destinationChangesDelta - Changes should be written to this changes delta.
15
14
  */
16
- constructor(transactionCache: TransactionCache, previousChangesDelta: ParentChangesDelta, destinationChangesDelta: ChangesDelta);
15
+ constructor(transactionCache: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta, destinationChangesDelta: ChangesDelta);
17
16
  /**
18
17
  * An alias for `destinationChangesDelta.setItemUpdated().
18
+ *
19
+ * In most cases, `setUpdatedValue()`, would be preferred, because it only sets the value when differs from the
20
+ * current value.
19
21
  */
20
22
  setItemUpdated<ItemTypeType extends ApiItemType>(entry: ItemEntry<ItemTypeType>, fields: Partial<FieldMap<ItemTypeType>>): void;
21
23
  /**
22
24
  * An alias for `destinationChangesDelta.setItemsDeleted().
23
25
  */
24
26
  setItemsDeleted<ItemTypeType extends ApiItemType>(entries: ItemEntry<ItemTypeType>[]): void;
27
+ /**
28
+ * Convenience function to write an updated value to the destination changes delta. Only sets the value when differs
29
+ * from the current value.
30
+ */
31
+ setUpdatedValue<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(entry: ItemEntry<ItemTypeType>, columnId: ColumnId, newValue: GetFieldValueType<ItemTypeType, ColumnId>): void;
25
32
  }
@@ -1,17 +1,29 @@
1
1
  import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ErrorHandlerInterface } from '../../interfaces/ErrorHandlerInterface';
2
3
  import { GetFieldValueType, ItemTypeColumnId } from '../../types/ItemTypesCollection';
3
4
  import { TransactionCache } from '../cache/transaction/TransactionCache';
4
- import { ParentChangesDelta } from '../ParentChangesDelta';
5
- import { BLR_SKIP_RULE } from './BusinessLogicRule';
5
+ import { ChangesDelta, ChangesDeltaItemUpdateDelta } from '../ChangesDelta';
6
+ import { BLR_SKIP_RULE, BusinessLogicConditionResult } from './BusinessLogicRule';
6
7
  import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
7
8
  /**
8
9
  * Class that represents the context for the business logic rule `condition()` function.
9
10
  *
10
- * Please note that, while the transaction and previous changes delta are available on the
11
+ * Please note that, while the transaction, merged changes delta and previous changes delta are available on the
11
12
  * class instance, using the helper functions is preferred.
12
13
  */
13
14
  export declare class BusinessLogicRuleConditionContext extends BusinessLogicRuleContextBase {
14
- constructor(transaction: TransactionCache, previousChangesDelta: ParentChangesDelta);
15
+ private errorHandler;
16
+ constructor(transaction: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta, errorHandler: ErrorHandlerInterface);
17
+ /**
18
+ * @description
19
+ * This function will compare the stored changes with the given changes, and return a
20
+ * {@link BusinessLogicConditionResult} if the fields have been changed, `null` otherwise.
21
+ * If either the source or changed field is `undefined` it will always return `null` (not changed)
22
+ *
23
+ * @param tuple The {@link ChangesDelta.updated update tuple} from a ChangesDelta
24
+ * @param columnId The columnId of the field that should've been changed for the ID to be included
25
+ */
26
+ fieldChanged<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(tuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, columnId: ColumnId): null | BusinessLogicConditionResult<ItemTypeType, ColumnId>;
15
27
  /**
16
28
  * This function is a utility function that will return the {@link ItemId ItemIds} of updated items in the
17
29
  * {@link ChangesDelta ChangesDelta} which match the {@link ApiItemType ItemType} and of which the provided
@@ -20,7 +32,7 @@ export declare class BusinessLogicRuleConditionContext extends BusinessLogicRule
20
32
  * @param itemType The ItemType of the item you want to compare a field from
21
33
  * @param columnId The columnId of the field that should've been changed for the ID to be included
22
34
  */
23
- getItemIdsWithUpdatedField<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, columnId: ItemTypeColumnId<ItemTypeType>, includeCreatedItems?: boolean): ItemId[] | typeof BLR_SKIP_RULE;
35
+ getItemIdsWithUpdatedField<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, columnId: ItemTypeColumnId<ItemTypeType>): ItemId[] | typeof BLR_SKIP_RULE;
24
36
  /**
25
37
  * Like {@link getItemIdsWithUpdatedField}, but allows for a new value to be provided. Only IDs of items where the
26
38
  * field has been updated to the new value will be included in the result.
@@ -1,7 +1,58 @@
1
- import { TransactionCache } from '../cache/transaction/TransactionCache';
2
- import { ParentChangesDelta } from '../ParentChangesDelta';
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ChangesDelta, ChangesDeltaItemCreateDelta, ChangesDeltaItemUpdateDelta, FieldMap, GetFieldValueType, ItemEntry, ItemTypeColumnId, TransactionCache } from '../../internal';
3
+ export type LatestItemColumnsArray<ItemTypeType extends ApiItemType> = readonly ItemTypeColumnId<ItemTypeType>[];
4
+ export type UpdatedLatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>> = {
5
+ itemEntry: ItemEntry<ItemTypeType>;
6
+ updatedTuple?: ChangesDeltaItemUpdateDelta<ItemTypeType>;
7
+ fields: FieldMap<ItemTypeType, ColumnIds>;
8
+ };
9
+ /**
10
+ * A 'latest' item can either be:
11
+ * - A created changes delta (for created items).
12
+ * - An object containing an item entry and a `fields` property (for updated items). The `fields` property will
13
+ * read updated values from the changes delta if available.
14
+ *
15
+ * In both cases, we can access the latest values through the `fields` property.
16
+ */
17
+ export type LatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>> = UpdatedLatestItem<ItemTypeType, ColumnIds> | ChangesDeltaItemCreateDelta<ItemTypeType>;
3
18
  export declare abstract class BusinessLogicRuleContextBase {
4
19
  readonly transaction: TransactionCache;
5
- readonly previousChangesDelta: ParentChangesDelta;
6
- protected constructor(transaction: TransactionCache, previousChangesDelta: ParentChangesDelta);
20
+ readonly previousChangesDelta: ChangesDelta;
21
+ readonly mergedChangesDelta: ChangesDelta;
22
+ /**
23
+ * @param transaction - The transaction the business logic rule is being applied on.
24
+ * @param previousChangesDelta - A changes delta containing source changes, *or* the changes made during the last
25
+ * rule application cycle only. Should be used to determine whether the business logic rule should run.
26
+ * @param mergedChangesDelta - A changes delta containing the source changes, plus the changes made during *all*
27
+ * previous rule application cycles.
28
+ */
29
+ protected constructor(transaction: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta);
30
+ /**
31
+ * This function will get the latest value of the given itemEntry by first looking in the merged changes delta.
32
+ * It will return the value found in the transaction chain otherwise.
33
+ *
34
+ * You could assume this function never returns `undefined` if you fetch the resource in your dependency function.
35
+ */
36
+ getLatestValue<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(entry: ItemEntry<ItemTypeType>, columnId: ColumnId): GetFieldValueType<ItemTypeType, ColumnId> | undefined;
37
+ isUpdatedLatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(latestItem: LatestItem<ItemTypeType, ColumnIds>): latestItem is UpdatedLatestItem<ItemTypeType, ColumnIds>;
38
+ collectFields<ItemTypeType extends ApiItemType>(latestItem: LatestItem<ItemTypeType, any>): FieldMap<ItemTypeType>;
39
+ /**
40
+ * The equivalent of `getLinkCollections` on the transaction. Returns an array of 'latest' items for each parent
41
+ * ID. Covers the merged changes delta as well as the transaction. Currently doesn't take deleted items into account.
42
+ *
43
+ * TODO: Instead of replicating transaction functionality in the business rule context, we should apply business
44
+ * logic rules on a child transaction.
45
+ */
46
+ fetchLatestItemsByParent<ParentItemType extends ApiItemType, ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(parentItemType: ParentItemType, parentItemIds: ItemId<ParentItemType>[], itemType: ItemTypeType, requestColumns: ColumnIds): Promise<Map<ItemId<ParentItemType>, LatestItem<ItemTypeType, ColumnIds>[]>>;
47
+ /**
48
+ * This method should only be used when we're sure the items do not occur in the created changes. Generally,
49
+ * {@link fetchLatestItemsById} should be used instead.
50
+ */
51
+ fetchUpdatedLatestItemsById<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(itemType: ItemTypeType, itemIds: ItemId[], requestColumns: ColumnIds): Promise<UpdatedLatestItem<ItemTypeType, ColumnIds>[]>;
52
+ /**
53
+ * Returns an array of {@link LatestItem}s, taking both changes on the transaction and the merged changes delta into
54
+ * account.
55
+ */
56
+ fetchLatestItemsById<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(itemType: ItemTypeType, itemIds: Iterable<ItemId>, requestColumns: ColumnIds): Promise<LatestItem<ItemTypeType, ColumnIds>[]>;
57
+ private constructLatestItems;
7
58
  }
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const customfieldColumns: readonly ["defaultvalue"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Customfield', typeof customfieldColumns>[];
8
+ type Dependency = ItemResource<'Customfield', ['defaultvalue']>[];
10
9
  /**
11
10
  * @description
12
11
  * If the 'type' field changes we reset the 'defaultvalue' and 'attribute' fields so that they do not contain invalid values
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const customfieldColumns: readonly ["defaultvalue", "attributes", "type"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Customfield', typeof customfieldColumns>[];
8
+ type Dependency = ItemResource<'Customfield', ['defaultvalue', 'attributes', 'type']>[];
10
9
  /**
11
10
  * @description
12
11
  * If the 'type' field changes we reset the 'defaultvalue' and 'attribute' fields so that they do not contain invalid values
@@ -1,51 +1,30 @@
1
- import { ItemId } from '@rentman/backend-types';
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
2
  import { ItemEntry } from '../../models/ItemEntry';
3
3
  import { ItemResource } from '../../models/ItemResource';
4
+ import { ItemTypeColumnId } from '../../types/ItemTypesCollection';
4
5
  import { TransactionCache } from '../cache/transaction/TransactionCache';
5
6
  import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
6
7
  import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
7
8
  import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
8
- export declare const itemTypeFieldMap: {
9
- readonly Offerte: {
10
- readonly opdrachtgever: "contactpersoon";
11
- };
12
- readonly Contract: {
13
- readonly opdrachtgever: "contactpersoon";
14
- };
15
- readonly Factuur: {
16
- readonly opdrachtgever: "contactpersoon";
17
- };
18
- readonly Project: {
19
- readonly opdrachtgever: "opdrachtgever_persoon";
20
- readonly locatie: "locatie_persoon";
21
- };
22
- readonly Subproject: {
23
- readonly locatie: "locatie_persoon";
24
- };
25
- readonly Inhuur: {
26
- readonly locatie: "locatie_persoon";
27
- readonly leverancier: "contactpersoon";
28
- };
29
- readonly ProjectRequest: {
30
- readonly aanvrager: "accountmanager";
31
- };
32
- };
33
- type ItemTypeFieldMap = typeof itemTypeFieldMap;
34
- type ItemTypeWithContactPerson = keyof ItemTypeFieldMap;
35
9
  type ConditionResult = {
36
- [ItemTypeType in ItemTypeWithContactPerson]?: Map<ItemEntry<ItemTypeType>, {
37
- [ColumnId in keyof ItemTypeFieldMap[ItemTypeType]]?: ItemId<'Contact'>;
10
+ [ItemTypeType in ApiItemType]?: Map<ItemEntry, {
11
+ [ColumnId in ItemTypeColumnId<ItemTypeType>]?: ItemId<'Contact'>;
38
12
  }>;
39
13
  };
40
- declare const constactColumns: readonly ["id", "contactpersoon"];
41
- type Dependency = ItemResource<'Contact', typeof constactColumns>[];
14
+ declare const dependencyColumns: readonly ["id", "contactpersoon"];
15
+ type Dependency = {
16
+ conditionResult: ConditionResult;
17
+ contactMap: {
18
+ [contactId: string]: ItemResource<'Contact', typeof dependencyColumns>;
19
+ };
20
+ };
42
21
  /**
43
- * This business rule is responsible for setting the default contact person related to a
22
+ * This business rule is responsible for setting the default contactperson related to a
44
23
  * selected contact for itemTypes that have fields for this.
45
24
  */
46
25
  export declare class DefaultContactPersonUpdateBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
47
26
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
48
27
  dependency(transaction: TransactionCache, conditionResult: ConditionResult): Promise<Dependency>;
49
- apply(context: BusinessLogicRuleApplyContext, contactResources: Dependency, conditionResult: ConditionResult): void;
28
+ apply(context: BusinessLogicRuleApplyContext, dependencyResult: Dependency): void;
50
29
  }
51
30
  export {};
@@ -4,14 +4,13 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- export declare const documentTypes: readonly ["Factuur", "Offerte", "Contract", "Bon", "Inhuurbon", "Materiaalbon", "Medewerkerbon", "Aanmaning", "Reparatiebon", "Voertuigbon"];
7
+ declare const documentTypes: readonly ["Factuur", "Offerte", "Contract", "Bon", "Inhuurbon", "Materiaalbon", "Medewerkerbon", "Aanmaning", "Reparatiebon", "Voertuigbon"];
8
8
  type DocumentTypes = (typeof documentTypes)[number];
9
- declare const documentColumns: readonly ["filename", "betreft"];
10
9
  type ConditionResult = {
11
10
  [key in DocumentTypes]?: ItemId[];
12
11
  };
13
12
  type Dependency = {
14
- [key in DocumentTypes]?: ItemResource<DocumentTypes, typeof documentColumns>[];
13
+ [key in DocumentTypes]?: ItemResource<DocumentTypes, ['filename', 'betreft']>[];
15
14
  };
16
15
  export declare class DocumentTemplateBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
17
16
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const exemplaarColumns: readonly ["actief"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Exemplaar', typeof exemplaarColumns>[];
8
+ type Dependency = ItemResource<'Exemplaar', ['actief']>[];
10
9
  export declare class ExemplaarAanschafdatumBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
11
10
  condition({ previousChangesDelta, }: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
12
11
  dependency(transaction: TransactionCache, exemplaarIds: ConditionResult): Promise<Dependency>;
@@ -1,26 +1,21 @@
1
1
  import { ItemId } from '@rentman/backend-types';
2
2
  import { ItemResource } from '../../../models/ItemResource';
3
3
  import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
- import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
4
+ import { BLR_SKIP_RULE, BusinessLogicConditionResult, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const factuurColumns: readonly ["vervaldatum", "datum", "betalingsconditie"];
8
- declare const betalingsconditieColumns: readonly ["id", "dagen"];
9
- type ConditionResult = ItemId<'Factuur'>[];
7
+ import { BusinessLogicRuleContextBase } from '../BusinessLogicRuleContextBase';
8
+ type ConditionResult = BusinessLogicConditionResult<'Factuur', 'betalingsconditie'>[];
10
9
  type Dependency = {
11
- Factuur: ItemResource<'Factuur', typeof factuurColumns>[];
10
+ Factuur: ItemResource<'Factuur', ['vervaldatum', 'datum']>[];
12
11
  Betalingsconditie: {
13
- [conditieId: string]: ItemResource<'Betalingsconditie', typeof betalingsconditieColumns>;
12
+ [conditieId: string]: ItemResource<'Betalingsconditie', ['dagen']>;
14
13
  };
15
14
  defaultPaymentConditionId: ItemId | null;
16
15
  };
17
- /**
18
- * When setting the payment condition of an invoice, set the relevant due date.
19
- * TODO: Test this.
20
- */
21
16
  export declare class FactuurBetalingsconditieBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
22
17
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
23
- dependency(transaction: TransactionCache, result: ConditionResult): Promise<Dependency>;
18
+ dependency(transaction: TransactionCache, result: ConditionResult, context: BusinessLogicRuleContextBase): Promise<Dependency>;
24
19
  apply(context: BusinessLogicRuleApplyContext, deps: Dependency): void;
25
20
  }
26
21
  export {};
@@ -4,13 +4,12 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const factuurColumns: readonly ["id", "taxschema", "vervaldatum", "betalingsconditie", "datum"];
8
- declare const betalingsconditieColumns: readonly ["id", "dagen"];
7
+ import { BusinessLogicRuleContextBase } from '../BusinessLogicRuleContextBase';
9
8
  type ConditionResult = ItemId[];
10
9
  type Dependency = {
11
- Factuur: ItemResource<'Factuur', typeof factuurColumns>[];
10
+ Factuur: ItemResource<'Factuur', ['vervaldatum', 'betalingsconditie']>[];
12
11
  Betalingsconditie: {
13
- [conditieId: string]: ItemResource<'Betalingsconditie', typeof betalingsconditieColumns>;
12
+ [conditieId: string]: ItemResource<'Betalingsconditie', ['dagen']>;
14
13
  };
15
14
  latestTaxSchemasByDateMap: {
16
15
  [taxschemaId: string]: ItemId<'TaxSchema'>;
@@ -18,7 +17,7 @@ type Dependency = {
18
17
  };
19
18
  export declare class FactuurDatumBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
20
19
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
21
- dependency(transaction: TransactionCache, factuurIds: ConditionResult): Promise<Dependency>;
20
+ dependency(transaction: TransactionCache, factuurIds: ConditionResult, context: BusinessLogicRuleContextBase): Promise<Dependency>;
22
21
  apply(context: BusinessLogicRuleApplyContext, deps: Dependency): void;
23
22
  }
24
23
  export {};
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const factuurColumns: readonly ["nummer"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Factuur', typeof factuurColumns>[];
8
+ type Dependency = ItemResource<'Factuur', ['nummer']>[];
10
9
  export declare class FactuurNumberseriesBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
11
10
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
12
11
  dependency(transaction: TransactionCache, factuurIds: ConditionResult): Promise<Dependency>;
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- type ConditionResult = ItemId<'Files'>[];
8
- declare const filesColumns: readonly ["name", "friendlyname"];
9
- type Dependency = ItemResource<'Files', typeof filesColumns>[];
7
+ type ConditionResult = ItemId[];
8
+ type Dependency = ItemResource<'Files', ['name', 'friendlyname']>[];
10
9
  /**
11
10
  * @description
12
11
  * Automatically appends the file extension again when the user removes it from the name
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const functieColumns: readonly ["naamintern", "naamofferte"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Functie', typeof functieColumns>[];
8
+ type Dependency = ItemResource<'Functie', ['naamintern']>[];
10
9
  /**
11
10
  * @description
12
11
  * If the `naamofferte` is set and the user hasn't filled in a `naamintern` we sync the fields
@@ -4,9 +4,8 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const functieColumns: readonly ["afstand", "twoway"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Functie', typeof functieColumns>[];
8
+ type Dependency = ItemResource<'Functie', ['afstand']>[];
10
9
  export declare class FunctieTwowayBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
11
10
  condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
12
11
  dependency(transaction: TransactionCache, functionIds: ConditionResult): Promise<Dependency>;
@@ -1,6 +1,6 @@
1
1
  import { ItemResource } from '../../../models/ItemResource';
2
2
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
3
- export declare const functieTravelDistanceColumns: readonly ["twoway", "afstand", "afstand_van_locatie", {
3
+ export declare const functieTravelDistanceColumns: readonly ["twoway", {
4
4
  readonly subproject: readonly [{
5
5
  readonly locatie: readonly ["kilometers"];
6
6
  }];
@@ -1,16 +1,10 @@
1
- import { ItemId } from '@rentman/backend-types';
2
- import { ItemEntry } from '../../../models/ItemEntry';
3
1
  import { ItemResource } from '../../../models/ItemResource';
4
2
  import { TransactionCache } from '../../cache/transaction/TransactionCache';
5
- import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
3
+ import { BLR_SKIP_RULE, BusinessLogicConditionResult, BusinessLogicRule } from '../BusinessLogicRule';
6
4
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
7
5
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
8
- declare const functieColumns: readonly ["subproject"];
9
- type ConditionResult = {
10
- itemEntry: ItemEntry<'Functiegroep'>;
11
- newValue: ItemId<'Subproject'>;
12
- }[];
13
- type Dependency = ItemResource<'Functie', typeof functieColumns>[][];
6
+ type ConditionResult = BusinessLogicConditionResult<'Functiegroep', 'subproject'>[];
7
+ type Dependency = ItemResource<'Functie', ['subproject']>[][];
14
8
  /**
15
9
  * When the subproject field of a function group is updated, set the subproject field of all the functions within the
16
10
  * function group to the same value.
@@ -1,15 +1,13 @@
1
1
  import { ItemId } from '@rentman/backend-types';
2
2
  import { BLR_SKIP_RULE, BusinessLogicRule, BusinessLogicRuleApplyContext, BusinessLogicRuleConditionContext, ItemEntry, ItemResource, TransactionCache } from '../../../internal';
3
- declare const materiaalColumns: readonly ["is_combination"];
4
- declare const containerContentColumns: readonly ["equipment"];
5
3
  export type ConditionResult = ItemId[];
6
4
  type Dependency = {
7
5
  voorraadmutatieTuples: {
8
6
  local: ItemEntry<'Voorraadmutatie'>[];
9
7
  remote: ItemEntry<'Voorraadmutatie'>[];
10
8
  };
11
- materiaalResources: ItemResource<'Materiaal', typeof materiaalColumns>[];
12
- containerContentResources: ItemResource<'ContainerContent', typeof containerContentColumns>[];
9
+ materiaalResources: ItemResource<'Materiaal', ['is_combination']>[];
10
+ containerContentResources: ItemResource<'ContainerContent', ['equipment']>[];
13
11
  };
14
12
  export declare class MateriaalBulkToSerialBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
15
13
  dependency(transaction: TransactionCache, materiaalIds: ConditionResult): Promise<Dependency>;
@@ -3,12 +3,10 @@ import { ItemResource } from '../../../models/ItemResource';
3
3
  import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
6
- declare const materiaalColumns: readonly ["is_combination"];
7
- declare const containerContentColumns: readonly ["equipment"];
8
6
  type ConditionResult = ItemId[];
9
7
  type Dependency = {
10
- materiaalResources: ItemResource<'Materiaal', typeof materiaalColumns>[];
11
- containerContentResources: ItemResource<'ContainerContent', typeof containerContentColumns>[];
8
+ materiaalResources: ItemResource<'Materiaal', ['is_combination']>[];
9
+ containerContentResources: ItemResource<'ContainerContent', ['equipment']>[];
12
10
  };
13
11
  export declare class MateriaalSerialToBulkBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
14
12
  dependency(transaction: TransactionCache, materiaalIds: ConditionResult): Promise<Dependency>;
@@ -4,11 +4,11 @@ import { TransactionCache } from '../../cache/transaction/TransactionCache';
4
4
  import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
5
5
  import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
6
6
  import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
7
- declare const materiaalColumns: readonly ["is_combination", "is_physical"];
8
7
  type ConditionResult = ItemId[];
9
- type Dependency = ItemResource<'Materiaal', typeof materiaalColumns>[];
8
+ type Dependency = ItemResource<'Materiaal', ['type']>[];
10
9
  /**
11
10
  * @description
11
+ * A sales item can never be a case, so if it is we reset it to an item
12
12
  * A physical sales item can never be a combination, if it is we set it to a single item
13
13
  */
14
14
  export declare class MateriaalVerhuurBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {