sahab-utils 1.4.0 → 1.7.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 +86 -0
- package/dist/constants/types.d.ts +963 -749
- package/dist/constants/types.js +102 -82
- package/dist/index.d.ts +4 -2
- package/dist/index.js +20 -18
- package/dist/ts/calcs.d.ts +34 -34
- package/dist/ts/calcs.js +295 -385
- package/dist/ts/gifts.d.ts +97 -0
- package/dist/ts/gifts.js +201 -0
- package/dist/ts/loyalty.d.ts +79 -0
- package/dist/ts/loyalty.js +222 -0
- package/dist/ts/utils.d.ts +3 -3
- package/dist/ts/utils.js +24 -24
- package/package.json +37 -36
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
|