350 Commits

Author SHA1 Message Date
b3013eb2f2 add: check unique trx id error 2023-12-15 13:32:33 +07:00
e58d359cae fix: added failed reason on failed transaction 2023-12-12 15:03:52 +07:00
f9ad9eb473 fix: sending raw data in error message 2023-12-05 22:58:51 +07:00
b66b296292 fix :
- fix error metro
2023-10-30 13:41:46 +07:00
cbeae3c404 fix :
- trace error metro
2023-10-30 13:21:20 +07:00
d9c8917fd6 feat :
- implement vocagame supplier in prod
2023-10-05 23:49:08 +07:00
034a666729 -comment order prod condition 2023-10-02 11:38:03 +07:00
3f78367ce4 -uncomment order prod condition 2023-09-21 01:02:57 +07:00
5defbff687 -logs callback voca 2023-09-21 00:55:06 +07:00
b4a1259de6 -logs callback voca 2023-09-21 00:47:00 +07:00
26cb992c96 - fix code voca in subcategory column 2023-09-21 00:39:18 +07:00
8324e1c50b - fix code voca in subcategory column 2023-09-21 00:29:41 +07:00
6438c66397 - fix code voca in subcategory column 2023-09-21 00:23:10 +07:00
3aeef208af - fix code voca in subcategory column 2023-09-21 00:10:01 +07:00
844d5f4571 - fix code voca in subcategory column 2023-09-21 00:03:16 +07:00
56967904dd - fix code voca in subcategory column 2023-09-20 23:54:58 +07:00
b3c514483c - fix code voca in subcategory column 2023-09-20 23:52:30 +07:00
f707e0836e - fix code voca in subcategory column 2023-09-20 23:41:17 +07:00
3b246e9ebc - fix code voca in subcategory column 2023-09-20 23:31:23 +07:00
04270e20f2 - fix code voca in subcategory column 2023-09-20 23:25:17 +07:00
395a59b287 - fix code voca in subcategory column 2023-09-20 23:15:21 +07:00
ed962c24c8 - fix code voca in subcategory column 2023-09-20 23:09:52 +07:00
2f470ad69f - log code sub category 2023-09-20 23:01:07 +07:00
e030ca897f - comment order-prod condition to test vocagames 2023-09-20 22:23:34 +07:00
28f98de87c - integrating vocagame supplier 2023-09-20 22:07:06 +07:00
8f731226ee - fix when base url stg cannot order on prod 2023-09-14 15:02:36 +07:00
e4811a4ad6 - fix response elang when balance supplier not enough 2023-09-12 13:04:38 +07:00
49d435a70e - fix response hemat 2023-09-01 02:46:19 +07:00
a04d597d8f - fix response hemat 2023-08-31 21:40:11 +07:00
6d52cf2a45 - fix response hemat 2023-08-31 21:35:52 +07:00
320a0ca5a5 - fix response error elang 2023-08-31 16:17:14 +07:00
2faf5967b2 - fix response error elang 2023-08-31 15:59:13 +07:00
e367bc4fcc - fix response error elang 2023-08-31 15:44:13 +07:00
4477178f2e - fix response error elang 2023-08-31 15:38:40 +07:00
2217917bc8 - fix response error elang 2023-08-31 15:36:34 +07:00
d5d48480ee - fix response error elang 2023-08-31 15:24:33 +07:00
fd5ee9655e - fix update price hemat 2023-08-30 17:33:34 +07:00
b9bc034492 - added logs tracing hemat 2023-08-30 03:00:26 +07:00
b15b685a7b - added logs tracing hemat 2023-08-29 23:02:48 +07:00
25e59eb086 - added logs tracing hemat 2023-08-29 22:55:16 +07:00
a3b8d474df - fix when saldo supplier not enough change response 2023-08-28 20:49:35 +07:00
7eb19b5ad1 - fix response failed added what caused failed transaction 2023-08-23 12:49:36 +07:00
f0706cb887 - fix response failed added what caused failed transaction 2023-08-02 00:23:05 +07:00
c902af56b7 - fix response failed added what caused failed transaction 2023-08-02 00:03:46 +07:00
808e41b391 - added filter by user and by supplier for export 2023-06-21 21:08:12 +07:00
9c2143d214 - added filter by user and by supplier for export 2023-06-21 20:01:20 +07:00
86b0bd8e68 - fix check bill send callback to partner 2023-05-30 10:46:05 +07:00
3e30a64bf0 - fix check bill send callback to partner 2023-05-30 10:45:07 +07:00
8481294c17 - fix check bill send callback to partner 2023-05-29 22:13:04 +07:00
3a6d6b5d34 - fix check bill send callback to partner 2023-05-29 14:41:42 +07:00
054cf676b5 - added logs for check bill 2023-05-29 13:50:49 +07:00
ae0a031d0a - fix metro supplier when getting success from link aja serial number is missing 2023-05-15 16:33:23 +07:00
253f1af8f8 - fix insert to table callback_partner when callback to url partner 2023-05-10 16:25:16 +07:00
f4c25af886 - fix insert to table callback_partner when callback to url partner 2023-05-10 16:09:30 +07:00
401c91f66d - Added filter by Partner Trx Id for transaction history 2023-05-10 15:00:07 +07:00
8d15f6f4be - Added filter by Partner Trx Id for transaction history 2023-05-10 14:14:10 +07:00
5d039499e5 - added filter by trxId in history transaction 2023-05-09 14:45:29 +07:00
dbb363983b - added between dates when exporting excel transaction history 2023-05-04 00:22:54 +07:00
8e9295a806 - fix get product partner hide markup price 2023-04-28 19:58:47 +07:00
0dd35e0baa - fix get product partner hide markup price 2023-04-28 19:47:21 +07:00
f0be8ca067 - fix get product partner hide markup price 2023-04-28 19:13:23 +07:00
8943d8b8ac - fix error metro 2023-04-21 12:12:10 +07:00
5cf8c7661c - fix error metro 2023-04-21 12:07:57 +07:00
704fad0895 - fix error metro 2023-04-21 12:01:24 +07:00
c6e0e44608 - fix error metro 2023-04-21 11:43:49 +07:00
4570790514 - push logs 2023-04-21 11:37:40 +07:00
0fb2e1d6fa - push logs 2023-04-21 11:31:53 +07:00
de3ce1adab - push logs 2023-04-21 11:26:59 +07:00
cbd65eb6c8 - push logs 2023-04-21 11:20:56 +07:00
Fadli
c98472c607 - added update sub categories for updating product csv 2023-04-11 11:20:51 +07:00
Fadli
1ca568ded4 - added update sub categories for updating product csv 2023-04-11 11:05:51 +07:00
Fadli
0e4d535ba3 - fix metro when response error 2023-04-03 20:18:29 +07:00
Fadli
56c27736a7 - fix sending check bill 2023-03-30 10:58:42 +07:00
Fadli
b657df70a8 - fix error respon when balance is not enough 2023-03-09 10:57:54 +07:00
Fadli
cfc13d60af - fix elang callback 2023-03-02 13:32:30 +07:00
Fadli
ab9b0c1907 - fix elang callback 2023-03-02 13:29:46 +07:00
Fadli
75425aca4a - push logs digiflazz for prod 2023-03-01 23:15:27 +07:00
Fadli
c93230b4b9 - update digiflazz for prod 2023-03-01 03:28:21 +07:00
Fadli
c06ca8f2c0 - fix digiflazz when receiving response 2023-03-01 02:55:20 +07:00
Fadli
7e79075c1d - log digiflazz when receiving response 2023-03-01 02:51:00 +07:00
Fadli
7d519f0510 - fix digiflazz when receiving response and callback 2023-03-01 02:45:17 +07:00
Fadli
b31e360633 - fix digiflazz postpaid
- fix digiflazz when receiving response
2023-03-01 02:29:00 +07:00
Fadli
4df19347bb - push digiflazz supplier add md5 lib 2023-03-01 02:11:56 +07:00
Fadli
fd8c50a01c - push digiflazz supplier add md5 lib 2023-03-01 02:04:58 +07:00
Fadli
4ce15f7499 - push digiflazz supplier add md5 lib 2023-03-01 01:33:22 +07:00
Fadli
b1c2afe555 - log digiflazz supplier 2023-02-28 16:11:11 +07:00
Fadli
fe2b6aa264 - log digiflazz supplier 2023-02-28 15:13:31 +07:00
Fadli
8ebd2a6622 - log digiflazz supplier 2023-02-28 14:38:49 +07:00
Fadli
7e83212df7 - log digiflazz supplier 2023-02-23 00:51:19 +07:00
Fadli
21afb05910 - log digiflazz supplier 2023-02-23 00:03:09 +07:00
Fadli
adabcaf98d - log digiflazz supplier 2023-02-22 23:57:18 +07:00
Fadli
b2edca7f39 - log digiflazz supplier 2023-02-22 23:52:00 +07:00
Fadli
64ae88357f - log digiflazz supplier 2023-02-22 23:42:16 +07:00
Fadli
e7e3e09d88 - log digiflazz supplier 2023-02-22 23:30:49 +07:00
Fadli
62593684f6 - log digiflazz supplier 2023-02-22 23:12:53 +07:00
Fadli
b645ed273c - log digiflazz supplier 2023-02-22 23:07:29 +07:00
Fadli
763d30f789 - log digiflazz supplier 2023-02-22 23:00:31 +07:00
Fadli
55b27631ba - log digiflazz supplier 2023-02-22 22:52:44 +07:00
Fadli
deced5f847 - log digiflazz supplier 2023-02-22 22:40:04 +07:00
Fadli
8bd3fadefc - log digiflazz supplier 2023-02-22 22:28:39 +07:00
Fadli
2cf3c8ad93 - log digiflazz supplier 2023-02-22 22:24:23 +07:00
Fadli
69b77b7561 - log digiflazz supplier 2023-02-22 22:12:56 +07:00
Fadli
fe801ef816 - log digiflazz supplier 2023-02-22 21:43:34 +07:00
Fadli
3705fbf151 - log digiflazz supplier 2023-02-22 21:33:54 +07:00
Fadli
23df673907 - fix digiflazz supplier 2023-02-22 21:24:09 +07:00
Fadli
576f57cd47 - add log for digiflazz 2023-02-22 20:55:11 +07:00
Fadli
cfb7d035f6 - added digiflazz supplier 2023-02-22 20:48:34 +07:00
Fadli
5463d1b12b - added digiflazz supplier 2023-02-22 19:07:32 +07:00
Fadli
823dbf1912 - added digiflazz supplier 2023-02-22 18:50:32 +07:00
Fadli
04d2ed62ec - added supplier name for role admin 2023-02-09 23:07:32 +07:00
Fadli
05690dcf5a - fix export data excel transaction 2023-02-06 17:42:04 +07:00
Fadli
cc7bc3fc6b - fix export data excel transaction 2023-01-11 15:31:26 +07:00
Fadli
ee0e4c4947 - fix export data excel transaction 2023-01-11 15:01:11 +07:00
Fadli
359659bdf7 - fix callback success hemat save to db 2023-01-10 23:27:40 +07:00
Fadli
add1b4c00e - fix balance remaining when failed 2023-01-10 22:00:26 +07:00
Fadli
7e4573488d - fix date format export transaction history 2023-01-10 14:52:23 +07:00
Fadli
02ef3a1a68 - fix hemat supplier transaction manual update 2023-01-10 13:27:17 +07:00
Fadli
80ecfa290c - fix hemat supplier transaction manual update 2023-01-10 12:59:47 +07:00
Fadli
dfc4e6b688 - push logs distribute saldo admin 2023-01-07 01:21:35 +07:00
Fadli
1ea59d2254 - change type data to bigint 2023-01-07 01:17:28 +07:00
Fadli
5367541079 Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into development 2023-01-06 16:11:57 +07:00
Fadli
03f3c1b7fb - fix balance_remaining transaction table callback gagal 2023-01-06 16:11:41 +07:00
ilham
38bdfcefd0 fix: change balance_remaining tu numeric 2023-01-06 15:40:00 +07:00
ilham
5d203ef8b0 fix: change column 2023-01-06 13:28:14 +07:00
ilham
7bda0ab5d4 fix: turn off sync 2023-01-06 13:23:52 +07:00
Fadli
bc7c5d71ba - add logger for distrbute saldo 2023-01-06 12:19:23 +07:00
Fadli
7c7c811b52 - add logger for distrbute saldo 2023-01-06 11:55:28 +07:00
Fadli
da1f593a53 - add logger for coa name 2023-01-04 02:07:59 +07:00
Fadli
4bf9d254e0 - fix format datetime transaction history export excel 2023-01-03 16:38:09 +07:00
Fadli
9db0c6a714 - add error if data not found export transaction history 2023-01-01 16:23:27 +07:00
Fadli
b06f96c95b - remove filename for excel histori transaksi 2023-01-01 15:37:46 +07:00
Fadli
e9eff08281 - add filename for excel histori transaksi 2023-01-01 15:20:53 +07:00
Fadli
e67ee94e07 - add design for export xlsx transaction history 2022-12-29 17:52:14 +07:00
Fadli
de3ce740f0 - fix total profit b2b 2022-12-29 16:30:58 +07:00
Fadli
af797919fd - add excel export for history transaction 2022-12-29 13:17:38 +07:00
Fadli
dbf7fa6af5 fix on proccess check bill doesn't insert on db 2022-12-20 01:39:34 +07:00
Fadli
621de03f32 - add type product in list product b2c 2022-12-19 22:59:39 +07:00
Fadli
f4e6c5ac3c - push logs send callback 2022-12-15 15:39:38 +07:00
Fadli
7f412abfa7 - fix order stg 2022-12-08 16:07:37 +07:00
Fadli
f3f22d1beb - fix order stg 2022-12-08 16:04:47 +07:00
Fadli
8e6fe1b164 - fix error message when balance supplier is not enough 2022-11-29 00:01:54 +07:00
Fadli
c3c1433197 - fix transaction error in metro 2022-11-24 22:31:04 +07:00
Fadli
071dd2f0ef - add id array for transaction 2022-11-22 13:11:11 +07:00
Fadli
3178c1f4c6 - add id array for transaction 2022-11-22 13:06:23 +07:00
Fadli
47459631ca - fix get product price in transaction 2022-11-21 16:34:10 +07:00
Fadli
0b8ce4967d - fix get product price in transaction 2022-11-21 16:22:34 +07:00
Fadli
12bd13fea7 - fix generate id for transaction 2022-11-18 16:06:51 +07:00
Fadli
cf19989ed9 - fix generate id for transaction 2022-11-18 16:00:41 +07:00
Fadli
da2fd4fdf1 - fix generate id for transaction 2022-11-18 15:39:05 +07:00
Fadli
5da58302fb - fix when response is PLN Quota with user name using space 2022-11-17 12:27:59 +07:00
Fadli
b46f82f775 - fix when response is PLN Quota with user name using space 2022-11-17 03:10:00 +07:00
Fadli
e8974a91c0 - fix when response is PLN Quota with user name using space 2022-11-17 02:44:41 +07:00
Fadli
340849905e - fix when response is PLN Quota with user name using space 2022-11-16 23:56:32 +07:00
Fadli
a819f08dad - fix when response is PLN Quota with user name using space 2022-11-16 23:53:03 +07:00
Fadli
33aca34917 - fix when response is PLN Quota with user name using space 2022-11-16 12:15:42 +07:00
Fadli
cb23ec16ae - fix when response is PLN Quota with user name using space 2022-11-16 00:17:53 +07:00
Fadli
0e61523dab - push total commision 2022-10-28 11:10:50 +07:00
Fadli
ead1a6efa4 - add hemat when transaction failed or success update to db 2022-10-27 00:12:24 +07:00
Fadli
7f76d10062 -fix callback hemat to post
-fix getting callback
2022-10-26 12:33:58 +07:00
Fadli
f8accba15d -fix callback hemat to post 2022-10-26 12:09:18 +07:00
Fadli
e26194ac4e -push logs 2022-10-25 13:00:25 +07:00
Fadli
c6d143487c - fix trx id test for hemat 2022-10-21 17:26:05 +07:00
Fadli
7dcb7d30f6 - fix trx id test for hemat 2022-10-19 16:53:12 +07:00
Fadli
cff473abd9 - fix callback hemat 2022-10-18 13:06:48 +07:00
Fadli
bc45617211 - fix callback hemat 2022-10-18 13:04:26 +07:00
Fadli
7958231883 - fix total commision query 2022-10-12 11:50:16 +07:00
Fadli
175fa2a7eb - fix total commision query 2022-10-12 10:45:42 +07:00
Fadli
9bd6ee6b9b - fix total commision query 2022-10-12 10:41:40 +07:00
Fadli
16be12ff69 - fix total commision query 2022-10-12 10:24:30 +07:00
Fadli
d7bac800e2 - fix total commision query 2022-10-12 10:06:18 +07:00
Fadli
65ba23c7f6 - fix total commision query 2022-10-12 09:59:20 +07:00
Fadli
fdd9802d6c - fix total commision query 2022-10-12 09:53:05 +07:00
Fadli
7285938241 - fix total commision 2022-10-11 11:40:54 +07:00
Fadli
8d1ed5a686 - fix total commision 2022-10-11 11:30:41 +07:00
Fadli
6fe43a6194 - logs total expense 2022-10-10 22:01:46 +07:00
Fadli
3369c3aedb - fix when product not active can't order 2022-10-10 17:21:13 +07:00
Fadli
c47327f524 - fix when product not active can't order 2022-10-10 14:43:52 +07:00
Fadli
21792e981e - add 2 hemat supplier as faktur and non faktur 2022-10-03 11:11:09 +07:00
Fadli
d598bbb4ab - fix callback if got 2 times in elang 2022-09-30 14:03:16 +07:00
Fadli
903880ed49 - fix check-bill for si hemat 2022-09-28 11:49:08 +07:00
Fadli
634f7946e5 - fix check-bill for si hemat 2022-09-28 00:54:58 +07:00
mfadiln2018
5f8212e5c5 fix: transaction supplier hemat 2022-09-27 14:30:15 +07:00
Fadli
30713bebec Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into development
 Conflicts:
	src/helper/irs-api.ts
	src/transaction/transaction.service.ts
2022-09-26 22:16:47 +07:00
Fadli
a218b949b4 -fix transaction api error 401 for hemat 2022-09-26 22:12:55 +07:00
mfadiln2018
4cf1454c2c fix: post api transaction hemat 2022-09-26 16:04:54 +07:00
Fadli
7cd52a5998 -fix url for login and transaction si hemat 2022-09-26 14:54:41 +07:00
Fadli
45064ee853 -fix url for login and transaction si hemat 2022-09-26 14:38:51 +07:00
Fadli
9b14685a92 add all request for si hemat :
- Login
- Request Transaction PrePaid
- Request Inquiry / Check Bill PostPaid
- Request Payment PostPaid
2022-09-21 18:51:44 +07:00
Fadli
a5683666aa - add condition for irs as a supplier 2022-09-14 12:21:06 +07:00
Fadli
c8554645cd - push logs partner id when transaction 2022-09-14 11:18:54 +07:00
Fadli
bfb8a2ca66 - push logs partner id when transaction 2022-09-14 11:17:45 +07:00
mfadiln2018
a007808535 fix: get list by categories all where partner is null 2022-09-07 19:19:55 +07:00
mfadiln2018
dd86a86373 fix: get list by categories all where supplier status is true 2022-09-07 17:50:50 +07:00
mfadiln2018
799cd43983 fix: get list by categories all 2022-09-07 17:08:06 +07:00
Fadli
6d9ce6f8ec - fix order-prod and order-stg if suppliers have same code product 2022-09-07 16:36:24 +07:00
Fadli
399c6ff9e4 - revert change for checking if callback already success or failed cannot hit 2 times 2022-09-07 01:25:35 +07:00
mfadiln2018
3342d5044d fix: insert balance remaining 2022-09-06 23:48:30 +07:00
Fadli
e11c6a285b - logs in find all coa by user 2022-09-06 22:29:26 +07:00
Fadli
42403184b1 - push logs in callback success checking data partneer 2022-09-06 22:17:07 +07:00
Fadli
5f5880f4e8 - push logs in callback success checking data partneer 2022-09-06 21:59:50 +07:00
Fadli
880d32b4bc - push logs in callback success checking data partneer 2022-09-06 21:43:27 +07:00
Fadli
9d9772270d - add condition for userdata partner if not null in callback success
- comment check if the transaction is success
2022-09-06 21:36:05 +07:00
mfadiln2018
6a7c66f461 fix: get list product by categories 2022-09-06 16:44:11 +07:00
Fadli
08116a3f0d change back status failed and revert success 2022-09-06 13:24:38 +07:00
Fadli
606864ec3b revert back status failed 2022-09-06 13:14:50 +07:00
mfadiln2018
a650657a8d fix: delete unused code at callback order failed 2022-09-06 12:57:57 +07:00
mfadiln2018
975cace081 fix: update status product at upload product 2022-09-01 16:44:13 +07:00
Fadli
95dc740ca2 fix order-prod for b2c temporary 2022-08-31 12:25:08 +07:00
Fadli
73820927ce revert back 'fix: update status product at upload product' 2022-08-31 11:26:35 +07:00
Fadli
0c617d4c3b changes back 'fix: update status product at upload product' 2022-08-31 07:12:47 +07:00
Fadli
25a2f2918e - revert 'fix: update status product at upload product' 2022-08-31 07:06:32 +07:00
mfadiln2018
ab518b8766 fix: update status product at upload product 2022-08-31 01:30:14 +07:00
Fadli
2e9475e83e - fix list order prod in b2c 2022-08-30 17:39:16 +07:00
Fadli
c58e3f281b - fix order prod error when checking status 2022-08-30 14:45:34 +07:00
Fadli
52d712fd05 - change status to product history status and only 1 value get from table product history status if value is same 2022-08-30 14:28:27 +07:00
Fadli
ce99cf5327 - change status to product history status and only 1 value get from table product history status if value is same 2022-08-30 11:05:39 +07:00
Fadli
42e0ab57dd - change status to product history status 2022-08-30 01:18:57 +07:00
Fadli
112662d069 - change status to product history status 2022-08-30 01:06:35 +07:00
Fadli
8e2106b831 - change status to product history status 2022-08-30 01:05:18 +07:00
Fadli
af29531485 - change status to product history status 2022-08-30 00:41:45 +07:00
Fadli
7cdd33cd5a - change status to product history status 2022-08-30 00:39:29 +07:00
Fadli
0db3bd8c32 - change status to product history status 2022-08-30 00:31:31 +07:00
Fadli
38935e40a9 - change status to product history status 2022-08-30 00:29:31 +07:00
Fadli
b0ff71cf41 - change status to product history status 2022-08-30 00:24:58 +07:00
Fadli
74d1e6f422 - change status to product history status 2022-08-30 00:18:17 +07:00
Fadli
f6d896cf8b - change status to product history status 2022-08-29 23:19:20 +07:00
mfadiln2018
09e13a0435 fix: update status product 2022-08-29 16:10:14 +07:00
mfadiln2018
4f03fee759 Feat: add get status from product history status 2022-08-29 15:46:02 +07:00
Fadli
c6d4b12307 - change status to product history status 2022-08-29 14:49:01 +07:00
Fadli
25a48ff39f - change status to product history status 2022-08-29 12:11:49 +07:00
mfadiln2018
b13a38590c Feat: add insert product history status at update product 2022-08-27 13:42:11 +07:00
mfadiln2018
2f0e191e5a Feat: add insert product history status at upload product csv 2022-08-26 15:47:21 +07:00
mfadiln2018
9e51516519 Feat: add insert product history status at upload product csv 2022-08-25 23:02:09 +07:00
Fadli
cfaaa6ce64 - push serial number not detected metro 2022-08-23 05:59:09 +07:00
Fadli
30597626d7 - push logs serial number not detected metro 2022-08-23 05:55:23 +07:00
Fadli
6ce1112d4c - push logs serial number not detected metro 2022-08-23 05:51:26 +07:00
Fadli
53ade2b30e - push logs serial number not detected metro 2022-08-23 05:31:05 +07:00
Fadli
4cc5794ea5 - fix auto update price elang 2022-08-21 01:51:46 +07:00
Fadli
1ae7966861 - push logs auto update price elang 2022-08-21 01:43:16 +07:00
Fadli
78da6bae13 - fix getting the product that only active 2022-08-21 01:15:25 +07:00
Fadli
e849c1cfdb - fix when all the product is not active 2022-08-21 00:37:19 +07:00
Fadli
356868c262 - push logs for price not found 2022-08-20 23:40:58 +07:00
Fadli
4737ae9f3a - push logs for price not found 2022-08-20 23:29:32 +07:00
mfadiln2018
fc35203f24 Fix: top up supplier 2022-08-15 14:40:59 +07:00
mfadiln2018
1b7477c34d Fix: top up supplier 2022-08-15 13:59:09 +07:00
mfadiln2018
3dd3748a71 Fix: top up supplier 2022-08-15 13:23:25 +07:00
mfadiln2018
c1c22560d5 Fix: balance remaining 2022-08-12 21:36:15 +07:00
mfadiln2018
d2bd88c6ac Feat: add response mark_up_price at user history 2022-08-10 23:52:06 +07:00
Fadli
0b9df3006a - fix auto update price and add new repository for product_history_price 2022-08-10 23:20:30 +07:00
Fadli
d251cadb0d - revert auto update price logs 2022-08-10 23:12:31 +07:00
Fadli
b60ff9ebdb - fix product price auto update getting from calback in metro
- revert logs in ppob callback metro
2022-08-10 23:04:49 +07:00
Fadli
5078177b6f - fix product price auto update getting from calback in metro
- revert logs in ppob callback metro
2022-08-10 22:40:50 +07:00
Fadli
eec61277c2 - fix product price auto update getting from calback in metro
- revert logs in ppob callback metro
2022-08-10 22:30:17 +07:00
mfadiln2018
576336661a Fix: query productPriceRepository 2022-08-10 21:21:48 +07:00
Hasta Ragil Saputra
ff212020a1 fix: check partner url before calling the callback 2022-08-10 17:46:01 +07:00
mfadiln2018
2a6f0faae3 Fix: query productPriceRepository 2022-08-10 15:56:10 +07:00
mfadiln2018
4298366e56 Feat: add query productPriceRepository 2022-08-10 14:05:12 +07:00
mfadiln2018
e0c52e5505 Feat: add logs at callback failed 2022-08-10 11:22:58 +07:00
Fadli
eb18eb501b - added logs for auto update price 2022-08-10 03:22:26 +07:00
mfadiln2018
3603da8977 Feat: add try catch at callback metro 2022-08-09 20:31:47 +07:00
mfadiln2018
5ec93b43aa Feat: add column balance_remaining at get list history-user 2022-08-08 12:26:06 +07:00
mfadiln2018
cfd36873ac Feat: add column and function balance_remaining 2022-08-05 22:51:24 +07:00
Fadli
a33c685d65 - fix handle if callback message is null 2022-08-05 14:57:02 +07:00
Fadli
be0dd93a09 - fix handle if callback message is null 2022-08-05 14:54:35 +07:00
Fadli
109f8f65e2 - add auto update price when getting callback metro only for metro 2022-08-05 14:30:23 +07:00
Fadli
9c90c3f1d0 - add auto update price when getting callback metro only for metro 2022-08-05 12:50:19 +07:00
Fadli
92b71ec274 - add auto update price when getting callback metro 2022-08-04 18:43:44 +07:00
Fadli
ee4314c66e - add auto update price when getting callback metro 2022-08-04 18:06:08 +07:00
Fadli
245e876144 - handle when product is not active cannot hit api transaction order prod 2022-08-03 22:47:59 +07:00
mfadiln2018
c184fdddc5 Fix: error callback order failed 2022-08-03 22:07:47 +07:00
Fadli
1ef47fc7e7 - added logs in ppob callback for metro 2022-08-03 19:25:08 +07:00
Fadli
f8c9e4fcd0 - added logs in ppob callback for metro 2022-08-03 19:00:52 +07:00
Fadli
929d06331e - handle when product is not active cannot hit api transaction order 2022-07-23 01:04:05 +07:00
Fadli
73d033738a - revert total modal in dashboard 2022-07-22 08:57:18 +07:00
Fadli
43cd745d5e - fix total modal in dashboard admin filter by partner id 2022-07-22 04:13:39 +07:00
Fadli
67e79280b2 - fix total modal in dashboard admin 2022-07-22 03:16:52 +07:00
mfadiln2018
f77fae0e16 Feat: add column supplier_name and product_price at get list history user 2022-07-18 22:39:21 +07:00
Fadli
e014b70f6c -fix bugs in add condition for ppob_callback can't hit 2 times if the transaction is already success or failed (only pending) 2022-07-01 02:29:14 +07:00
Fadli
7fe73c0dc4 -add condition for ppob_callback can't hit 2 times if the transaction is already success or failed (only pending) 2022-06-29 22:46:28 +07:00
Fadli
5c50d1d53a Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into development
 Conflicts:
	src/transaction/transaction.service.ts
2022-06-29 18:11:37 +07:00
Fadli
1fcc7ca8ad -add condition for ppob_callback can't hit 2 times if the transaction is already success or failed (only pending) 2022-06-29 18:10:05 +07:00
ilham
fe7702836e fix: rollback 2022-06-29 18:07:07 +07:00
ilham
104067f263 fix: callbacktransction 2022-06-28 17:10:07 +07:00
ilham
5d3b8dbcb4 fix: callbacktransction 2022-06-28 17:06:16 +07:00
ilham
47bf474a6a fix: callbacktransction 2022-06-28 16:22:01 +07:00
ilham
359b375556 fix: callbacktransction 2022-06-28 15:40:01 +07:00
ilham
953161c4b2 fix: rollback jurnal 2022-06-28 15:14:51 +07:00
ilham
c2b4b5ec30 fix: rollback jurnal 2022-06-28 14:58:05 +07:00
ilham
4befb8d9fd fix: callback ppob 2022-06-28 13:51:18 +07:00
ilham
7aee976de6 Merge remote-tracking branch 'origin/development' into development 2022-06-21 20:09:29 +07:00
ilham
e36d79d091 fix: callback ppob 2022-06-21 20:09:15 +07:00
mfadiln2018
b493b33f30 Feat: add relation to partner 2022-06-20 13:27:51 +07:00
ilham
2ca165f8d9 fix: callback ppob 2022-06-16 14:46:09 +07:00
ilham
bddfc18a31 fix: callback ppob 2022-06-16 14:37:48 +07:00
mfadiln2018
1aa61bfe36 Fix: bug filter get product by categories 2022-05-25 11:30:08 +07:00
mfadiln2018
9e177679a8 Fix: bug filter get product by categories 2022-05-24 22:33:14 +07:00
mfadiln2018
1050ca4c85 Feat: add rumus prepaid and postpaid 2022-05-24 20:24:42 +07:00
ilham
cb7d6833aa fix: callback failed on bill 2022-05-24 00:51:24 +07:00
ilham
2daf62b3df fix: transaction 2022-05-24 00:47:02 +07:00
ilham
6f29457720 fix: ppob callback 2022-05-24 00:42:58 +07:00
ilham
c26294ac50 fix: ppob callback 2022-05-24 00:34:17 +07:00
mfadiln2018
d2deb841f9 Feat: add column admin_price 2022-05-23 21:31:23 +07:00
mfadiln2018
0934147c51 Feat: add column partner_fee 2022-05-23 21:20:46 +07:00
ilham
044a5082e1 fixing: callback transaction 2022-05-21 19:40:47 +07:00
ilham
b33fa4c9c6 fixing: callback transaction 2022-05-21 18:32:56 +07:00
ilham
5f0512e3ce fixing: callback transaction 2022-05-21 15:21:05 +07:00
ilham
e386f5c618 fixing: callback transaction 2022-05-21 15:20:54 +07:00
ilham
fd47c34453 Merge remote-tracking branch 'origin/development' into development
# Conflicts:
#	src/transaction/transaction.service.ts
2022-05-21 14:38:21 +07:00
ilham
6629e97c35 fixing: callback transaction 2022-05-21 14:35:59 +07:00
mfadiln2018
f97095b740 Feat add get by id check bill history 2022-05-19 19:27:25 +07:00
ilham
6a2c535414 fixing: transaction bill 2022-05-18 22:23:09 +07:00
ilham
fe3404db32 fixing: product transaction 2022-05-17 15:59:15 +07:00
ilham
f66f071a3c fixing: check bill 2022-05-17 14:48:06 +07:00
ilham
f449299bbf fixing: check bill 2022-05-17 12:52:02 +07:00
ilham
9ee5b65dfc fixing: check bill 2022-05-17 12:26:25 +07:00
0f0d80f118 feat: add column check bill 2022-05-16 15:06:23 +07:00
6bc9c72df8 feat: add column check bill 2022-05-16 15:05:03 +07:00
ilham
feda138732 fixing: ppob 2022-05-16 14:12:08 +07:00
ilham
aae7005914 fix: callback 2022-05-13 00:44:28 +07:00
ilham
5542ed2d4b fix: admin price 2022-05-13 00:39:08 +07:00
ilham
9bdda9e8bf fix: callback 2022-05-13 00:27:15 +07:00
mfadiln2018
284ae2416b Feat add column admin_price at table product history price 2022-05-11 16:57:08 +07:00
mfadiln2018
892ec58c6a Fix: filter sub categories 2022-05-09 17:29:23 +07:00
ilham
819c59f28f fix: product in partner 2022-05-08 22:42:22 +07:00
ilham
137ca8e6f3 fix: check bill 2022-05-05 18:20:15 +07:00
ilham
52839223e6 add: transaction billing 2022-05-03 19:09:12 +07:00
ilham
49e22932b6 add: check bill 2022-04-29 15:50:16 +07:00
ilham
4685797ad4 fix: callback metro 2022-04-28 17:46:45 +07:00
Fadli
06f12b0140 add : Add supplier: Metro, logic for the callback 2022-04-28 17:26:56 +07:00
mfadiln2018
3ff8193949 Feat: add validation error if id partner is null 2022-04-26 12:19:26 +07:00
ilham
a1f689e82b add: new partner 2022-04-14 14:06:13 +07:00
ilham
b87c444ae6 add: new partner 2022-04-14 13:21:35 +07:00
790c0902a6 add column in table supplier 2022-04-02 01:34:11 +07:00
cdf9a19816 add column url in table supplier 2022-04-01 18:17:38 +07:00
b05404eb23 add column url in table supplier 2022-04-01 17:50:22 +07:00
2eac1c99e2 add column url in table supplier 2022-04-01 15:49:27 +07:00
ilham
876842eb53 add: order by in product retail 2022-03-11 00:25:06 +07:00
ilham
9f0536e2d1 fix: product 2022-03-11 00:04:13 +07:00
ilham
484b534322 add: orderby in product 2022-02-27 09:10:54 +07:00
ilham
ddda6020a3 fix: transaction service 2022-02-27 09:02:11 +07:00
ilham
ec6e8da63c fix: transaction service 2022-02-06 01:20:09 +07:00
ilham
890f82bfec fix: transaction 2022-02-05 21:07:12 +07:00
ilham
62225606b0 fix: transaction service 2022-02-04 22:37:51 +07:00
ilham
730d7fc3e4 fix: calculating 2022-02-04 21:28:57 +07:00
ilham
3e0f016408 fix: space 2022-02-04 20:13:07 +07:00
ilham
b92888486a fix: space 2022-02-04 20:08:32 +07:00
ilham
4e4ec7fcca fix: hit elang 2022-02-04 19:58:45 +07:00
ilham
57032361ff add: history-deposit-profile 2022-02-03 02:32:39 +07:00
ilham
e972223867 fix: create user 2022-01-28 12:31:56 +07:00
247195deab add deployment 2022-01-26 21:35:05 +07:00
35 changed files with 24211 additions and 2227 deletions

View File

@@ -6,9 +6,10 @@ metadata:
annotations: annotations:
kubernetes.io/ingress.class: "traefik" kubernetes.io/ingress.class: "traefik"
cert-manager.io/cluster-issuer: letsencrypt-prod cert-manager.io/cluster-issuer: letsencrypt-prod
traefik.ingress.kubernetes.io/router.middlewares: empatnusabangsa-production-redirect-https@kubernetescrd
spec: spec:
rules: rules:
- host: "ppob-backend.k3s.bangun-kreatif.com" - host: "api.wndsolutions.id"
http: http:
paths: paths:
- pathType: Prefix - pathType: Prefix
@@ -20,5 +21,5 @@ spec:
number: 5000 number: 5000
tls: tls:
- hosts: - hosts:
- "ppob-backend.k3s.bangun-kreatif.com" - "api.wndsolutions.id"
secretName: ppob-backend-k3s-bangun-kreatif-com-tls secretName: api-wndsolutions-id-tls

View File

@@ -0,0 +1,9 @@
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirect-https
namespace: empatnusabangsa-production
spec:
redirectScheme:
scheme: https
permanent: true

18837
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -19,9 +19,7 @@
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:cov": "jest --coverage", "test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json", "test:e2e": "jest --config ./test/jest-e2e.json"
"seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config",
"seed:run": "ts-node ./node_modules/typeorm-seeding/dist/cli.js seed"
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "^8.0.0", "@nestjs/common": "^8.0.0",
@@ -35,17 +33,22 @@
"@nestjs/typeorm": "^8.0.2", "@nestjs/typeorm": "^8.0.2",
"axios": "^0.24.0", "axios": "^0.24.0",
"bluebird": "^3.7.2", "bluebird": "^3.7.2",
"blueimp-md5": "^2.19.0",
"class-transformer": "^0.4.0", "class-transformer": "^0.4.0",
"class-validator": "^0.13.1", "class-validator": "^0.13.1",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"crypto-md5": "^1.0.0",
"csv-parser": "^3.0.0", "csv-parser": "^3.0.0",
"decimal.js": "^10.3.1", "decimal.js": "^10.3.1",
"exceljs": "^4.3.0",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"joi": "^17.4.2", "joi": "^17.4.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"md5-hash": "^1.0.1",
"moment": "^2.29.4",
"nestjs-pino": "^2.3.1", "nestjs-pino": "^2.3.1",
"passport": "^0.5.0", "passport": "^0.4.0",
"passport-jwt": "^4.0.0", "passport-jwt": "^4.0.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"pg": "^8.7.1", "pg": "^8.7.1",
@@ -54,9 +57,9 @@
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0", "rxjs": "^7.2.0",
"tmp": "^0.2.1",
"typeorm": "^0.2.37", "typeorm": "^0.2.37",
"typeorm-naming-strategies": "^2.0.0", "typeorm-naming-strategies": "^2.0.0"
"typeorm-seeding": "^1.6.1"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^8.0.0", "@nestjs/cli": "^8.0.0",

View File

@@ -45,11 +45,9 @@ import { MulterModule } from '@nestjs/platform-express';
password: configService.get<string>('database.password'), password: configService.get<string>('database.password'),
database: configService.get<string>('database.name'), database: configService.get<string>('database.name'),
entities: [], entities: [],
synchronize: true, synchronize: false,
autoLoadEntities: true, autoLoadEntities: true,
logging: true, logging: true,
seeds: ['src/seeds/**/*{.ts,.js}'],
factories: ['src/factories/**/*{.ts,.js}'],
namingStrategy: new SnakeNamingStrategy(), namingStrategy: new SnakeNamingStrategy(),
}; };
}, },

View File

@@ -1,19 +1,233 @@
import axios from 'axios'; import axios from 'axios';
import {HttpException, HttpStatus, NotFoundException} from "@nestjs/common";
import {createHmac} from "crypto";
const irs_url = 'http://h2h.elangpangarep.com/api/h2h'; const irs_url = 'http://h2h.elangpixiu.com/api/h2h';
const irs_id = 'PT0005'; const irs_id = 'PT0005';
const irs_pin = '04JFGC'; const irs_pin = '04JFGC';
const irs_user = 'D10BD0'; const irs_user = 'D10BD0';
const irs_pass = '6251F3'; const irs_pass = '6251F3';
export const doTransaction = async (productCode, destination, idtrx) => { export const doTransaction = async (
productCode,
destination,
idtrx,
supplier,
authorization,
typePaid,
billTrxId,
productVocaSubCategoryId,
productPrice
) => {
try { try {
const res = await axios.get( if (supplier.code == 'IRS') {
`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`, const res = await axios.get(
); `${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
);
return res.data;
} else if (supplier.code == 'NIRS') {
const res = await axios.get(
`${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
);
return res.data;
} else if (supplier.code == 'Vocagame') {
const merchantId = supplier.irs_id;
const reference = idtrx
const endpoint = `/transaction/${reference}`;
const secretKey = supplier.irs_pass;
const signature = createHmac('sha256', secretKey)
.update(merchantId + endpoint)
.digest('hex');
const options = {
headers: {'Content-Type': 'application/json',
'X-Merchant': `${merchantId}`},
};
const mergedDestination = destination;
const regex = /\(([^)]+)\)/;
const match = regex.exec(mergedDestination);
let productDestination = ""
let productRegion = ""
if (match) {
var productSplit = destination.split('(')
productDestination = productSplit[0]
const insideBrackets = match[1];
productRegion = insideBrackets // This will print inside brackets
} else {
productDestination = destination
}
const data =
{
productId: productVocaSubCategoryId, // Sub Kategori ID
productItemId: productCode, // Product Code
data: { // Get object from user input within endpoint /products/detail
userId: productDestination,
zoneId: productRegion // Optional
},
price: productPrice, // Price equals from items
reference: reference, // Your reference I
callbackUrl: "https://api.wndsolutions.id/v1/ppob_callback/vocagame" // Set your endpoint callback
}
const res = await axios.post(
`${supplier.url}/v1/core/transaction?signature=${signature}`,
data,
options,
);
var responseVoca = res.data.data;
console.log('iniresponsevoca', responseVoca)
if (responseVoca != null) {
const endpointDetail = `/transaction/${responseVoca.invoiceId}/detail`;
const signatureDetail = createHmac('sha256', secretKey)
.update(merchantId + endpointDetail)
.digest('hex');
const resDetail = await axios.get(
`${supplier.url}/v1/core/transaction/${responseVoca.invoiceId}/detail?signature=${signatureDetail}`,
options,
);
return resDetail.data
}
} else if (supplier.code == 'Digiflazz') {
if (typePaid == 'INQUIRY') {
const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`;
const md5Hash = require("blueimp-md5");
const options = {
headers: { 'Content-Type': 'application/json' },
};
const data = {
commands: 'inq-pasca',
username: supplier.irs_user,
customer_no: `${destination}`,
buyer_sku_code: `${productCode}`,
ref_id: `${idtrx}`,
sign: md5Hash(md5HashDigiflazz),
};
const res = await axios.post(
`${supplier.url}/transaction`,
data,
options,
);
return res.data.data;
} else if (typePaid == 'PAYMENT') {
const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`;
const md5Hash = require("blueimp-md5");
const options = {
headers: { 'Content-Type': 'application/json' },
};
const data = {
commands: 'pay-pasca',
username: supplier.irs_user,
customer_no: `${destination}`,
buyer_sku_code: `${productCode}`,
ref_id: `${billTrxId}`,
sign: md5Hash(md5HashDigiflazz),
};
const res = await axios.post(
`${supplier.url}/transaction`,
data,
options,
);
return res.data.data;
} else {
const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`;
const md5Hash = require("blueimp-md5");
console.log('testmd5', md5HashDigiflazz);
const options = {
headers: {'Content-Type': 'application/json'},
};
const data = {
username: supplier.irs_user,
customer_no: `${destination}`,
buyer_sku_code: `${productCode}`,
ref_id: `${idtrx}`,
sign: md5Hash(md5HashDigiflazz),
};
const res = await axios.post(
`${supplier.url}/transaction`,
data,
options,
);
console.log('resdigiflazz', res);
return res.data.data;
}
} else if (supplier.code == 'Hemat') {
if (authorization != '') {
console.log('initoken', authorization);
const options = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${authorization}`,
},
};
const data = {
idtransaction: idtrx,
destination: `${destination}`,
code: `${productCode}`,
type: `${typePaid}`,
};
const res = await axios.post(
`${supplier.url}/v1/transaction/request`,
data,
options,
);
return res.data;
}
}
try {
const res = await axios.get(
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
);
console.log('restransini', res);
console.log('restransini1', res.status);
if (res.data.includes('Saldo anda tidak mencukupi')) {
throw new HttpException(
{
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali',
},
HttpStatus.INTERNAL_SERVER_ERROR,
);
} else {
return res.data;
}
} catch (e) {
throw new HttpException(
{
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali',
},
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
return res.data;
} catch (err) { } catch (err) {
throw err; console.log('errtransaction', err);
console.log('errtransaction2', err.response.data);
console.log('errtransaction3', err.response.status);
console.log('errtransaction4', err.message);
throw new HttpException(
{
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali',
},
HttpStatus.INTERNAL_SERVER_ERROR,
);
} }
}; };

View File

@@ -5,7 +5,7 @@ export const createTransaction = async (kode, tujuan) => {
return axios.default return axios.default
.get( .get(
`http://h2h.elangpangarep.com/api/h2h?id=PT0005&pin=04JFGC&user=D10BD0&pass=6251F3&kodeproduk=${kode}&tujuan=${tujuan}&counter=1&idtrx=${codeTransaksi}`, `http://h2h.elangpixiu.com/api/h2h?id=PT0005&pin=04JFGC&user=D10BD0&pass=6251F3&kodeproduk=${kode}&tujuan=${tujuan}&counter=1&idtrx=${codeTransaksi}`,
) )
.then((response) => { .then((response) => {
return response.data; return response.data;

View File

@@ -0,0 +1,16 @@
import axios from 'axios';
export const doAuthorizeHemat = async (user, pass, supplier) => {
try {
const data = {
username: `${user}`,
password: `${pass}`,
};
const res = await axios.post(`${supplier.url}/authenticate`, data);
return res.data;
} catch (err) {
console.log('errauthhemat', err)
throw err;
}
};

View File

@@ -11,6 +11,9 @@ export class UpdatePriceProductDto {
@IsNotEmpty() @IsNotEmpty()
type: productType; type: productType;
@IsNotEmpty()
productType: string;
startDate: Date; startDate: Date;
endDate: Date; endDate: Date;

View File

@@ -32,4 +32,14 @@ export class ProductHistoryPrice extends BaseModel {
@Column('text') @Column('text')
type: productType; type: productType;
@Column({
default: 0,
})
admin_price: number;
@Column({
default: 0,
})
partner_fee: number;
} }

View File

@@ -0,0 +1,20 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Product } from './product.entity';
import { BaseModel } from '../../config/basemodel.entity';
import { productType } from '../../helper/enum-list';
import { Partner } from '../../users/entities/partner.entity';
@Entity()
export class ProductHistoryStatus extends BaseModel {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToOne(() => Product, (product) => product.id)
product: Product;
@ManyToOne(() => Partner, (partner) => partner.id)
partner: Partner;
@Column()
status: string;
}

View File

@@ -16,6 +16,11 @@ export class ProductSubCategories extends BaseModel {
}) })
code: string; code: string;
@Column({
nullable: true,
})
code_voca: string;
@ManyToOne(() => ProductCategories, (categories) => categories.sub_categories) @ManyToOne(() => ProductCategories, (categories) => categories.sub_categories)
category: ProductCategories; category: ProductCategories;

View File

@@ -3,6 +3,7 @@ import { ProductSubCategories } from './product-sub-category.entity';
import { BaseModel } from '../../config/basemodel.entity'; import { BaseModel } from '../../config/basemodel.entity';
import { Supplier } from '../../users/entities/supplier.entity'; import { Supplier } from '../../users/entities/supplier.entity';
import { ProductHistoryPrice } from './product-history-price.entity'; import { ProductHistoryPrice } from './product-history-price.entity';
import {ProductHistoryStatus} from "./product-history-status.entity";
@Entity() @Entity()
export class Product extends BaseModel { export class Product extends BaseModel {
@@ -28,6 +29,16 @@ export class Product extends BaseModel {
}) })
basePrice: number; basePrice: number;
@Column({
default: 'prepaid',
})
type: string;
@Column({
type: 'uuid'
})
sub_categories_id: string;
@ManyToOne( @ManyToOne(
() => { () => {
return ProductSubCategories; return ProductSubCategories;
@@ -48,6 +59,19 @@ export class Product extends BaseModel {
) )
supplier: Supplier; supplier: Supplier;
@OneToMany(
() => {
return ProductHistoryStatus;
},
(php) => {
return php.product;
},
)
statusHistory: ProductHistoryStatus;
currentStatus: ProductHistoryStatus;
@OneToMany( @OneToMany(
() => { () => {
return ProductHistoryPrice; return ProductHistoryPrice;

View File

@@ -69,6 +69,9 @@ export class ProductHistoryPriceService {
}); });
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
console.log("pricenotfound1", "msk")
console.log("pricenotfound1product", product)
console.log("pricenotfound1partner", partner)
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
@@ -92,6 +95,7 @@ export class ProductHistoryPriceService {
}); });
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
console.log("pricenotfound2", "msk")
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
@@ -115,8 +119,8 @@ export class ProductHistoryPriceService {
const query = this.productHistoryPriceRepository const query = this.productHistoryPriceRepository
.createQueryBuilder('product_history_price') .createQueryBuilder('product_history_price')
.leftJoin('product_history_price.product', 'product') .leftJoin('product_history_price.product', 'product')
.where({ product: productId }) .where({ product: productId });
.andWhere('product_history_price.endDate IS NULL'); // .andWhere('product_history_price.endDate IS NULL');
if (supplierId !== 'null' && supplierId) { if (supplierId !== 'null' && supplierId) {
query.andWhere('product.supplier = :supplierId', { query.andWhere('product.supplier = :supplierId', {

View File

@@ -0,0 +1,44 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { EntityNotFoundError, IsNull, Repository } from 'typeorm';
import { ProductHistoryStatus } from '../entities/product-history-status.entity';
@Injectable()
export class ProductHistoryStatusService {
constructor(
@InjectRepository(ProductHistoryStatus)
private productHistoryStatusRepository: Repository<ProductHistoryStatus>,
) {}
async create(dataProduct: ProductHistoryStatus) {
const result = await this.productHistoryStatusRepository.insert(
dataProduct,
);
return result;
}
async findOneActive(productId: string, partnerId: string) {
try {
return await this.productHistoryStatusRepository.findOneOrFail({
relations: ['product'],
where: {
product: productId,
partner: partnerId,
},
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Product not active',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
}

View File

@@ -10,6 +10,8 @@ import { ProductSubCategories } from './entities/product-sub-category.entity';
import { ProductSubCategoriesService } from './product-sub-categories.service'; import { ProductSubCategoriesService } from './product-sub-categories.service';
import { UsersModule } from '../users/users.module'; import { UsersModule } from '../users/users.module';
import { ProductHistoryPriceService } from './history-price/history-price.service'; import { ProductHistoryPriceService } from './history-price/history-price.service';
import {ProductHistoryStatus} from "./entities/product-history-status.entity";
import {ProductHistoryStatusService} from "./history-status/history-status.service";
@Module({ @Module({
imports: [ imports: [
@@ -17,6 +19,7 @@ import { ProductHistoryPriceService } from './history-price/history-price.servic
Product, Product,
ProductCategories, ProductCategories,
ProductHistoryPrice, ProductHistoryPrice,
ProductHistoryStatus,
ProductSubCategories, ProductSubCategories,
]), ]),
forwardRef(() => UsersModule), forwardRef(() => UsersModule),
@@ -27,7 +30,8 @@ import { ProductHistoryPriceService } from './history-price/history-price.servic
ProductCategoriesService, ProductCategoriesService,
ProductSubCategoriesService, ProductSubCategoriesService,
ProductHistoryPriceService, ProductHistoryPriceService,
ProductHistoryStatusService,
], ],
exports: [ProductService, ProductHistoryPriceService], exports: [ProductService, ProductHistoryPriceService, ProductHistoryStatusService, ProductSubCategoriesService],
}) })
export class ProductModule {} export class ProductModule {}

View File

@@ -13,22 +13,25 @@ import { SupplierService } from '../users/supplier/supplier.service';
import { parsingFile } from '../helper/csv-parser'; import { parsingFile } from '../helper/csv-parser';
import { PartnerService } from '../users/partner/partner.service'; import { PartnerService } from '../users/partner/partner.service';
import { mapSeries } from 'bluebird'; import { mapSeries } from 'bluebird';
import { ProductHistoryStatus } from './entities/product-history-status.entity';
export class ProductService { export class ProductService {
constructor( constructor(
@InjectRepository(Product) @InjectRepository(Product)
private productRepository: Repository<Product>, private productRepository: Repository<Product>,
@InjectRepository(ProductHistoryPrice) @InjectRepository(ProductHistoryPrice)
private productHistoryPrice: Repository<ProductHistoryPrice>, private productHistoryPrice: Repository<ProductHistoryPrice>,
private productSubCategoriesService: ProductSubCategoriesService, @InjectRepository(ProductHistoryStatus)
private usersService: UsersService, private productHistoryStatus: Repository<ProductHistoryStatus>,
private supplierService: SupplierService, private productSubCategoriesService: ProductSubCategoriesService,
private partnerService: PartnerService, private usersService: UsersService,
private supplierService: SupplierService,
private partnerService: PartnerService,
) {} ) {}
async create(createProductDto: CreateProductDto) { async create(createProductDto: CreateProductDto) {
const subCategories = await this.productSubCategoriesService.findOne( const subCategories = await this.productSubCategoriesService.findOne(
createProductDto.subCategoriesId, createProductDto.subCategoriesId,
); );
const result = await this.productRepository.insert({ const result = await this.productRepository.insert({
@@ -55,13 +58,15 @@ export class ProductService {
const supplierData = await this.supplierService.findByCode(supplierCode); const supplierData = await this.supplierService.findByCode(supplierCode);
const data = await parsingFile(uploadFile); const data = await parsingFile(uploadFile);
data.shift(); data.shift();
await mapSeries(data, async (it) => { await mapSeries(data, async (it) => {
let dataHistoryPrice; let dataHistoryPrice;
let partnerData; let partnerData;
let productStatusPartner;
const subCategories = const subCategories =
await this.productSubCategoriesService.findOneForCSVParser(it[2]); await this.productSubCategoriesService.findOneForCSVParser(it[2]);
if (!subCategories) { if (!subCategories) {
return; return;
@@ -71,15 +76,35 @@ export class ProductService {
code: it[0], code: it[0],
supplier: supplierData, supplier: supplierData,
}); });
const productStatus = await this.productHistoryStatus.findOne({
product: productData,
partner: null,
});
if (productData) { if (productData) {
//TODO : Handle Update Product //TODO : Handle Update Product
productData.name = it[1]; productData.name = it[1];
productData.status = it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE'; productData.status = it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE';
productData.sub_categories_id = subCategories.id;
await this.productRepository.save(productData); await this.productRepository.save(productData);
//TODO : Handle History Price //TODO : Handle History Price
if (it[6] != '-' && it[6] != '') { if (it[6] != '-' && it[6] != '') {
partnerData = await this.partnerService.findOne(it[6]); partnerData = await this.partnerService.findOne(it[6]);
productStatusPartner = await this.productHistoryStatus.findOne({
product: productData,
partner: partnerData.id,
});
if (productStatusPartner === undefined) {
await this.productHistoryStatus.insert({
product: productData,
partner: it[6] != '-' ? partnerData : null,
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
});
}
dataHistoryPrice = await this.productHistoryPrice.findOne({ dataHistoryPrice = await this.productHistoryPrice.findOne({
where: { where: {
product: productData.id, product: productData.id,
@@ -88,6 +113,17 @@ export class ProductService {
}, },
}); });
} else { } else {
if (productStatus != undefined) {
productStatus.status = it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE';
await this.productHistoryStatus.save(productStatus);
} else {
await this.productHistoryStatus.insert({
product: productData,
partner: it[6] != '-' ? partnerData : null,
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
});
}
dataHistoryPrice = await this.productHistoryPrice.findOne({ dataHistoryPrice = await this.productHistoryPrice.findOne({
product: productData, product: productData,
partner: IsNull(), partner: IsNull(),
@@ -101,6 +137,12 @@ export class ProductService {
}); });
} }
if (productStatusPartner) {
await this.productHistoryStatus.update(productStatusPartner.id, {
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
});
}
await this.productHistoryPrice.insert({ await this.productHistoryPrice.insert({
product: productData, product: productData,
mark_up_price: it[4], mark_up_price: it[4],
@@ -108,18 +150,29 @@ export class ProductService {
type: productType.NORMAL, type: productType.NORMAL,
startDate: new Date(), startDate: new Date(),
partner: it[6] != '-' ? partnerData : null, partner: it[6] != '-' ? partnerData : null,
admin_price: it[8],
partner_fee: it[9],
}); });
} else { } else {
let partnerData; let partnerData;
if (it[6] != '-' && it[6] != '') { if (it[6] != '-' && it[6] != '') {
partnerData = await this.partnerService.findOne(it[6]); partnerData = await this.partnerService.findOne(it[6]);
} }
const savedProduct = await this.productRepository.insert({ const savedProduct = await this.productRepository.insert({
name: it[1], name: it[1],
code: it[0], code: it[0],
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE', status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
sub_categories: subCategories, sub_categories: subCategories,
supplier: supplierData, supplier: supplierData,
type: it[7] == 'postpaid' ? 'postpaid' : 'prepaid',
});
await this.productHistoryStatus.insert({
product: savedProduct.identifiers[0],
partner: partnerData,
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
}); });
return await this.productHistoryPrice.insert({ return await this.productHistoryPrice.insert({
@@ -130,6 +183,8 @@ export class ProductService {
startDate: new Date(), startDate: new Date(),
endDate: null, endDate: null,
partner: partnerData, partner: partnerData,
admin_price: it[8],
partner_fee: it[9],
}); });
} }
}); });
@@ -138,10 +193,10 @@ export class ProductService {
} }
async findAll( async findAll(
page: number, page: number,
supplier: string, supplier: string,
subCategories: string, subCategories: string,
pageSize?: number, pageSize?: number,
) { ) {
let filterSupplier, filterSubCategories; let filterSupplier, filterSubCategories;
@@ -158,30 +213,40 @@ export class ProductService {
} }
const baseQuery = this.productRepository const baseQuery = this.productRepository
.createQueryBuilder('product') .createQueryBuilder('product')
.leftJoin('product.sub_categories', 'sub_categories') .leftJoin('product.sub_categories', 'sub_categories')
.leftJoin('sub_categories.category', 'category') .leftJoin('sub_categories.category', 'category')
.leftJoin('product.supplier', 'supplier') .leftJoin('product.supplier', 'supplier')
.where('supplier.status = :status', { status: true }) .where('supplier.status = :status', { status: true })
.innerJoinAndMapOne( .innerJoinAndMapOne(
'product.currentPrice', 'product.currentPrice',
'product.priceHistory', 'product.priceHistory',
'current_price', 'current_price',
'current_price.partner_id is null and current_price.end_date is NULL', 'current_price.end_date is NULL',
) )
.select(['product.id']) .innerJoinAndMapOne(
.addSelect([ 'product.currentStatus',
'product.name', 'product.statusHistory',
'product.code', 'history_status',
'sub_categories.name', 'history_status.deleted_at is NULL',
'supplier.name', )
'category.name', .select(['product.id'])
'product.status', .addSelect([
]) 'product.name',
.addSelect('current_price.price') 'product.code',
.addSelect( 'sub_categories.name',
'(current_price.price + current_price.mark_up_price) as mark_up_price', 'supplier.name',
); 'category.name',
])
.addSelect('history_status.status', 'status')
.addSelect('current_price.price', 'price')
.addSelect('current_price.partner_fee', 'partner_fee')
.addSelect('current_price.admin_price', 'admin_price')
.addSelect(
'(current_price.price + current_price.mark_up_price) as mark_up_price',
)
.orderBy('product.code')
.distinct();
if (subCategories && filterSubCategories.length > 0) { if (subCategories && filterSubCategories.length > 0) {
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', { baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
@@ -196,9 +261,9 @@ export class ProductService {
} }
const data = await baseQuery const data = await baseQuery
.offset(page * (pageSize || 10)) .offset(page * (pageSize || 10))
.limit(pageSize || 10) .limit(pageSize || 10)
.getRawMany(); .getRawMany();
const totalData = await baseQuery.getCount(); const totalData = await baseQuery.getCount();
@@ -210,26 +275,26 @@ export class ProductService {
async findAllByCategories(page, subCategories, supplier) { async findAllByCategories(page, subCategories, supplier) {
const baseQuery = this.productRepository const baseQuery = this.productRepository
.createQueryBuilder('product') .createQueryBuilder('product')
.leftJoin('product.sub_categories', 'sub_categories') .leftJoin('product.sub_categories', 'sub_categories')
.where( .where(
'sub_categories.category_id = :id and product.supplier_id = :supplier_id', 'sub_categories.category_id = :id and product.supplier_id = :supplier_id',
{ {
id: subCategories, id: subCategories,
supplier_id: supplier, supplier_id: supplier,
}, },
) )
.leftJoinAndMapOne( .leftJoinAndMapOne(
'product.currentPrice', 'product.currentPrice',
'product.priceHistory', 'product.priceHistory',
'current_price', 'current_price',
'current_price.partner_id is null', 'current_price.partner_id is null',
); );
const data = await baseQuery const data = await baseQuery
.skip(page * 10) .skip(page * 10)
.take(10) .take(10)
.getMany(); .getMany();
const totalData = await baseQuery.getCount(); const totalData = await baseQuery.getCount();
@@ -244,37 +309,68 @@ export class ProductService {
supplier = (await this.supplierService.findByActive()).id; supplier = (await this.supplierService.findByActive()).id;
} }
console.log(supplier, 'asldklaksd')
const baseQuery = this.productRepository const baseQuery = this.productRepository
.createQueryBuilder('product') .createQueryBuilder('product')
.leftJoin('product.sub_categories', 'sub_categories') .leftJoin('product.sub_categories', 'sub_categories')
.where( .leftJoin('product.supplier', 'supplier')
`product.supplier_id = :supplier_id and product.status = 'ACTIVE'`,
{ // .leftJoin('product.statusHistory', 'status_history')
supplier_id: supplier,
}, .leftJoinAndMapOne(
) 'product.currentPrice',
.leftJoinAndMapOne( 'product.priceHistory',
'product.currentPrice', 'current_price',
'product.priceHistory', 'current_price.partner_id is NULL and current_price.end_date is NULL',
'current_price', )
'current_price.partner_id is NULL and current_price.end_date is NULL', .innerJoinAndMapOne(
) 'product.currentStatus',
.select(['product.id']) 'product.statusHistory',
.addSelect(['product.name', 'product.code', 'sub_categories.name']) 'history_status',
.addSelect( `history_status.status = 'ACTIVE' and history_status.deleted_at is NULL`,
'(current_price.price + current_price.mark_up_price) as price', {
); status: 'ACTIVE',
},
)
// .where(
// `product.supplier_id = :supplier_id`,
// {
// supplier_id: supplier,
// },
// )
.where(
`history_status.partner_id is NULL`,
{
partner_id: null,
},
)
.andWhere(
'supplier.status = TRUE',
{
status: true,
},
)
.select(['product.id'])
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
.addSelect('(current_price.price + current_price.mark_up_price) as price')
.addSelect('product.supplier_id', 'supplier')
.addSelect('supplier.status', 'status')
.addSelect('history_status.partner_id', 'partner')
.addSelect('product.type')
.orderBy('price', 'ASC')
.distinct();
if (subCategories != 'null' && subCategories) { if (subCategories != 'null' && subCategories) {
baseQuery.where('product.sub_categories_id = :id', { baseQuery.andWhere('product.sub_categories_id = :id', {
id: subCategories, id: subCategories,
}); });
} }
const data = await baseQuery const data = await baseQuery
.offset(page * 10) .offset(page * 1000)
.limit(10) .limit(1000)
.getRawMany(); .getRawMany();
const totalData = await baseQuery.getCount(); const totalData = await baseQuery.getCount();
@@ -285,52 +381,136 @@ export class ProductService {
} }
async findAllForPartner( async findAllForPartner(
page: number, page: number,
pageSize: number, pageSize: number,
subCategories: string, subCategories: string,
username: string, username: string,
) { ) {
let filterSubCategories;
const user = await this.usersService.findOneByUsername(username); const user = await this.usersService.findOneByUsername(username);
const supplier = await this.supplierService.findByActive();
const baseQuery = this.productRepository if (subCategories) {
.createQueryBuilder('product') filterSubCategories = subCategories.split(',').map((data) => {
.leftJoin('product.sub_categories', 'sub_categories') return data.trim();
.where(
`product.supplier_id = :supplier_id and product.status = 'ACTIVE'`,
{
supplier_id: supplier.id,
},
)
.innerJoinAndMapOne(
'product.currentPrice',
'product.priceHistory',
'current_price',
'current_price.partner_id = :id_partner and current_price.end_date is NULL',
{
id_partner: user.partner.id,
},
)
.select(['product.id'])
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
.addSelect(
'(current_price.price + current_price.mark_up_price) as price',
);
if (
subCategories != 'null' &&
subCategories &&
subCategories != 'undefined'
) {
baseQuery.where('product.sub_categories_id = :id', {
id: subCategories,
}); });
} }
if (user.partner === null) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Partner id not found',
},
HttpStatus.NOT_FOUND,
);
}
const baseQuery = await this.productRepository
.createQueryBuilder('product')
.leftJoin('product.sub_categories', 'sub_categories')
.leftJoin('product.supplier', 'supplier')
// .leftJoinAndSelect(
// 'product.supplier',
// 'supplier',
// 'supplier.status = true',
// {
// status: true
// }
//
// )
.innerJoinAndMapOne(
'product.currentPrice',
'product.priceHistory',
'current_price',
'current_price.partner_id = :id_partner and current_price.end_date is NULL',
{
id_partner: user.partner.id,
},
)
.innerJoinAndMapOne(
'product.currentStatus',
'product.statusHistory',
'history_status',
'history_status.partner_id = :id_partner and history_status.deleted_at is NULL',
{
id_partner: user.partner.id,
},
)
// .where(`history_status.partner_id = :id_partner`, {
// partner: user.partner.id,
// })
.where(`history_status.status = 'ACTIVE'`, {
status: 'ACTIVE',
})
.andWhere('supplier.status = TRUE', {
status: true
})
.select(['product.id'])
.addSelect([
'product.name',
'product.code',
'product.type',
'product.supplier_id',
'sub_categories.name',
'current_price.admin_price as admin_price',
'current_price.mark_up_price as markup_price',
'current_price.partner_fee as partner_fee',
'current_price.price as price',
])
.addSelect('history_status.status', 'status')
.distinct();
// .addSelect(
// '(current_price.price + current_price.mark_up_price) as price',
// );
// if (
// subCategories != 'null' &&
// subCategories &&
// subCategories != 'undefined'
// ) {
// baseQuery.where('product.sub_categories_id = :id', {
// id: subCategories,
// });
// }
if (subCategories && filterSubCategories.length > 0) {
baseQuery
.where('product.sub_categories_id IN (:...subCategoryId)', {
subCategoryId: filterSubCategories,
})
.andWhere(`history_status.status = 'ACTIVE'`);
}
const newData = [];
const data = await baseQuery const data = await baseQuery
.offset(page * pageSize) .offset(page * pageSize)
.limit(pageSize) .limit(pageSize)
.getRawMany(); .getRawMany();
data.map((dataa) => {
let actualPrice = 0;
if (dataa.product_type === 'prepaid') {
actualPrice = Number(dataa['price']) + Number(dataa['markup_price']);
}
if (dataa.product_type === 'postpaid') {
actualPrice =
Number(dataa['admin_price']) -
(Number(dataa['partner_fee']) + Number(dataa['markup_price']));
}
dataa.price = actualPrice;
if (user.username != 'admin') {
delete dataa.markup_price;
}
newData.push({
...dataa,
});
});
const totalData = await baseQuery.getCount(); const totalData = await baseQuery.getCount();
@@ -340,22 +520,23 @@ export class ProductService {
}; };
} }
async findOne(code: string) { async findOne(code: string, type: string, productId: string) {
try { try {
return await this.productRepository.findOneOrFail({ return await this.productRepository.findOneOrFail({
relations: ['supplier'], relations: ['supplier'],
where: { where: {
code: code, code: code,
id: productId
}, },
}); });
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
error: 'Product not found', error: 'Product not found',
}, },
HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
); );
} else { } else {
throw e; throw e;
@@ -363,6 +544,35 @@ export class ProductService {
} }
} }
async findOneActive(
code: string,
type: string,
productId: string
) {
try {
return await this.productRepository.findOneOrFail({
relations: ['supplier'],
where: {
code: code,
id: productId
},
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Product not found',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
async findOneById(id: string) { async findOneById(id: string) {
try { try {
return await this.productRepository.findOneOrFail({ return await this.productRepository.findOneOrFail({
@@ -374,11 +584,11 @@ export class ProductService {
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
error: 'Product not found', error: 'Product not found',
}, },
HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
); );
} else { } else {
throw e; throw e;
@@ -392,11 +602,11 @@ export class ProductService {
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
error: 'Product not found', error: 'Product not found',
}, },
HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
); );
} else { } else {
throw e; throw e;
@@ -404,9 +614,19 @@ export class ProductService {
} }
const subCategories = await this.productSubCategoriesService.findOne( const subCategories = await this.productSubCategoriesService.findOne(
updateProductDto.subCategoriesId, updateProductDto.subCategoriesId,
); );
const dataStatus = await this.productHistoryStatus.findOne({
where: {
product: id,
},
});
await this.productHistoryStatus.update(dataStatus.id, {
status: updateProductDto.status,
});
const result = await this.productRepository.update(id, { const result = await this.productRepository.update(id, {
name: updateProductDto.name, name: updateProductDto.name,
code: updateProductDto.code, code: updateProductDto.code,
@@ -418,19 +638,19 @@ export class ProductService {
} }
async updatePrice( async updatePrice(
code: string, code: string,
updatePriceProductDto: UpdatePriceProductDto, updatePriceProductDto: UpdatePriceProductDto,
) { ) {
const product = await this.findOne(code); // const product = await this.findOne(code, updatePriceProductDto.productType);
await this.productHistoryPrice.insert({ // await this.productHistoryPrice.insert({
product: product, // product: product,
type: updatePriceProductDto.type, // type: updatePriceProductDto.type,
price: updatePriceProductDto.price, // price: updatePriceProductDto.price,
mark_up_price: updatePriceProductDto.markUpPrice, // mark_up_price: updatePriceProductDto.markUpPrice,
startDate: updatePriceProductDto.startDate, // startDate: updatePriceProductDto.startDate,
endDate: updatePriceProductDto.endDate, // endDate: updatePriceProductDto.endDate,
}); // });
return true; return true;
} }
@@ -441,11 +661,11 @@ export class ProductService {
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.NOT_FOUND, statusCode: HttpStatus.NOT_FOUND,
error: 'Product not found', error: 'Product not found',
}, },
HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
); );
} else { } else {
throw e; throw e;

View File

@@ -1,31 +0,0 @@
import { Factory, Seeder } from 'typeorm-seeding';
import { Connection } from 'typeorm';
import { Roles } from '../configurable/entities/roles.entity';
export default class CreateUsers implements Seeder {
public async run(factory: Factory, connection: Connection): Promise<any> {
await connection
.createQueryBuilder()
.insert()
.into('roles')
.values([
{
id: '3196cdf4-ae5f-4677-9bcd-98be35c72329',
created_at: new Date(),
updated_at: new Date(),
deleted_at: null,
version: 1,
name: 'Admin',
},
{
id: '3196cdf4-ae5f-4677-9bcd-98be35c72328',
created_at: new Date(),
updated_at: new Date(),
deleted_at: null,
version: 1,
name: 'Supervisor',
},
])
.execute();
}
}

View File

@@ -50,6 +50,7 @@ export class CoaService {
} }
async findByUser(id: string, typeOfCoa: coaType) { async findByUser(id: string, typeOfCoa: coaType) {
console.log('findbyuser', 'msk')
try { try {
return await this.coaRepository.findOneOrFail({ return await this.coaRepository.findOneOrFail({
user: id, user: id,
@@ -72,6 +73,7 @@ export class CoaService {
async findByTwoUser(from: string, destination: string, typeOfCoa: coaType) { async findByTwoUser(from: string, destination: string, typeOfCoa: coaType) {
try { try {
console.log('findbytwouser', 'msk')
return await this.coaRepository.findOneOrFail({ return await this.coaRepository.findOneOrFail({
user: from, user: from,
relatedUser: destination, relatedUser: destination,
@@ -120,8 +122,10 @@ export class CoaService {
async findByName(name: string) { async findByName(name: string) {
try { try {
console.log('coaname', name);
return await this.coaRepository.findOneOrFail({ name: name }); return await this.coaRepository.findOneOrFail({ name: name });
} catch (e) { } catch (e) {
console.log('coaerror', e);
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
{ {

View File

@@ -0,0 +1,16 @@
import { IsNotEmpty, IsOptional } from 'class-validator';
export class ExportTransactionDto {
@IsNotEmpty()
dateStart: string;
@IsNotEmpty()
dateEnd: string;
@IsOptional()
supplier: string;
@IsOptional()
buyer: string;
}

View File

@@ -1,6 +1,10 @@
import { IsNotEmpty, IsOptional } from 'class-validator'; import { IsNotEmpty, IsOptional } from 'class-validator';
export class OrderTransactionDto { export class OrderTransactionDto {
@IsNotEmpty()
productId: string;
@IsNotEmpty() @IsNotEmpty()
productCode: string; productCode: string;
@@ -9,4 +13,7 @@ export class OrderTransactionDto {
@IsOptional() @IsOptional()
trx_id: string; trx_id: string;
@IsOptional()
bill_trx_id: string;
} }

View File

@@ -0,0 +1,18 @@
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { BaseModel } from '../../config/basemodel.entity';
import { statusTransaction, typeTransaction } from '../../helper/enum-list';
import { ProductHistoryPrice } from '../../product/entities/product-history-price.entity';
import { UserDetail } from '../../users/entities/user_detail.entity';
import { TransactionJournal } from './transaction-journal.entity';
@Entity()
export class CallbackPartner extends BaseModel {
@Column()
trx_id: string;
@Column()
partner_trx_id: string;
@Column()
url: string;
}

View File

@@ -0,0 +1,51 @@
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { BaseModel } from '../../config/basemodel.entity';
import { statusTransaction, typeTransaction } from '../../helper/enum-list';
import { ProductHistoryPrice } from '../../product/entities/product-history-price.entity';
import { UserDetail } from '../../users/entities/user_detail.entity';
import { TransactionJournal } from './transaction-journal.entity';
@Entity()
export class CheckBillHistory extends BaseModel {
@Column()
trx_id: string;
@Column()
partner_trx_id: string;
@Column({ nullable: true })
amount: number;
@Column({ nullable: true })
admin_price: number;
@Column({
type: 'uuid',
nullable: true,
})
user: string;
@Column({
nullable: true,
})
destination: string;
@Column({
nullable: true,
})
request_json: string;
@Column({
nullable: true,
})
callback_json: string;
@Column()
product_code: string;
@Column()
status: string;
@ManyToOne(() => ProductHistoryPrice, (product) => product.id)
product_price: ProductHistoryPrice;
}

View File

@@ -10,12 +10,20 @@ export class Transactions extends BaseModel {
@Column() @Column()
amount: number; amount: number;
@Column()
balance_remaining: number;
@Column() @Column()
status: statusTransaction; status: statusTransaction;
@Column() @Column()
type: typeTransaction; type: typeTransaction;
@Column({
nullable: true,
})
check_bill: string;
@Column({ @Column({
type: 'uuid', type: 'uuid',
nullable: true, nullable: true,

View File

@@ -0,0 +1,58 @@
import {
Controller,
Get,
Res,
Header,
Post,
Body,
Request,
Param,
ParseUUIDPipe,
} from '@nestjs/common';
import { Response } from 'express';
import { TransactionService } from './transaction.service';
import { ExportTransactionDto } from './dto/export-transaction.dto';
@Controller({
path: 'excel',
version: '1',
})
export class ExcelController {
constructor(private transactionService: TransactionService) {}
@Post('history-user/export/:id')
@Header('Content-Type', 'text/xlsx')
async exportTransactionHistory(
@Param('id') id: string,
@Body() exportTransactionDto: ExportTransactionDto,
@Request() req,
@Res() res: Response,
) {
const result = await this.transactionService.exportDataExcel(
exportTransactionDto.dateStart,
exportTransactionDto.dateEnd,
id,
req.user,
);
res.download(`${result}`);
}
@Post('history-user/export-all')
@Header('Content-Type', 'text/xlsx')
async exportTransactionHistoryAll(
@Body() exportTransactionDto: ExportTransactionDto,
@Request() req,
@Res() res: Response,
) {
const result = await this.transactionService.exportDataExcelAll(
exportTransactionDto.dateStart,
exportTransactionDto.dateEnd,
exportTransactionDto.supplier,
exportTransactionDto.buyer,
req.user,
);
res.download(`${result}`);
}
}

View File

@@ -1,7 +1,15 @@
import { Controller, Get, HttpStatus, Logger, Req } from '@nestjs/common'; import {
Controller,
Get,
HttpException,
HttpStatus,
Logger, Post,
Req,
} from '@nestjs/common';
import { TransactionService } from './transaction.service'; import { TransactionService } from './transaction.service';
import { FastifyRequest } from 'fastify'; import { FastifyRequest } from 'fastify';
import { Public } from '../auth/public.decorator'; import { Public } from '../auth/public.decorator';
import { EntityNotFoundError } from 'typeorm';
@Controller({ @Controller({
path: 'ppob_callback', path: 'ppob_callback',
@@ -19,26 +27,179 @@ export class PpobCallbackController {
if (response['statuscode'] == 2) { if (response['statuscode'] == 2) {
//TODO: UPDATE GAGAL //TODO: UPDATE GAGAL
const updateTransaction = await this.transactionService.checkCallbackOrderFailed(
await this.transactionService.callbackOrderFailed( response['clientid'],
response['clientid'], response,
response, );
);
} else { } else {
//TODO: UPDATE BERHASIL //TODO: UPDATE BERHASIL
const updateTransaction = await this.transactionService.checkCallbackOrderSuccess(
await this.transactionService.callbackOrderSuccess( response['clientid'],
response['clientid'], response,
response, );
);
} }
this.logger.log({ }
requestQuery: request.query,
});
return { @Public()
statusCode: HttpStatus.OK, @Get('/metro')
message: 'success', async getMetro(@Req() request: FastifyRequest) {
}; try {
const response = request.query;
if (response['message'].toLowerCase().includes('CEK TAGIHAN')) {
if (response['status'] != 20) {
//TODO: UPDATE GAGAL
await this.transactionService.updateBill(
response['refid'],
null,
null,
false,
response['message'],
);
return {
statusCode: HttpStatus.OK,
message: 'success',
};
}
const splitMessage = response['message'].split('"');
//TODO: UPDATE BERHASIL
await this.transactionService.updateBill(
response['refid'],
Number(splitMessage[21].replace(/^\D+/g, '')),
Number(splitMessage[17].replace(/^\D+/g, '')),
true,
response['message'],
);
//
} else {
console.log('statusapani', response['status']);
console.log('statusapani2', response.toString());
if (response['status'].toString() != '20') {
//TODO: UPDATE GAGAL
const updateTransaction =
await this.transactionService.callbackOrderFailed(
response['refid'],
response,
);
return {
updateTransaction,
statusCode: HttpStatus.BAD_REQUEST,
message: 'failed to proccess',
};
} else {
//TODO: UPDATE BERHASIL
const updateTransaction =
await this.transactionService.callbackOrderSuccess(
response['refid'],
response,
);
return {
updateTransaction,
statusCode: HttpStatus.OK,
message: 'success',
};
}
}
this.logger.log({
requestQuery: request.query,
});
return {
statusCode: HttpStatus.OK,
message: 'success',
};
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Error callback',
message: e
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
@Public()
@Post('/hemat')
async getHemat(@Req() request: FastifyRequest) {
const response = request.body;
console.log('responsehemat', response);
console.log('responsehemat2', request.body);
if (response['msg'] != 'Transaksi Sukses') {
console.log('masukgagalhemat', 'msk')
//TODO: UPDATE GAGAL
await this.transactionService.checkCallbackOrderFailed(
response['data']['idtransaction'],
response,
);
} else {
console.log('masuksukseshemat', 'msk')
//TODO: UPDATE BERHASIL
await this.transactionService.checkCallbackOrderSuccess(
response['data']['idtransaction'],
response,
);
}
}
@Public()
@Post('/digiflazz')
async getDigiflazz(@Req() request: FastifyRequest) {
const response = request.body;
console.log('responsedigiflazz', response);
if (response['data']['message'] != 'Transaksi Sukses') {
//TODO: UPDATE GAGAL
await this.transactionService.checkCallbackOrderFailed(
response['data']['ref_id'],
response['data'],
);
} else {
//TODO: UPDATE BERHASIL
await this.transactionService.checkCallbackOrderSuccess(
response['data']['ref_id'],
response['data'],
);
}
}
@Public()
@Post('/vocagame')
async getVoca(@Req() request: FastifyRequest) {
const response = request.body;
console.log('responsevocagame', response);
if (response['status'] != 'Success') {
//TODO: UPDATE GAGAL
console.log('responsevocagame1', response['status'])
if (response['status'] != 'Processing') {
console.log('responsevocagame2', response['status'])
await this.transactionService.checkCallbackOrderFailed(
response['reference'],
response,
);
}
} else {
//TODO: UPDATE BERHASIL
console.log('responsevocagame3', response['status'])
if (response['status'] != 'Processing') {
console.log('responsevocagame4', response['status'])
await this.transactionService.checkCallbackOrderSuccess(
response['reference'],
response,
);
}
}
} }
} }

View File

@@ -1,9 +1,22 @@
import { Body, Controller, Get, HttpStatus, Param, ParseUUIDPipe, Post, Put, Query, Request } from '@nestjs/common'; import {
Body,
Controller,
Get,
Header,
HttpStatus,
Param,
ParseUUIDPipe,
Post,
Put,
Query,
Request, Res
} from '@nestjs/common';
import { TransactionService } from './transaction.service'; import { TransactionService } from './transaction.service';
import { DistributeTransactionDto } from './dto/distribute-transaction.dto'; import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
import { OrderTransactionDto } from './dto/order-transaction.dto'; import { OrderTransactionDto } from './dto/order-transaction.dto';
import { AddSaldoSupplier } from './dto/add-saldo-supplier.dto'; import { AddSaldoSupplier } from './dto/add-saldo-supplier.dto';
import { DepositReturnDto } from './dto/deposit_return.dto'; import { DepositReturnDto } from './dto/deposit_return.dto';
import { ExportTransactionDto } from './dto/export-transaction.dto';
@Controller({ @Controller({
path: 'transaction', path: 'transaction',
@@ -76,9 +89,50 @@ export class TransactionController {
async orderTransactionProd( async orderTransactionProd(
@Body() orderTransactionDto: OrderTransactionDto, @Body() orderTransactionDto: OrderTransactionDto,
@Request() req, @Request() req,
) {
if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) {
return {
data: await this.transactionService.orderTransaction(
orderTransactionDto,
req.user,
),
statusCode: HttpStatus.CREATED,
message: 'success',
};
} else {
return {
data: await this.transactionService.orderTransactionProd(
orderTransactionDto,
req.user,
),
statusCode: HttpStatus.CREATED,
message: 'success',
};
}
}
@Post('order-bill-prod')
async orderTransactioBillnProd(
@Body() orderTransactionDto: OrderTransactionDto,
@Request() req,
) { ) {
return { return {
data: await this.transactionService.orderTransactionProd( data: await this.transactionService.orderTransactionBillProd(
orderTransactionDto,
req.user,
),
statusCode: HttpStatus.CREATED,
message: 'success',
};
}
@Post('check-bill')
async checkBill(
@Body() orderTransactionDto: OrderTransactionDto,
@Request() req,
) {
return {
data: await this.transactionService.checkBill(
orderTransactionDto, orderTransactionDto,
req.user, req.user,
), ),
@@ -102,12 +156,48 @@ export class TransactionController {
}; };
} }
@Post('rollback-jurnal')
async rollbackJurnal(@Body() request, @Request() req) {
const data = await this.transactionService.rollbackJurnal(request.trxId);
return {
data,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('resend-partner/success/:code')
async resendSuccess(@Request() req, @Param('code') code: string) {
const data = await this.transactionService.resendOrderToPartner(code, true);
return {
data,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('resend-partner/failed/:code')
async resendFailed(@Request() req, @Param('code') code: string) {
const data = await this.transactionService.resendOrderToPartner(
code,
false,
);
return {
data,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('history') @Get('history')
async getHistoryTransactionUser( async getHistoryTransactionUser(
@Query('page') page: number, @Query('page') page: number,
@Query('pageSize') pageSize: number, @Query('pageSize') pageSize: number,
@Query('start') startDate: string, @Query('start') startDate: string,
@Query('end') endDate: string, @Query('end') endDate: string,
@Query('trxId') trxId: string,
@Query('partnerTrxId') partnerTrxId: string,
@Request() req, @Request() req,
) { ) {
const data = await this.transactionService.transactionHistoryByUser( const data = await this.transactionService.transactionHistoryByUser(
@@ -115,6 +205,8 @@ export class TransactionController {
req.user.userId, req.user.userId,
startDate == 'null' ? null : startDate, startDate == 'null' ? null : startDate,
endDate == 'null' ? null : endDate, endDate == 'null' ? null : endDate,
trxId == 'null' ? null : trxId,
partnerTrxId == 'null' ? null : partnerTrxId,
pageSize, pageSize,
); );
@@ -125,12 +217,35 @@ export class TransactionController {
}; };
} }
@Get('check-bill-history')
async getCheckBillHistory(
@Param('id') id: string,
@Query('page') page: number,
@Query('pageSize') pageSize: number,
@Request() req,
) {
const [data, count] = await this.transactionService.findAll(
req.user.userId,
page,
pageSize,
);
return {
data,
count,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('history-user/:id') @Get('history-user/:id')
async getHistoryTransactionUserByParam( async getHistoryTransactionUserByParam(
@Query('page') page: number, @Query('page') page: number,
@Query('pageSize') pageSize: number, @Query('pageSize') pageSize: number,
@Query('start') startDate: string, @Query('start') startDate: string,
@Query('end') endDate: string, @Query('end') endDate: string,
@Query('trxId') trxId: string,
@Query('partnerTrxId') partnerTrxId: string,
@Param('id', ParseUUIDPipe) id: string, @Param('id', ParseUUIDPipe) id: string,
) { ) {
const data = await this.transactionService.transactionHistoryByUser( const data = await this.transactionService.transactionHistoryByUser(
@@ -138,6 +253,8 @@ export class TransactionController {
id, id,
startDate == 'null' ? null : startDate, startDate == 'null' ? null : startDate,
endDate == 'null' ? null : endDate, endDate == 'null' ? null : endDate,
trxId == 'null' ? null : trxId,
partnerTrxId == 'null' ? null : partnerTrxId,
pageSize, pageSize,
); );
@@ -159,6 +276,29 @@ export class TransactionController {
page, page,
req.user.userId, req.user.userId,
userDestination, userDestination,
'detail',
pageSize,
);
return {
...data,
statusCode: HttpStatus.OK,
message: 'success',
};
}
@Get('history-deposit-profile')
async getHistoryDepositUserProfile(
@Query('page') page: number,
@Query('pageSize') pageSize: number,
@Query('user-destination') userDestination: string,
@Request() req,
) {
const data = await this.transactionService.topUpHistoryByUser(
page,
req.user.userId,
userDestination,
'profile',
pageSize, pageSize,
); );

View File

@@ -10,15 +10,32 @@ import { CoaService } from './coa.service';
import { ProductModule } from '../product/product.module'; import { ProductModule } from '../product/product.module';
import { UsersModule } from 'src/users/users.module'; import { UsersModule } from 'src/users/users.module';
import { ConfigurableModule } from '../configurable/configurable.module'; import { ConfigurableModule } from '../configurable/configurable.module';
import { CheckBillHistory } from './entities/check-bill-history.entity';
import { CallbackPartner } from './entities/callback-partner.entity';
import { ProductHistoryPrice } from '../product/entities/product-history-price.entity';
import { ProductHistoryStatus } from '../product/entities/product-history-status.entity';
import { ExcelController } from './excel.controller';
import {ProductSubCategories} from "../product/entities/product-sub-category.entity";
@Module({ @Module({
imports: [ imports: [
TypeOrmModule.forFeature([COA, TransactionJournal, Transactions]), TypeOrmModule.forFeature([
COA,
TransactionJournal,
Transactions,
CheckBillHistory,
CallbackPartner,
ProductHistoryPrice,
ProductHistoryStatus,
ProductSubCategories
]),
ProductModule, ProductModule,
ConfigurableModule, ConfigurableModule,
forwardRef(() => UsersModule), forwardRef(() => {
return UsersModule;
}),
], ],
controllers: [TransactionController, PpobCallbackController], controllers: [TransactionController, PpobCallbackController, ExcelController],
providers: [TransactionService, CoaService], providers: [TransactionService, CoaService],
exports: [CoaService], exports: [CoaService],
}) })

File diff suppressed because it is too large Load Diff

View File

@@ -6,4 +6,19 @@ export class CreateSupplierDto {
@IsNotEmpty() @IsNotEmpty()
code: string; code: string;
@IsNotEmpty()
url: string;
@IsNotEmpty()
irs_id: string;
@IsNotEmpty()
irs_pin: string;
@IsNotEmpty()
irs_user: string;
@IsNotEmpty()
irs_pass: string;
} }

View File

@@ -27,4 +27,9 @@ export class Partner extends BaseModel {
@Column({ default: true }) @Column({ default: true })
status: boolean; status: boolean;
@Column({
default: '',
})
callback_url: string;
} }

View File

@@ -16,6 +16,31 @@ export class Supplier extends BaseModel {
@Column() @Column()
status: boolean; status: boolean;
@Column({
nullable: true
})
url: string;
@Column({
nullable: true
})
irs_id: string;
@Column({
nullable: true
})
irs_pin: string;
@Column({
nullable: true
})
irs_user: string;
@Column({
nullable: true
})
irs_pass: string;
coa: COA; coa: COA;
coa_undistribute: COA; coa_undistribute: COA;

View File

@@ -22,7 +22,7 @@ export class SupplierService {
) )
private coaService: CoaService, private coaService: CoaService,
private connection: Connection, private connection: Connection,
) {} ) { }
async create(createSupplierDto: CreateSupplierDto) { async create(createSupplierDto: CreateSupplierDto) {
const check = await this.supplierRepository.findOne({ const check = await this.supplierRepository.findOne({
@@ -43,6 +43,11 @@ export class SupplierService {
supplierData.id = uuid.v4(); supplierData.id = uuid.v4();
supplierData.name = createSupplierDto.name; supplierData.name = createSupplierDto.name;
supplierData.code = createSupplierDto.code; supplierData.code = createSupplierDto.code;
supplierData.url = createSupplierDto.url;
supplierData.irs_id = createSupplierDto.irs_id;
supplierData.irs_pin = createSupplierDto.irs_pin;
supplierData.irs_user = createSupplierDto.irs_user;
supplierData.irs_pass = createSupplierDto.irs_pass;
supplierData.status = false; supplierData.status = false;
await this.connection.transaction(async (manager) => { await this.connection.transaction(async (manager) => {
@@ -99,6 +104,11 @@ export class SupplierService {
const supplierData = new Supplier(); const supplierData = new Supplier();
supplierData.name = updateSupplierDto.name; supplierData.name = updateSupplierDto.name;
supplierData.url = updateSupplierDto.url;
supplierData.irs_id = updateSupplierDto.irs_id;
supplierData.irs_pin = updateSupplierDto.irs_pin;
supplierData.irs_user = updateSupplierDto.irs_user;
supplierData.irs_pass = updateSupplierDto.irs_pass;
supplierData.status = true; supplierData.status = true;
await this.connection.transaction(async (manager) => { await this.connection.transaction(async (manager) => {

View File

@@ -20,12 +20,15 @@ import * as uuid from 'uuid';
import { UserDetail } from './entities/user_detail.entity'; import { UserDetail } from './entities/user_detail.entity';
import { COA } from '../transaction/entities/coa.entity'; import { COA } from '../transaction/entities/coa.entity';
import { mapSeries } from 'bluebird'; import { mapSeries } from 'bluebird';
import { Partner } from './entities/partner.entity';
@Injectable() @Injectable()
export class UsersService { export class UsersService {
constructor( constructor(
@InjectRepository(User) @InjectRepository(User)
private usersRepository: Repository<User>, private usersRepository: Repository<User>,
@InjectRepository(Partner)
private partnerRepository: Repository<Partner>,
@InjectRepository(UserDetail) @InjectRepository(UserDetail)
private userDetailRepository: Repository<UserDetail>, private userDetailRepository: Repository<UserDetail>,
@Inject( @Inject(
@@ -67,14 +70,20 @@ export class UsersService {
if (createUserDto.superior) { if (createUserDto.superior) {
let approvalRole = ''; let approvalRole = '';
if(superior.roles.name == 'Sales'){ if (superior.superior) {
approvalRole = 'Supervisor'; if(superior.roles.name == 'Sales'){
approvalRole = 'Supervisor';
} else {
approvalRole = 'Admin';
}
userData.superior = superior;
userData.status_approval = superior.superior.id;
userData.is_active = false;
} else { } else {
approvalRole = 'Admin'; userData.superior = superior;
userData.is_active = true;
} }
userData.superior = superior;
userData.status_approval = superior.superior.id;
userData.is_active = false;
} else { } else {
userData.superior = null; userData.superior = null;
userData.partner = createUserDto.partner; userData.partner = createUserDto.partner;
@@ -357,7 +366,7 @@ export class UsersService {
where: { where: {
id: id, id: id,
}, },
relations: ['superior', 'roles'], relations: ['superior', 'roles', 'partner'],
}); });
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
@@ -404,6 +413,7 @@ export class UsersService {
.leftJoinAndSelect('users.roles', 'roles') .leftJoinAndSelect('users.roles', 'roles')
.leftJoinAndSelect('users.superior', 'superior') .leftJoinAndSelect('users.superior', 'superior')
.leftJoinAndSelect('users.userDetail', 'userDetail') .leftJoinAndSelect('users.userDetail', 'userDetail')
.leftJoinAndSelect('users.partner', 'partner')
.where('users.id = :id', { .where('users.id = :id', {
id: id, id: id,
}) })
@@ -423,8 +433,17 @@ export class UsersService {
'userDetail.identity_number', 'userDetail.identity_number',
'userDetail.image_identity', 'userDetail.image_identity',
'userDetail.image_store', 'userDetail.image_store',
'partner.id',
'partner.name',
'partner.code',
'partner.npwp',
'partner.address',
'partner.phone_number',
'partner.callback_url'
]) ])
.getOne(); .getOne();
console.log('coamsk11', 'coa')
const coa = await this.coaService.findByUser(id, coaType.WALLET); const coa = await this.coaService.findByUser(id, coaType.WALLET);
let coaProfit; let coaProfit;
@@ -432,6 +451,7 @@ export class UsersService {
userData.roles.id != 'e4dfb6a3-2338-464a-8fb8-5cbc089d4209' && userData.roles.id != 'e4dfb6a3-2338-464a-8fb8-5cbc089d4209' &&
userData.roles.id != '21dceea2-416e-4b55-b74c-12605e1f8d1b' userData.roles.id != '21dceea2-416e-4b55-b74c-12605e1f8d1b'
) { ) {
console.log('coamsk12', 'coa')
coaProfit = await this.coaService.findByUser(id, coaType.PROFIT); coaProfit = await this.coaService.findByUser(id, coaType.PROFIT);
} }
@@ -670,4 +690,26 @@ export class UsersService {
} }
} }
} }
async findPartner(partnerId: string) {
try {
return this.partnerRepository.findOneOrFail({
where: {
id: partnerId,
},
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Partner not found',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
} }

3133
yarn.lock

File diff suppressed because it is too large Load Diff