sahab-utils 1.3.0 → 1.6.0

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/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # sahab-utils
2
+
3
+ Utility helpers and shared TypeScript types for Sahab order pricing, loyalty, and related business logic.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install sahab-utils
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import {
15
+ getCustomerTotalToPay,
16
+ getProviderTransferAmount,
17
+ getSahabFees,
18
+ applyLoyaltyStamp,
19
+ redeemLoyaltyReward,
20
+ OrderPaymentType,
21
+ OrderStatus,
22
+ } from 'sahab-utils';
23
+ ```
24
+
25
+ ## What is included
26
+
27
+ ### Pricing and calculation helpers
28
+
29
+ The package exports functions for working with order totals and discounts, including:
30
+
31
+ - `getServicesTotal(order)`
32
+ - `getSahabDiscountsAmount(order)`
33
+ - `getProviderDiscountsAmount(order)`
34
+ - `getOrderTotalDiscountsAmount(order)`
35
+ - `getCustomerTotalToPay(order)`
36
+ - `getProviderTransferAmount(order)`
37
+ - `getProviderProfits(order)`
38
+ - `getOnlineProcessingFees(order)`
39
+ - `getSahabFees(order)`
40
+ - `calcOrdersData(orders)`
41
+
42
+ ### Loyalty helpers
43
+
44
+ The package also includes loyalty-flow utilities for buy-X-get-Y offers:
45
+
46
+ - `loyaltyProviderScope(offer)`
47
+ - `loyaltyCoversProvider(offer, providerUid)`
48
+ - `orderEarnsLoyaltyStamp(order, offer)`
49
+ - `emptyLoyaltyProgress(clientId, offer)`
50
+ - `applyLoyaltyStamp(progress, order, offer)`
51
+ - `stampsRemaining(progress, offer)`
52
+ - `hasLoyaltyReward(progress)`
53
+ - `loyaltyRewardValue(order, offer)`
54
+ - `redeemLoyaltyReward(order, offer)`
55
+
56
+ ### Shared types and enums
57
+
58
+ The package exposes common domain types such as:
59
+
60
+ - `Order`
61
+ - `Discount`
62
+ - `Client`
63
+ - `Car`
64
+ - `Price`
65
+ - `OrderStatus`
66
+ - `OrderPaymentType`
67
+ - `MovementType`
68
+ - `ComplaintType`
69
+
70
+ ## Development
71
+
72
+ Build the package:
73
+
74
+ ```bash
75
+ npm run build
76
+ ```
77
+
78
+ Deploy the package:
79
+
80
+ ```bash
81
+ npm run deploy
82
+ ```
83
+
84
+ ## License
85
+
86
+ ISC