Compare commits

...

518 Commits

Author SHA1 Message Date
ragilap cad9328e5d [FEAT/BE] Add restrict purchase chickin 2026-02-10 15:21:48 +07:00
Adnan Zahir b43979bbba Merge branch 'feat/delivery-order-purchase-recordings' into 'development'
Feat/delivery order purchase recordings

See merge request mbugroup/lti-api!315
2026-02-07 16:59:19 +07:00
M1 AIR 1a56b37e4e Create job for MR 2026-02-06 23:36:20 +07:00
ragilap 4340828fec [FEAT/BE] Add telur seeder and saparator category 2026-02-06 19:26:00 +07:00
ragilap f74b6476de [FEAT/BE] Add filter delivery order, adjust response purchase and fcr growing recording 2026-02-06 14:13:05 +07:00
Hafizh A. Y. 3011735458 Merge branch 'fix/hpp-harian-feed' into 'development'
[FIX][BE]: add query for feed supplier

See merge request mbugroup/lti-api!312
2026-02-06 04:29:35 +00:00
Hafizh A. Y. d40aac8960 Merge branch 'fix/search-finance' into 'development'
[FIX][BE] Add payment method search in module finance

See merge request mbugroup/lti-api!313
2026-02-06 04:29:03 +00:00
Hafizh A. Y 18672f541e fix(BE): add payment method search in module finance 2026-02-06 11:27:48 +07:00
giovanni 58aed76bbb add query for feed supplier 2026-02-06 10:58:54 +07:00
ragilap 77ec805931 [FEAT/BE] Add filter delivery order and adjust response purchase 2026-02-06 01:02:03 +07:00
Hafizh A. Y. 505db703d8 Merge branch 'fix/filter-report-customer' into 'development'
[FIX][BE] Filter by transaction or realization in report customer payment

See merge request mbugroup/lti-api!311
2026-02-05 07:19:07 +00:00
Hafizh A. Y. cc19b626e1 Merge branch 'fix/sapronak' into 'development'
[FIX][BE]: adjust query value notes

See merge request mbugroup/lti-api!309
2026-02-05 07:17:06 +00:00
Hafizh A. Y fc157dfd79 fix(BE): filter by transaction or realization in report customer payment 2026-02-05 14:16:02 +07:00
Hafizh A. Y. f407ef6a0c Merge branch 'fix/multiple-filter-finance' into 'development'
fix(BE): multiple filter, all search

See merge request mbugroup/lti-api!308
2026-02-05 03:28:26 +00:00
giovanni 248ca1d522 adjust query value notes 2026-02-05 10:27:00 +07:00
Hafizh A. Y d41f1b9495 fix(BE): multiple filter, all search 2026-02-05 10:26:44 +07:00
Hafizh A. Y. 6efab80686 Merge branch 'FEAT/BE/marketing' into 'development'
FEAT[BE] : update new concept of marketing

See merge request mbugroup/lti-api!307
2026-02-05 03:23:00 +00:00
Hafizh A. Y. 6253ca46bc Merge branch 'fix/sapronak' into 'development'
[FIX][BE]: fix query field source_warehouse type adjustment stock sapronak masuk

See merge request mbugroup/lti-api!306
2026-02-05 03:06:48 +00:00
aguhh18 aa1fd1c35b FEAT[BE] :update price calculation in sales order service for accurate rounding, add new conversion unit for quantity 2026-02-05 09:57:38 +07:00
giovanni 1f10e96288 fix query field source_warehouse 2026-02-04 15:17:05 +07:00
Hafizh A. Y. ae69b138bf Merge branch 'fix/hasil-produksi' into 'development'
[FIX][BE]: fix hasil produksi deplesi std dan filter recording approved

See merge request mbugroup/lti-api!305
2026-02-04 07:50:54 +00:00
Hafizh A. Y. b2dd9a6e13 Merge branch 'feat/sapronak' into 'development'
[FEAT][BE]: add query adjustment stock at closing sapronak

See merge request mbugroup/lti-api!304
2026-02-04 07:50:07 +00:00
Hafizh A. Y. 9bc66798d4 Merge branch 'fix/BE/remove_fcr_id_project-flock' into 'development'
[FEAT/BE]Fix remove fcr master data and changes to standart production

See merge request mbugroup/lti-api!303
2026-02-04 07:49:44 +00:00
aguhh18 1d95976360 FEAT[BE] :add marketing type field to delivery and sales order DTOs, enhance validation and service logic for consistent marketing type handling 2026-02-04 14:47:56 +07:00
giovanni 114f1a7c24 fix hasil produksi deplesi std dan filter recording approved 2026-02-04 13:51:55 +07:00
ragilap 14cc7ef2ae [FEAT/BE] Add field purchase response get all 2026-02-04 13:31:20 +07:00
aguhh18 357b5709f5 FEAT[BE] :add conversion fields and week tracking to marketing product DTOs and update mapping functions 2026-02-04 12:48:05 +07:00
aguhh18 474c42770b FEAT[BE] :add week calculation and chickin preload to product warehouse services 2026-02-04 11:46:32 +07:00
aguhh18 90de167fcd FEAT[BE] :add type filtering and validation to product warehouse services 2026-02-04 09:59:15 +07:00
giovanni 7183df6938 add query adjustment stock at closing sapronak 2026-02-04 09:17:16 +07:00
ragilap b862fc4113 [FEAT/BE]Fix remove fcr master data and changes to standart production 2026-02-03 17:01:50 +07:00
aguhh18 f59cdd821a FEAT[BE] :add marketing type and conversion fields to marketing entities and services 2026-02-03 13:32:37 +07:00
Hafizh A. Y. 22038533d7 Merge branch 'FEAT/BE/Production_standard' into 'development'
FEAT[BE] :add production standard detail creation for growing only FCR

See merge request mbugroup/lti-api!302
2026-02-03 05:58:15 +00:00
Hafizh A. Y. 5641cadeec Merge branch 'Fix/BE/recording_avaible_qty' into 'development'
[FEAT/BE]Fix add new response depletions_rate

See merge request mbugroup/lti-api!301
2026-02-03 05:09:53 +00:00
ragilap 4eacdd543a [FEAT/BE]Fix add new response depletions_rate 2026-02-03 12:08:11 +07:00
aguhh18 f75225b81b FEAT[BE] :add production standard detail creation for growing project category with zero target values 2026-02-03 12:02:45 +07:00
Hafizh A. Y. a0221bb79c Merge branch 'Fix/BE/recording_avaible_qty' into 'development'
[FEAT/BE]Fix create avaible qty

See merge request mbugroup/lti-api!300
2026-02-03 04:18:06 +00:00
ragilap 82f0db107a [FEAT/BE]Fix create avaible qty 2026-02-03 11:17:11 +07:00
Hafizh A. Y. d2ce0918b5 Merge branch 'dev/teguh' into 'development'
FIX/BE: fix closing keuangan kalkulasi penjualan, marketing fifo, transfer laying fifo stock alocation

See merge request mbugroup/lti-api!298
2026-02-03 02:34:33 +00:00
Hafizh A. Y. 8f4fce1219 Merge branch 'Fix/BE/Purchase-rejected' into 'development'
Fix/be/purchase rejected

See merge request mbugroup/lti-api!297
2026-02-03 02:34:09 +00:00
Hafizh A. Y. b7ecf1dfcf Merge branch 'fix/BE/US-281-adjustment-recording-egg-mass' into 'development'
[FEAT/BE] fix bug recording and closing counting sapronak

See merge request mbugroup/lti-api!296
2026-02-03 02:33:54 +00:00
aguhh18 9a328ae1e4 FEAT[BE] :implement proportional distribution with rounding for stock allocation in transfer laying approval process 2026-02-03 08:06:52 +07:00
aguhh18 58ae03a090 FIX[BE] :remove unnecessary quantity calculations in Adjustment method to streamline stock adjustment logic 2026-02-02 21:45:18 +07:00
aguhh18 e406b20ca7 FEAT[BE] :Fixing fifo stock when marketing deleted 2026-02-02 21:11:27 +07:00
aguhh18 1c1f2f03aa FIX[BE] :remove unused product warehouse repository import and streamline stock consumption logic in consumeDeliveryStock method 2026-02-02 16:46:33 +07:00
aguhh18 ce108da847 FEAT[BE] :enhance production data calculations by adding TotalBirdSold and refining profit/loss metrics 2026-02-02 15:36:06 +07:00
ragilap e968b8ed9c Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into Fix/BE/Purchase-rejected 2026-02-02 15:24:11 +07:00
ragilap 96627e964f [FEAT/BE]Purchase rejected payload 2026-02-02 15:23:15 +07:00
ragilap 6e0ff557a8 [FEAT/BE]delete adjustment use in doc closing counting sapronak 2026-02-02 14:59:29 +07:00
ragilap f4790e56ea [FEAT/BE] update herautics for closing counting sapronak 2026-02-02 14:25:37 +07:00
ragilap 760b37449e [FEAT/BE] fix bug recording and closing counting sapronak 2026-02-02 14:08:29 +07:00
Hafizh A. Y. fb2a7a6676 Merge branch 'fix/inventory-stock' into 'development'
[FIX][BE]: add response stock to informasi stock product

See merge request mbugroup/lti-api!295
2026-02-02 06:18:10 +00:00
Hafizh A. Y. a89c2edb99 Merge branch 'dev/teguh' into 'development'
FEAT[BE] : change transfer to laying number to correct format

See merge request mbugroup/lti-api!294
2026-02-02 06:17:48 +00:00
aguhh18 5b80081d05 FIX[BE] :add handling for empty input in ToSummaryDto function to return zeroed summary 2026-02-02 13:02:30 +07:00
giovanni 9bf33d2bae add response stock to informasi stock product 2026-02-02 12:15:41 +07:00
aguhh18 2cc89b31be Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-02-02 07:44:09 +07:00
aguhh18 3d92c4eb54 FEAT[BE] :refactor egg production data retrieval to use date parameter in GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds method 2026-02-02 07:42:22 +07:00
Adnan Zahir 75b822eb19 Merge branch 'production' into 'development'
Back Merge Production

See merge request mbugroup/lti-api!292
2026-01-31 10:55:55 +07:00
Adnan Zahir 3b661919c0 Merge branch 'fix/daily-checklist' into 'development'
[FIX][BE]: add validation max size upload file 5 MB

See merge request mbugroup/lti-api!289
2026-01-31 10:40:25 +07:00
Adnan Zahir 74146e90c6 Merge branch 'fix/sapronak' into 'development'
[FIX][BE]: fix filter by kandang

See merge request mbugroup/lti-api!288
2026-01-31 10:40:07 +07:00
aguhh18 1a9936eaa1 FIX[BE] :remove obsolete db_lti_erp-202601271102-stg.sql file 2026-01-30 19:45:11 +07:00
giovanni c257a2cb28 add validation max size upload file 5 MB 2026-01-30 15:09:23 +07:00
giovanni 8a403e803c fix filter by kandang 2026-01-30 14:47:13 +07:00
aguhh18 0707876a81 FEAT[BE] :update movement number format in GenerateMovementNumber method to include hyphen 2026-01-30 14:31:04 +07:00
Adnan Zahir c191776e6c Merge branch 'fix/daily-checklist' into 'development'
[FIX][BE]: fix search list daily checklist

See merge request mbugroup/lti-api!286
2026-01-30 14:04:18 +07:00
Adnan Zahir 4bdcadb898 Merge branch 'feat/inventory-logs' into 'development'
[FEAT][BE]: add migration add field stock to stock_logs; adjust logic stock for insert data stock_logs

See merge request mbugroup/lti-api!275
2026-01-30 13:27:16 +07:00
giovanni 4f9cd5131f Merge branch 'development' into feat/inventory-logs 2026-01-30 12:11:34 +07:00
giovanni 703c1548c9 fix search list daily checklist 2026-01-30 11:49:13 +07:00
Adnan Zahir 616250d38b Merge branch 'fix/data-production-age' into 'development'
[FIX][BE]: Fix/data production age

See merge request mbugroup/lti-api!284
2026-01-30 11:27:34 +07:00
giovanni a312b32aa2 Merge branch 'development' into fix/data-production-age 2026-01-30 10:48:06 +07:00
giovanni 9b6637066e fix calculate age at closing data production 2026-01-30 10:46:54 +07:00
Adnan Zahir 4496d211a1 Merge branch 'dev/teguh' into 'development'
FEAT[BE] :add validation if supplier id not null in transfer stock

See merge request mbugroup/lti-api!281
2026-01-30 10:38:09 +07:00
Adnan Zahir 2c93558d05 Merge branch 'FIX/BE/Marketing' into 'development'
FIX[BE]; fixing penjualan qty tidak berkurang jika qty tida ada dalam stockable

See merge request mbugroup/lti-api!283
2026-01-30 10:18:58 +07:00
aguhh18 d5b3120ea3 FEAT[BE] :add GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIdsAll method and update usage in calculateProductionData 2026-01-30 08:42:03 +07:00
aguhh18 4a85643aef Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-30 08:34:19 +07:00
aguhh18 22bd0e5891 FEAT[BE] :enhance UpdateOne method with validation for source and target kandang ownership and quantity checks 2026-01-30 08:24:43 +07:00
Adnan Zahir d1e3234f73 Merge branch 'feat/BE/sso-adjustment' into 'development'
Feat/be/sso adjustment

See merge request mbugroup/lti-api!273
2026-01-29 18:46:52 +07:00
aguhh18 3d1d9c418b FEAT[BE] :implement movement number generation and sequence management for transfer layings 2026-01-29 16:52:19 +07:00
aguhh18 3669f20f4a FEAT[BE] :add validation if supplier id not null in transfer stock 2026-01-29 14:50:46 +07:00
ragilap a21b554fc7 [FIX/BE-US] changes permission to redis and scope 2026-01-29 14:33:26 +07:00
aguhh18 86caa6c4d4 FIX[BE]; fixing penjualan qty tidak berkuranga 2026-01-29 12:24:32 +07:00
Hafizh A. Y. ef286949f8 Merge branch 'Fix/BE/US-281-adjustment-recording-egg-mass' into 'development'
[FIX/BE-US] delete *1000 egg mass

See merge request mbugroup/lti-api!274
2026-01-29 02:50:55 +00:00
Adnan Zahir 16157b135f Merge branch 'revert-392b2f51' into 'development'
Revert "Edit production.yml"

See merge request mbugroup/lti-api!280
2026-01-28 17:34:32 +07:00
kris a2012aa145 Edit production.yml 2026-01-28 10:34:31 +00:00
Adnan Zahir 478487870b Revert "Edit production.yml"
This reverts commit 392b2f51ad
2026-01-28 17:34:11 +07:00
kris 392b2f51ad Edit production.yml 2026-01-28 10:32:18 +00:00
Adnan Zahir 20a45bb71e Edit production.yml 2026-01-28 17:20:52 +07:00
Adnan Zahir 9c9cd1dd1b Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!279
2026-01-28 17:10:47 +07:00
Adnan Zahir bb8e4198f4 Merge branch 'development' into 'staging'
Activated migrate production no manual

See merge request mbugroup/lti-api!278
2026-01-28 17:03:46 +07:00
M1 AIR 6b58eb0c65 Activated migrate production no manual 2026-01-28 16:59:52 +07:00
kris 97a807f494 Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!277
2026-01-28 09:46:17 +00:00
kris bee9feafaf Merge branch 'development' into 'staging'
Activated migrate production

See merge request mbugroup/lti-api!276
2026-01-28 08:49:52 +00:00
M1 AIR d0dd12776e Activated migrate production 2026-01-28 15:48:05 +07:00
giovanni ac3623fa97 Merge branch 'development' into feat/inventory-logs 2026-01-28 13:44:26 +07:00
ragilap 705939bbf5 [FIX/BE-US] delete *1000 egg mass 2026-01-28 13:39:06 +07:00
giovanni 4d6f731f80 add migration add field stock to stock_logs; adjust logic stock for insert data stock_logs 2026-01-28 13:32:34 +07:00
Adnan Zahir a26ccb7811 Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!260
2026-01-28 13:24:37 +07:00
Adnan Zahir 24289796b9 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!272
2026-01-28 11:32:10 +07:00
Adnan Zahir 9dd4a93476 Merge branch 'feat/BE/sso-adjustment' into 'development'
[FIX/BE-US]add feature restrict by location and areas in roles

See merge request mbugroup/lti-api!189
2026-01-28 11:22:47 +07:00
Hafizh A. Y. b468ba3df9 Merge branch 'fix/path-s3' into 'development'
fix(BE): limit path to 255

See merge request mbugroup/lti-api!271
2026-01-28 04:22:10 +00:00
Hafizh A. Y 2127e9d1f4 fix(BE): limit path to 255 2026-01-28 11:21:47 +07:00
Hafizh A. Y. 1dae84101f Merge branch 'fix/path-s3' into 'development'
fix(BE): bug path s3

See merge request mbugroup/lti-api!270
2026-01-28 04:13:48 +00:00
Hafizh A. Y. 595ad6ed17 Merge branch 'FIX/BE/Expense' into 'development'
FIX/BE/Expense fixing tab not appear when expense attached to location only

See merge request mbugroup/lti-api!269
2026-01-28 04:13:30 +00:00
Hafizh A. Y. 8c71e7f2a3 Merge branch 'fix/BE/Purchase-edit-qty' into 'development'
[FIX/BE-US] fixing stock log delete recording and purchase

See merge request mbugroup/lti-api!267
2026-01-28 04:13:16 +00:00
Hafizh A. Y 43f9b660ce fix(BE): bug path s3 2026-01-28 11:12:22 +07:00
aguhh18 641b7ebd38 [FIX] fixing tab not appear when expense attached to location only 2026-01-28 11:01:27 +07:00
Hafizh A. Y. 396c1b5e45 Merge branch 'fix/path-s3' into 'development'
[FIX][BE] S3 prefix path

See merge request mbugroup/lti-api!268
2026-01-28 03:28:21 +00:00
Hafizh A. Y 2c169e7f83 fix(BE): s3 prefix path 2026-01-28 10:26:13 +07:00
ragilap 150f8e8606 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/Purchase-edit-qty 2026-01-28 10:09:05 +07:00
ragilap 1a0261ed36 [FIX/BE-US] fixing stock log delete recording and purchase 2026-01-28 10:08:41 +07:00
Hafizh A. Y. c3fe6b0463 Merge branch 'fix/daily-checklist' into 'development'
[FIX][BE]: add migration for change type data id tables module daily checklist

See merge request mbugroup/lti-api!266
2026-01-28 03:06:32 +00:00
Hafizh A. Y. 207e8ee3c4 Merge branch 'FEAT/BE/Transfer_stock' into 'development'
[FEAT][BE-transfer_Stock]L Update StockTransferDelivery and TransferDeliveryDTO to allow optional SupplierId

See merge request mbugroup/lti-api!265
2026-01-28 03:05:31 +00:00
Hafizh A. Y. f2195ae208 Merge branch 'FIX/BE/Closing_penjualan' into 'development'
FIX[BE-Closing_penjualan]: fixing penjualan ayam tidak mucnul di in closing penjualan

See merge request mbugroup/lti-api!263
2026-01-28 03:04:53 +00:00
giovanni 8086d2fb9e adjust query 2026-01-28 09:50:03 +07:00
giovanni 3d39d6d31e adjust validation select phase 2026-01-28 09:46:34 +07:00
aguhh18 3d70701d03 [FIX] Update validation for Query limit to remove max constraint 2026-01-28 09:21:44 +07:00
ragilap 8410573ee6 [FIX/BE-US] add transfer to laying filter location and area 2026-01-27 22:28:14 +07:00
giovanni 095080320c add migration for change type data id tables module daily checklist 2026-01-27 21:20:17 +07:00
aguhh18 e503a84660 [FEAT] Add stock logging for transfer laying process and introduce new StockLogType for transfer laying 2026-01-27 20:43:01 +07:00
aguhh18 6cac4f0243 [FEAT] Update StockTransferDelivery and TransferDeliveryDTO to allow optional SupplierId 2026-01-27 16:57:36 +07:00
Hafizh A. Y. 958dd4f241 Merge branch 'fix/sort-approval' into 'development'
fix(BE): change name from sort to order

See merge request mbugroup/lti-api!264
2026-01-27 08:31:17 +00:00
Hafizh A. Y 37f0324e2a fix(BE): change name from sort to order 2026-01-27 15:30:44 +07:00
aguhh18 77043005dd [FIX]BE: fixing penjualan ayam tidak mucnul di in closing penjualan 2026-01-27 14:53:51 +07:00
Hafizh A. Y. 8302345b30 Merge branch 'fix/data-produksi' into 'development'
[FIX][BE]: fix closing data produksi PENJUALAN

See merge request mbugroup/lti-api!261
2026-01-27 07:53:45 +00:00
Hafizh A. Y. 461877f75c Merge branch 'fix/sort-approval' into 'development'
fix(BE): sorting by date approval get all

See merge request mbugroup/lti-api!262
2026-01-27 07:53:21 +00:00
Hafizh A. Y f3ddd79974 fix(BE): sorting by date approval get all 2026-01-27 14:52:32 +07:00
ragilap 8848a50e3b Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment 2026-01-27 14:22:18 +07:00
giovanni ae7e53ac1f add flag layer 2026-01-27 13:26:04 +07:00
giovanni ba20394a10 fix closing data produksi sales 2026-01-27 12:27:25 +07:00
Adnan Zahir b8de42b6fa Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!259
2026-01-27 11:49:30 +07:00
Adnan Zahir aa94c7cc02 Merge branch 'fix/BE/Report-purchasing-Debt-supplier-and-Closing-counting-sapronak' into 'development'
[FIX/BE-US] remove stock logs counting sapronak

See merge request mbugroup/lti-api!258
2026-01-27 11:47:39 +07:00
ragilap 5621c63e9a [FIX/BE-US] remove stock logs counting sapronak 2026-01-27 11:44:54 +07:00
ragilap 0920b91271 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment 2026-01-27 10:46:49 +07:00
ragilap 00cdfb692b [FIX/BE-US] feat adjustment location and area 2026-01-27 10:34:25 +07:00
Adnan Zahir eef3c0f759 Merge branch 'development' into 'staging'
Staging

See merge request mbugroup/lti-api!257
2026-01-27 10:20:04 +07:00
Adnan Zahir 3c77aff413 Merge branch 'dev/teguh' into 'development'
FEAT[BE]: transfer to laying, stock transfer, refactor adjustment, fix  age closing penjualan, filter transfer to laying

See merge request mbugroup/lti-api!256
2026-01-27 10:17:00 +07:00
Hafizh A. Y. f8d42dbdb3 Merge branch 'fix/BE/Report-purchasing-Debt-supplier-and-Closing-counting-sapronak' into 'development'
[FIX/BE-US] fix closing count sapronak,expense notes purchase

See merge request mbugroup/lti-api!255
2026-01-27 03:16:34 +00:00
Adnan Zahir e881c2b952 Merge branch 'FIX/BE/Closing_keuangan' into 'development'
[FIX]BE: fixing and refactoring closing keuangan to use hpp service and repo for some getter data

See merge request mbugroup/lti-api!254
2026-01-27 10:16:01 +07:00
Adnan Zahir 52ebcc5c2d Merge branch 'fix/hpp-calculate' into 'development'
[FIX][BE]: adjust calculate hpp filter delivery date marketing delivery

See merge request mbugroup/lti-api!253
2026-01-27 10:09:19 +07:00
aguhh18 3e0291c2ba Feat[BE]: enhance transfer laying functionality with comprehensive filtering options and improved DTO structures 2026-01-26 23:50:04 +07:00
aguhh18 7a704c4ec4 Feat[BE]: implement max target quantity retrieval for kandangs and update routes 2026-01-26 18:03:54 +07:00
ragilap bd0f89c521 [FIX/BE-US] fix closing count sapronak,expense notes purchase 2026-01-26 16:47:28 +07:00
aguhh18 b83ebc0ff9 Feat[BE] : add stock log to transfer service 2026-01-26 16:26:59 +07:00
aguhh18 1572dfd0b8 Refactor[BE] adjustment stock handling: remove stock_log_id, update relations, and enhance transfer logging 2026-01-26 16:26:20 +07:00
aguhh18 258fd1d7e0 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-26 13:40:17 +07:00
aguhh18 f44ddef79b Fix[BE]: update age calculation logic to include additional product flags and start day laying form week 18 2026-01-26 13:39:56 +07:00
aguhh18 9339e1e9f0 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into FIX/BE/Closing_keuangan 2026-01-26 13:01:16 +07:00
aguhh18 798dd7f9a3 Fix[BE]: fixing and refactoring closing keuangan to use hpp service and repo for some getter data 2026-01-26 13:00:30 +07:00
giovanni 7a8f813e1f adjust calculate hpp filter delivery date marketing delivery 2026-01-26 11:44:22 +07:00
Adnan Zahir d656eedfbe Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!252
2026-01-26 11:24:41 +07:00
ragilap 571f6b4bf3 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment 2026-01-25 22:16:38 +07:00
ragilap 76d980878d Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment 2026-01-24 19:03:52 +07:00
Hafizh A. Y. fdd8e3ec31 Merge branch 'fix/hpp-calculate' into 'development'
[FIX][BE]: fix calculate sisa berat telur

See merge request mbugroup/lti-api!251
2026-01-24 09:34:24 +00:00
Hafizh A. Y. 0f6cd3a054 Merge branch 'fix/BE/UUIT-Recording-closing-report-uniformity-dashboard' into 'development'
Fix/be/uuit recording and dashboard

See merge request mbugroup/lti-api!250
2026-01-24 09:34:07 +00:00
Hafizh A. Y. c6d087eeab Merge branch 'fix/customer-finance' into 'development'
[FIX][BE] Edit customer, finance: bank optional, nominal minus, and filter

See merge request mbugroup/lti-api!249
2026-01-24 09:31:09 +00:00
Hafizh A. Y. 437cd3beda Merge branch 'fix/warehouse' into 'development'
[FIX][BE]: add filter location id

See merge request mbugroup/lti-api!248
2026-01-24 09:30:49 +00:00
ragilap 8fbce5a01e Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/UUIT-Recording-closing-report-uniformity-dashboard 2026-01-24 14:20:30 +07:00
ragilap f4b2408698 [FIX/BE-US] fix recording stock and dashboard filtering 2026-01-24 14:20:14 +07:00
giovanni 8c84981812 adjust get weight remaining 2026-01-24 14:17:50 +07:00
Hafizh A. Y 458c8e0a91 fix(BE): edit customer, finance: bank optional, nominal minus, and filter 2026-01-24 13:35:13 +07:00
giovanni 4646bf5577 add filter location id 2026-01-24 13:34:21 +07:00
Adnan Zahir e60c08e09e Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!247
2026-01-24 12:37:28 +07:00
Adnan Zahir 33d3b18468 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!246
2026-01-24 12:14:46 +07:00
giovanni 8b1831fc73 adjust take weight remaining 2026-01-24 12:03:09 +07:00
Adnan Zahir 919dc5c2e8 Merge branch 'dev/teguh' into 'development'
FIX[BE]: module transfer, report penjualan, closing penjualan

See merge request mbugroup/lti-api!244
2026-01-24 12:01:47 +07:00
Adnan Zahir 129d253683 Merge branch 'fix/hpp-calculate' into 'development'
[FIX][BE]: fix HPP get egg sales pieces and weight

See merge request mbugroup/lti-api!245
2026-01-24 11:38:31 +07:00
giovanni f69321d9cd fix get egg sales pieces and weight 2026-01-24 11:25:11 +07:00
aguhh18 74158138c0 Fix[BE]: enhance error logging and messages in transfer service 2026-01-24 10:38:52 +07:00
aguhh18 699a6e9289 Fix[BE]: update error message for insufficient stock in adjustment service 2026-01-24 09:40:00 +07:00
aguhh18 507d6c4293 FEAT[BE]: implement HPP on penjualan harian 2026-01-23 22:02:19 +07:00
aguhh18 43286cead1 Fix[BE]: fixing transfer to non kandang warehouse 2026-01-23 19:45:13 +07:00
aguhh18 1216e65419 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-23 17:54:58 +07:00
Adnan Zahir 42f030a780 Merge branch 'fix/data-production' into 'development'
[FIX][BE]: fix value all standard

See merge request mbugroup/lti-api!243
2026-01-23 16:27:54 +07:00
Adnan Zahir cf475d678e Merge branch 'fix/BE/Report-purchasing-Debt-supplier-and-Closing-counting-sapronak' into 'development'
[FIX/BE-US] fix closing counting sapronak

See merge request mbugroup/lti-api!242
2026-01-23 16:20:27 +07:00
Adnan Zahir a42c201ac6 Merge branch 'fix/hpp-calculate' into 'development'
[FIX][BE]: create common service calculate hpp

See merge request mbugroup/lti-api!241
2026-01-23 16:16:52 +07:00
Adnan Zahir d4699fba5b Merge branch 'fix/BE/UUIT-Recording-closing-report-uniformity-dashboard' into 'development'
Fix/be/uuit recording closing report uniformity dashboard

See merge request mbugroup/lti-api!240
2026-01-23 16:11:06 +07:00
giovanni e1ab5a90cb fix value all standard 2026-01-23 14:20:11 +07:00
aguhh18 f060da1cd3 FIX[BE]: Integrate StockLogRepository into deliveryOrdersService for stock logging functionality 2026-01-23 12:35:34 +07:00
ragilap f82ac01e7c [FIX/BE-US] fix recording date 2026-01-23 12:02:26 +07:00
ragilap fd2f773806 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/UUIT-Recording-closing-report-uniformity-dashboard 2026-01-23 11:57:38 +07:00
ragilap 7db3afe985 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/Report-purchasing-Debt-supplier-and-Closing-counting-sapronak 2026-01-23 11:53:54 +07:00
ragilap 8dc88b97a4 [FIX/BE-US] fix closing counting sapronak 2026-01-23 11:43:50 +07:00
aguhh18 f1787d3375 FIX[BE]: Fix wrong calculation avg sales on report penjualan harian 2026-01-23 11:07:11 +07:00
aguhh18 6b4eb758e4 FIX[BE]: fixing umur on closing penjualan for penjualan OVK and PAKAN 2026-01-23 10:32:40 +07:00
giovanni d54911f8b4 adjust value hpp 2026-01-23 10:29:48 +07:00
giovanni 1edd071a8a Merge branch 'development' into fix/hpp-calculate 2026-01-23 10:24:50 +07:00
giovanni fb565ef728 fix hpp harian kandang 2026-01-23 10:01:48 +07:00
ragilap 9928b4c970 [FIX/BE-US] fix uniformity relation chickin date 2026-01-22 17:50:04 +07:00
ragilap 8c58cc4103 [FIX/BE-US] fix uniformity relation chickin date 2026-01-22 17:49:46 +07:00
giovanni 0d585a99a6 adjust api hpp per kandang and implement common service hpp 2026-01-22 17:37:28 +07:00
kris 302147787e Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!239
2026-01-22 09:06:53 +00:00
kris 19a268adfe Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!238
2026-01-22 09:00:17 +00:00
M1 AIR b1b50c3c01 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into development 2026-01-22 15:57:47 +07:00
M1 AIR c085888ca9 Update cicd no migrate prod 2026-01-22 15:57:16 +07:00
Adnan Zahir 41d3c21fef Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!231
2026-01-22 14:57:34 +07:00
Adnan Zahir ad5e832d41 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!236
2026-01-22 14:49:02 +07:00
Adnan Zahir 774c9b1d58 Merge branch 'fix/BE/US-281-adjustment-recording' into 'development'
[FIX/BE-US] fix day in recording

See merge request mbugroup/lti-api!237
2026-01-22 14:47:40 +07:00
ragilap 12ed9cd753 [FIX/BE-US] fix day in recording 2026-01-22 14:44:53 +07:00
Hafizh A. Y. 4ab1553340 Merge branch 'HOTFIX/BE/marketing' into 'development'
Hotfix/be/marketing : hotfix perhitungan penjualan ovk dan pakan, overhead only bop

See merge request mbugroup/lti-api!235
2026-01-22 07:43:10 +00:00
Hafizh A. Y. 3fa50b6344 Merge branch 'fix/BE/Report-purchasing-Debt-supplier-and-Closing-counting-sapronak' into 'development'
[FIX/BE-US] debt-supplier only show receive purchase

See merge request mbugroup/lti-api!232
2026-01-22 07:42:19 +00:00
Hafizh A. Y. 80424dee17 Merge branch 'fix/production-result' into 'development'
[FIX][BE]: remove max limit production result

See merge request mbugroup/lti-api!230
2026-01-22 07:42:02 +00:00
Hafizh A. Y. a9b33eaf28 Merge branch 'fix/BE/Purchase-edit-qty' into 'development'
[FIX/BE-US] adjustment recording and purchase stock log

See merge request mbugroup/lti-api!229
2026-01-22 07:41:50 +00:00
aguhh18 551534d02a Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into HOTFIX/BE/marketing 2026-01-22 14:32:39 +07:00
aguhh18 202a8ffc66 HOTFIX[BE]: filter closing overhead by expense category "BOP" 2026-01-22 14:29:56 +07:00
giovanni 6bc5e7d293 fix get average bw 2026-01-22 14:19:16 +07:00
ragilap 2e0827dec5 [FIX/BE-US] debt-supplier only show receive and changes lunas 2026-01-22 14:15:26 +07:00
aguhh18 87973a6c9f HOTFIX[BE]: update total price calculation based on product flags for delivery and sales orders 2026-01-22 14:15:03 +07:00
kris ebac5f5a98 Merge branch 'development' into 'staging'
Fixing staging cicd

See merge request mbugroup/lti-api!234
2026-01-22 07:14:12 +00:00
M1 AIR 1ca6c6a104 Fixing staging cicd 2026-01-22 14:12:20 +07:00
kris a1832a6144 Merge branch 'development' into 'staging'
fixing pipeline

See merge request mbugroup/lti-api!233
2026-01-22 07:01:29 +00:00
M1 AIR 78a45b11e7 fixing pipeline 2026-01-22 13:59:52 +07:00
giovanni 58b29501c0 finishing common service calculate hpp 2026-01-22 13:54:32 +07:00
ragilap bac0361df5 [FIX/BE-US] debt-supplier only show receive purchase 2026-01-22 13:53:43 +07:00
Adnan Zahir c8912e503e Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!227
2026-01-22 13:52:03 +07:00
giovanni 645a97b460 remove max limit production result 2026-01-22 13:42:36 +07:00
ragilap eb2479cc41 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/Purchase-edit-qty 2026-01-22 13:36:53 +07:00
ragilap 04ec8560a7 [FIX/BE-US] adjustment recording and purchase stock log 2026-01-22 13:35:46 +07:00
Hafizh A. Y. 12240a9e2d Merge branch 'fix/mr-development-staging' into 'development'
Fix/mr development staging

See merge request mbugroup/lti-api!228
2026-01-22 06:17:31 +00:00
giovanni f2a46843c8 continue common service hpp 2026-01-22 12:53:02 +07:00
aguhh18 06e92d1c77 [FEAT][BE}: add umur week and day on closing penjualan 2026-01-22 11:17:02 +07:00
giovanni d7ed768d14 add filter project status and location id 2026-01-22 11:06:17 +07:00
ragilap f04cbd24bd [FIX/BE-US] adjustment recording 2026-01-22 11:06:17 +07:00
aguhh18 ec4b849778 FIX[BE]: fixing wrong index data on adjustment. change get from stocklogs to adjustment table 2026-01-22 11:06:17 +07:00
aguhh18 132e043597 FEAT[BE]: update warehouse DTO references in product warehouse and add UOM preload 2026-01-22 11:06:17 +07:00
aguhh18 e99af36796 FIX[BE] fix wrong calculation on summary report marketing 2026-01-22 11:06:17 +07:00
aguhh18 f6bdb17699 FIX[BE]: fixing report penjualan add avg weight and price to response 2026-01-22 11:06:17 +07:00
aguhh18 8f7fc622f6 FIX[BE]: fixing closing penjualan add sumary 2026-01-22 11:06:17 +07:00
aguhh18 30f5ed417c FEAT[BE]: add default filterby become so_date in report markeing 2026-01-22 11:06:17 +07:00
aguhh18 1d726afa6f FEAT[BE[: enhance marketing report items with aging days calculation 2026-01-22 11:06:17 +07:00
aguhh18 96ba947952 FEAT[BE[: add avg weight and avg amount on get penjualan harian 2026-01-22 11:06:17 +07:00
aguhh18 ad0504f49e refactor: unify GetOne method to return approval alongside transfer laying 2026-01-22 11:06:17 +07:00
giovanni 0b708cd57b fix data produksi not show response 2026-01-22 11:06:17 +07:00
ragilap 32153f02b8 [FIX/BE-US] purchase edit qty approval staf add adjustment fifo system 2026-01-22 11:06:17 +07:00
M1 AIR cf37822a07 Change rules cicd no conflicts 2026-01-22 11:06:16 +07:00
Hafizh A. Y. 7fb6c3c7bf Merge branch 'fix/sapronak' into 'development'
[FIX][BE]: add filter project status and location id

See merge request mbugroup/lti-api!226
2026-01-22 03:09:32 +00:00
giovanni fd689919b0 Merge branch 'development' into fix/hpp-calculate 2026-01-22 10:05:08 +07:00
giovanni 2ad0c17fbe add filter project status and location id 2026-01-22 10:00:24 +07:00
ragilap e8c7b3f2a8 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/Purchase-edit-qty 2026-01-22 09:50:21 +07:00
Hafizh A. Y. ce09c2473c Merge branch 'Fix/BE/US-281-adjustment-recording' into 'development'
[FIX/BE-US] adjustment recording

See merge request mbugroup/lti-api!222
2026-01-22 02:49:38 +00:00
Hafizh A. Y. 3493d1d7b2 Merge branch 'dev/teguh' into 'development'
[FIX][BE]: fixing bug after SIT module report marketing and closing marketing

See merge request mbugroup/lti-api!220
2026-01-22 02:48:41 +00:00
Hafizh A. Y. 9fff954857 Merge branch 'fix/LSS416' into 'development'
[FIX][BE]: fix data produksi not show response

See merge request mbugroup/lti-api!219
2026-01-22 02:48:13 +00:00
Hafizh A. Y. c7c1e4b335 Merge branch 'fix/BE/Purchase-edit-qty' into 'development'
[FIX/BE-US] purchase edit qty approval staf & add adjustment fifo system

See merge request mbugroup/lti-api!218
2026-01-22 02:47:35 +00:00
ragilap 5dbe9bb989 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into fix/BE/Purchase-edit-qty 2026-01-22 09:33:15 +07:00
aguhh18 e555cfa950 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-22 09:27:17 +07:00
ragilap 3a457ceee5 [FIX/BE-US] adjustment sso-location 2026-01-22 09:27:11 +07:00
M1 AIR 32a8557a3b Change rules cicd no conflicts 2026-01-21 15:56:58 +07:00
kris baa49b7cf1 Merge branch 'staging' into 'production'
Revert "Merge branch 'staging' into 'development'"

See merge request mbugroup/lti-api!225
2026-01-21 08:17:34 +00:00
M1 AIR 1818f5a295 merge: sync staging with production 2026-01-21 15:16:36 +07:00
aguhh18 a73b44808f FIX[BE]: fixing wrong index data on adjustment. change get from stocklogs to adjustment table 2026-01-21 15:16:30 +07:00
Adnan Zahir 69d9137e78 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!224
2026-01-21 14:55:09 +07:00
Adnan Zahir e32b231c6c Merge branch 'fix/daily-checklist' into 'development'
fix

See merge request mbugroup/lti-api!223
2026-01-21 14:25:26 +07:00
giovanni ca6d0b160b fix 2026-01-21 14:17:43 +07:00
aguhh18 e8a89f0f17 FEAT[BE]: update warehouse DTO references in product warehouse and add UOM preload 2026-01-21 13:52:46 +07:00
giovanni d96a12776a next commit 2026-01-21 13:38:59 +07:00
Adnan Zahir adabb4e035 Merge branch 'fix/daily-checklist' into 'development'
[FIX][BE]: fix duplicate name, time type and phase id create phase activity

See merge request mbugroup/lti-api!221
2026-01-21 13:30:21 +07:00
ragilap 16a0b848bc [FIX/BE-US] adjustment recording 2026-01-21 13:06:45 +07:00
aguhh18 c2d2701d72 FIX[BE] fix wrong calculation on summary report marketing 2026-01-21 09:57:44 +07:00
aguhh18 894efa7aa5 FIX[BE]: fixing report penjualan add avg weight and price to response 2026-01-21 09:46:03 +07:00
aguhh18 d0625e7d21 FIX[BE]: fixing closing penjualan add sumary 2026-01-21 09:45:19 +07:00
giovanni 67ecdbc1dd fix duplicate name, time type and phase id create phase activity 2026-01-20 23:01:58 +07:00
aguhh18 d50ab7cc97 FEAT[BE]: add default filterby become so_date in report markeing 2026-01-20 22:42:16 +07:00
aguhh18 ad3bb0e29a FEAT[BE[: enhance marketing report items with aging days calculation 2026-01-20 22:28:34 +07:00
aguhh18 dd4dcc1c39 FEAT[BE[: add avg weight and avg amount on get penjualan harian 2026-01-20 22:10:47 +07:00
aguhh18 aa4da68680 refactor: unify GetOne method to return approval alongside transfer laying 2026-01-20 22:07:07 +07:00
giovanni 95965cb26a add common service and repo for calculate hpp 2026-01-20 18:21:49 +07:00
giovanni e4e17f16f9 fix data produksi not show response 2026-01-20 18:18:41 +07:00
ragilap edd77c5265 [FIX/BE-US] purchase edit qty approval staf add adjustment fifo system 2026-01-20 16:40:37 +07:00
Adnan Zahir dab692a0c1 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!217
2026-01-20 14:25:14 +07:00
Hafizh A. Y. e6244dea8a Merge branch 'Fix/BE/Purchase-edit-qty' into 'development'
[FIX/BE-US] purchase edit qty approval staf

See merge request mbugroup/lti-api!216
2026-01-20 07:21:27 +00:00
Hafizh A. Y. d1e4bf060e Merge branch 'fix/LSS416' into 'development'
[FIX][BE]: fix endpoint not found

See merge request mbugroup/lti-api!213
2026-01-20 07:21:16 +00:00
ragilap fc06b3e4db [FIX/BE-US] purchase edit qty approval staf 2026-01-20 14:19:02 +07:00
Adnan Zahir cf42e8c130 Merge branch 'staging' into 'production'
Staging

See merge request mbugroup/lti-api!215
2026-01-20 12:11:41 +07:00
Adnan Zahir 8ff97cb647 Merge branch 'revert-21de17b1' into 'development'
Revert "Merge branch 'staging' into 'development'"

See merge request mbugroup/lti-api!214
2026-01-20 12:08:53 +07:00
Adnan Zahir 1b7ce3c62c Revert "Merge branch 'staging' into 'development'"
This reverts merge request !212
2026-01-20 12:08:41 +07:00
Adnan Zahir 21de17b18a Merge branch 'staging' into 'development'
Staging

See merge request mbugroup/lti-api!212
2026-01-20 12:07:52 +07:00
giovanni 2aaaab91f7 fix endpoint not found 2026-01-20 12:07:16 +07:00
Adnan Zahir 4227152979 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!209
2026-01-20 11:56:00 +07:00
Hafizh A. Y. ec020ac17c Merge branch 'Fix/BE/UUIT-Recording-closing-report-uniformity-dashboard' into 'development'
[FIX/BE-US] recording,reporting,closing and uniformity

See merge request mbugroup/lti-api!211
2026-01-20 03:55:35 +00:00
Hafizh A. Y. adc30ad5cd Merge branch 'fix/LSS416' into 'development'
[FIX][BE]: adjust closing tap sapronak; add api summart total kuantitas per category and uom

See merge request mbugroup/lti-api!210
2026-01-20 03:54:47 +00:00
ragilap 9fb5395469 [FIX/BE-US] recording,reporting,closing and uniformity 2026-01-20 10:13:58 +07:00
giovanni bc771660be adjust closing tap sapronak; add api summart total kuantitas per category and uom 2026-01-20 10:03:57 +07:00
Hafizh A. Y. b615570036 Merge branch 'fix/LSS390' into 'development'
[FIX][BE]: LSS390

See merge request mbugroup/lti-api!208
2026-01-20 02:23:42 +00:00
Hafizh A. Y. c793c3cf9a Merge branch 'dev/teguh' into 'development'
FIX[BE]: fixing BE

See merge request mbugroup/lti-api!207
2026-01-20 02:23:29 +00:00
aguhh18 b3e0410f5a Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-20 09:15:21 +07:00
Hafizh A. Y. a882d5a687 Merge branch 'Feat/BE/US-Closing_finance' into 'development'
[FIX][BE]: fixing filter on report penjualan and fix stock movement to not strict to not kandang warehouse

See merge request mbugroup/lti-api!206
2026-01-20 01:41:15 +00:00
Hafizh A. Y. c0848b6d2d Merge branch 'fix/closing-sapronak' into 'development'
[FIX][BE]: query outgoing sapronak

See merge request mbugroup/lti-api!205
2026-01-20 01:40:35 +00:00
aguhh18 b240478ed5 feat[BE]: Add notes field to Update validation and update approval logic in expense services 2026-01-19 17:44:10 +07:00
giovanni 3052497fc0 adjust grouping by project flock kandang 2026-01-19 17:05:43 +07:00
giovanni 71c62c5e02 [FIX][BE]: LSS390 2026-01-19 16:19:47 +07:00
aguhh18 768961d7d6 fix[BE]: Refactor GetAll method to improve query parameter handling and formatting 2026-01-19 14:39:43 +07:00
aguhh18 8cd9627a51 feat[BE]: Add requested_qty field to LayingTransferSource and update related logic for transfer operations 2026-01-19 14:34:08 +07:00
aguhh18 378d633ea4 feat[BE]: Enhance payment allocation logic to support FIFO consumption for sales transactions 2026-01-19 09:27:37 +07:00
aguhh18 fb193fc61f fix[BE]: Update GetAllWithFilters to enhance search functionality and join conditions 2026-01-18 21:26:31 +07:00
aguhh18 af7aabdec8 fix[BE]: Adjust validation for MarketingQuery limit to remove max constraint 2026-01-18 20:50:52 +07:00
aguhh18 bac36b4f00 fix[BE]: Update error messages in TransferService to provide clearer context in Indonesian 2026-01-18 20:36:33 +07:00
aguhh18 687d02313b feat[BE]: Update TransferRelationDTO and service search logic to include warehouse names 2026-01-18 19:46:09 +07:00
aguhh18 7d3602d829 feat[BE]: Enhance CreateOne method to validate project flock closing status and handle warehouse without kandang_id 2026-01-17 13:22:01 +07:00
aguhh18 533e9aca6f FIX[BE]: Fixing filter area and location 2026-01-17 12:20:40 +07:00
giovanni dcfb5e10b4 adjust max limit to 1000 2026-01-17 11:34:12 +07:00
giovanni fbeccf4cdc fix query outgoing sapronak 2026-01-17 11:01:08 +07:00
Adnan Zahir f2ae2cc731 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!204
2026-01-17 09:04:30 +07:00
Hafizh A. Y. eda50930e7 Merge branch 'Feat/BE/US-Closing_finance' into 'development'
[FEAT][BE]: Refactor closing services and add ClosingKeuanganService and add closing keuangan perkandang(the calculation not accurate yet)

See merge request mbugroup/lti-api!203
2026-01-17 01:21:13 +00:00
Hafizh A. Y. 0bc5480a1d Merge branch 'fix/production-data-dev' into 'development'
[FIX][BE]: fix api production result

See merge request mbugroup/lti-api!202
2026-01-17 01:20:31 +00:00
aguhh18 ef482dd1b9 feat[BE]: Add new ClosingKeuangan DTO and related mapper functions 2026-01-16 21:37:51 +07:00
aguhh18 302f0ed877 fix:[BE] Remove unnecessary filters and update profit loss calculation logic in ClosingKeuanganService 2026-01-16 21:34:49 +07:00
aguhh18 31c48ee1da feat[BE]: Add GetClosingKeuanganByKandang endpoint and related service methods 2026-01-16 20:53:47 +07:00
aguhh18 8ad11af9c9 feat: Refactor closing services and add ClosingKeuanganService
- Updated ClosingRoutes to include ClosingKeuanganService.
- Removed GetClosingKeuangan method from ClosingService interface and its implementation.
- Introduced new ClosingKeuanganService with GetClosingKeuangan method to handle financial logic.
- Implemented detailed logging and error handling in the new service.
- Added GetTotalWeightProducedFromUniformityByProjectFlockID method in RecordingRepository to support weight calculations.
- Enhanced the logic for fetching and classifying product usage data by flags.
- Built comprehensive DTO responses for HPP and Profit Loss sections.
2026-01-16 12:27:18 +07:00
giovanni 688d3fa757 fix api production result 2026-01-15 19:16:58 +07:00
Hafizh A. Y. 409652c15e Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!201
2026-01-15 11:55:47 +00:00
Hafizh A. Y. 08be60c229 Merge branch 'fix/warehouse-provided-location' into 'development'
fix(BE): warehouse provided location

See merge request mbugroup/lti-api!200
2026-01-15 11:53:20 +00:00
Hafizh A. Y. 50b19dc1c3 Merge branch 'fix/BE/Purchase-bop' into 'development'
[FIX/BE-US] adjustment purchase,closing hpp expedition,supplier filter flags

See merge request mbugroup/lti-api!199
2026-01-15 11:53:12 +00:00
Hafizh A. Y e770526c1a fix(BE): warehouse provided location 2026-01-15 18:51:32 +07:00
ragilap 77af262662 [FIX/BE-US] adjustment purchase,closing hpp expedition,supplier filter flags 2026-01-15 18:45:52 +07:00
Adnan Zahir 9d611b7492 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!198
2026-01-15 18:21:47 +07:00
Hafizh A. Y. 21ff1c8ab7 Merge branch 'fix/closing-sapronak-data-produksi' into 'development'
[FIX][BE]: api closing sapronak and data produksi

See merge request mbugroup/lti-api!197
2026-01-15 11:18:49 +00:00
giovanni 2ca84ecffe fixing api closing sapronak and data produksi 2026-01-15 18:16:23 +07:00
Adnan Zahir f13e4f907c Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!196
2026-01-15 17:59:24 +07:00
Hafizh A. Y. 4d334e8d5c Merge branch 'feat/hpp-harian' into 'development'
[FEAT][BE]: add hpp harian

See merge request mbugroup/lti-api!195
2026-01-15 10:54:29 +00:00
Hafizh A. Y. 62522a751f Merge branch 'FEAT/BE/report_customer_payment' into 'development'
[Feat][BE]: creating report customer payment API

See merge request mbugroup/lti-api!190
2026-01-15 10:53:58 +00:00
giovanni 62ccc2e5d6 adjust avg weight 2026-01-15 16:48:37 +07:00
aguhh18 13fc246f21 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into FEAT/BE/report_customer_payment 2026-01-15 16:20:37 +07:00
giovanni 89293a843e adjust api hpp kandang 2026-01-15 16:07:45 +07:00
Adnan Zahir a5af469865 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!192
2026-01-15 15:58:37 +07:00
Hafizh A. Y. 8efe9b668b Merge branch 'fix/nonstock-supplier' into 'development'
fix(BE): remove supplier price in master nonstock

See merge request mbugroup/lti-api!194
2026-01-15 08:52:11 +00:00
Hafizh A. Y. 89480deeb0 Merge branch 'feat/BE/US-281-adjustment_recording' into 'development'
[FIX/BE-US] add response warehouse and project flock kandang

See merge request mbugroup/lti-api!193
2026-01-15 08:51:57 +00:00
Hafizh A. Y. 4146342120 Merge branch 'feat/daily-checklist-permission' into 'development'
[FEAT][BE]: add daily checklist permission

See merge request mbugroup/lti-api!191
2026-01-15 08:51:32 +00:00
Hafizh A. Y. b375fb964e Merge branch 'feat/production-result' into 'development'
[FEAT][BE]: adjust api production-result

See merge request mbugroup/lti-api!188
2026-01-15 08:50:33 +00:00
Hafizh A. Y fe002c9602 fix(BE): remove supplier price in master nonstock 2026-01-15 15:49:15 +07:00
ragilap f1032b44d1 [FIX/BE-US] adjustment recording 2026-01-15 15:42:57 +07:00
ragilap a3e9017e29 [FIX/BE-US] changes role to user and query 2026-01-15 14:43:59 +07:00
ragilap 7f2401311b [FIX/BE-US] add response warehouse and project flock kandang 2026-01-15 13:48:00 +07:00
kris 3f4d6c630a Update .gitlab-ci.yml file 2026-01-15 06:46:07 +00:00
aguhh18 8792161c02 feat[BE]: rename Price field to UnitPrice in CustomerPaymentReportRow for clarity 2026-01-15 10:58:00 +07:00
giovanni 37c26d5877 add daily checklist permission 2026-01-15 10:45:13 +07:00
aguhh18 c316a6d7a9 feat[BE]: add address field to CustomerRelationDTO and refactor payment report functions for improved clarity and structure 2026-01-15 10:41:44 +07:00
aguhh18 3a89e18b16 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into FEAT/BE/report_customer_payment 2026-01-14 20:10:31 +07:00
aguhh18 c6dc94a4e1 feat[BE]: add permission requirement for customer payment report route 2026-01-14 20:06:41 +07:00
aguhh18 aeb5433346 feat[BE]: refine customer payment report structure by removing unused fields and enhancing query logic for better performance 2026-01-14 20:00:44 +07:00
ragilap 549e283757 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment 2026-01-14 17:01:33 +07:00
kris cad15bcd78 Update .gitlab-ci.yml file 2026-01-14 09:46:39 +00:00
giovanni e004354420 adjust api production-result 2026-01-14 16:20:59 +07:00
kris e0ff6e6d79 Update .gitlab-ci.yml file 2026-01-14 08:26:07 +00:00
aguhh18 804ff45dbd feat[BE]: enhance customer payment report with vehicle numbers and pickup info, add date filtering 2026-01-14 15:15:29 +07:00
kris 9f1c153841 Merge branch 'development' into 'staging'
Edit .gitignore (Tom haye)

See merge request mbugroup/lti-api!184
2026-01-14 07:37:47 +00:00
kris 2a884a8d09 Edit .gitignore (Tom haye) 2026-01-14 07:35:57 +00:00
kris dbf72c7248 Delete .air.toml 2026-01-14 07:06:37 +00:00
aguhh18 7daa509cd0 feat[BE]: update customer payment report to support multiple customer IDs and nullable aging days 2026-01-14 14:06:34 +07:00
kris 894fa0b22a Update .gitlab-ci.yml file 2026-01-14 06:55:28 +00:00
Adnan Zahir d680196919 Merge branch 'development' into 'staging'
Development

See merge request mbugroup/lti-api!180
2026-01-14 13:48:25 +07:00
Adnan Zahir 9fc2d0556e Merge branch 'chore/test-staging' into 'development'
chore: test staging from development

See merge request mbugroup/lti-api!179
2026-01-14 13:46:38 +07:00
Adnan Zahir c2a89910fb chore: test staging from development 2026-01-14 13:46:15 +07:00
ragilap 32772a63c8 Revert "Revert "[FIX/BE-US]add feature restrict by location and areas in roles""
This reverts commit 26bf7f165e.
2026-01-14 13:34:44 +07:00
ragilap 26bf7f165e Revert "[FIX/BE-US]add feature restrict by location and areas in roles"
This reverts commit dff9e73ab1.
2026-01-14 13:30:48 +07:00
ragilap dff9e73ab1 [FIX/BE-US]add feature restrict by location and areas in roles 2026-01-14 13:27:52 +07:00
Hafizh A. Y. 1847e5590a Merge branch 'feat/informasi-umum' into 'development'
adjust api informasi umum filter per kandang

See merge request mbugroup/lti-api!177
2026-01-14 06:21:21 +00:00
Hafizh A. Y. 57094f664c Merge branch 'feat/BE/US-281-adjustment_recording' into 'development'
Feat/be/us 281 adjustment recording

See merge request mbugroup/lti-api!174
2026-01-14 06:20:57 +00:00
Hafizh A. Y. f8b6e12d16 Merge branch 'dev/teguh' into 'development'
FIX[BE]: fixing error on report marketing dto

See merge request mbugroup/lti-api!178
2026-01-14 06:19:52 +00:00
kris e12c34db13 Update .gitlab-ci.yml file 2026-01-14 06:18:47 +00:00
aguhh18 3012d260ec FIX[BE]: fixing error on report marketing dto 2026-01-14 11:57:56 +07:00
aguhh18 f6e872c0aa feat[BE]: implement customer payment report retrieval with pagination and filtering 2026-01-14 11:46:39 +07:00
MacBook Air M1 8a639f127c adjust api informasi umum filter per kandang 2026-01-14 11:41:47 +07:00
Hafizh A. Y. 2acaa10b60 Merge branch 'fix/air.toml' into 'development'
fix(BE): add .air.toml

See merge request mbugroup/lti-api!176
2026-01-14 04:22:29 +00:00
MacBook Air M1 bd9d41e161 fix(BE): add .air.toml 2026-01-14 11:20:42 +07:00
Hafizh A. Y. 06d8d0b795 Merge branch 'feat/price-product-supplier' into 'development'
feat(BE): price-product-supplier

See merge request mbugroup/lti-api!160
2026-01-14 02:17:42 +00:00
ragilap 1d5e7b6e1a Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/US-281-adjustment_recording 2026-01-14 02:09:57 +07:00
Hafizh A. Y. da190f1b05 Merge branch 'feat/BE/Rekapitulasi-hutang-supplier' into 'development'
[Feat/be] Adjustment Counting debt supplier

See merge request mbugroup/lti-api!173
2026-01-13 17:40:18 +00:00
Hafizh A. Y. c8905eb715 Merge branch 'feat/BE/sapronak/data-produksi' into 'development'
Feat/be/sapronak/data produksi

See merge request mbugroup/lti-api!170
2026-01-13 17:39:33 +00:00
aguhh18 7f1d796b65 fix[BE]: correct total price calculation in delivery and sales order services 2026-01-13 22:50:58 +07:00
aguhh18 6c7ff3f415 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into FEAT/BE/report_customer_payment 2026-01-13 20:59:50 +07:00
ragilap 03fbf7f4b7 production_standard 2026-01-13 20:06:37 +07:00
ragilap 7545e9b37d [FIX/BE-US] add ignore for dockerfile.local 2026-01-13 19:57:47 +07:00
ragilap 69f38bf16a Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/Rekapitulasi-hutang-supplier 2026-01-13 19:55:02 +07:00
ragilap 5730053e04 [FIX/BE-US-390] changes counting debt supplier 2026-01-13 19:54:47 +07:00
MacBook Air M1 b087a703ef resolve conflict to development 2026-01-13 16:47:16 +07:00
Adnan Zahir 00edcb6add Merge branch 'chore/test-container-versioning' into 'development'
chore: test image versioning 2

See merge request mbugroup/lti-api!171
2026-01-13 16:47:12 +07:00
Adnan Zahir de6580d11c chore: test image versioning 2 2026-01-13 16:46:49 +07:00
Hafizh A. Y. dcd6008946 Merge branch 'FEAT/BE/report-penjualan' into 'development'
[FEAT][BE]: add some filter on report penjualan API and fixing some error

See merge request mbugroup/lti-api!167
2026-01-13 09:26:01 +00:00
Hafizh A. Y. 711f58abae Merge branch 'feat/BE/US-390-Dashboard' into 'development'
Feat/be/us 390 dashboard changes calculate kilo units

See merge request mbugroup/lti-api!166
2026-01-13 09:25:49 +00:00
Hafizh A. Y. ffd3c905fe Merge branch 'FEAT/BE/Closing_overhead_perkandang' into 'development'
feat[BE]: enhance GetOverhead functionality with project flock kandang count...

See merge request mbugroup/lti-api!165
2026-01-13 09:25:38 +00:00
Hafizh A. Y. 6e4a8617da Merge branch 'Feat/BE/Closing_Penjualan_perkandang' into 'development'
[FEAT][BE] : create closing penjualan perkandang API

See merge request mbugroup/lti-api!164
2026-01-13 09:25:24 +00:00
Adnan Zahir 8a57d5d675 Merge branch 'chore/test-container-versioning' into 'development'
chore: test image versioning

See merge request mbugroup/lti-api!168
2026-01-13 16:18:45 +07:00
Adnan Zahir 5de81f6315 chore: test image versioning 2026-01-13 16:18:15 +07:00
MacBook Air M1 e50dd096a4 Merge branch 'development' into dev/gio 2026-01-13 16:15:15 +07:00
MacBook Air M1 7551d11888 add filter by kandang id sapronak 2026-01-13 16:14:11 +07:00
Adnan Zahir 7444cfac31 Merge branch 'staging' into 'development'
Staging 13 January 2026

See merge request mbugroup/lti-api!163
2026-01-13 16:10:56 +07:00
aguhh18 1b5b5bc847 feat[BE]: add MarketingType filter to marketing reports and update related validations 2026-01-13 16:10:27 +07:00
ragilap 5d7b613ffc [FIX/BE-US-281] changes calculate fcr egg 2026-01-13 15:39:20 +07:00
ragilap 33e89d65ab [FIX/BE-US-281] changes calculate fcr egg 2026-01-13 15:37:54 +07:00
MacBook Air M1 0f4cc6e379 adjust api closing data produksi 2026-01-13 15:32:43 +07:00
MacBook Air M1 590df26a1f adjust api closing production data 2026-01-13 14:43:37 +07:00
ragilap ce7ce778fd [FIX/BE-US-281] add response validation if weeks not have production standart 2026-01-13 14:39:59 +07:00
ragilap eaa208f733 [FIX/BE-US-281] response recording and add payload record_at only in createOne 2026-01-13 14:11:53 +07:00
aguhh18 b088eebac5 feat[BE]: enhance GetOverhead functionality with project flock kandang count mapping and update related DTOs 2026-01-13 13:36:08 +07:00
aguhh18 3c10866208 feat[BE]: add GetOverheadByProjectFlockKandang endpoint and update related services 2026-01-13 13:20:06 +07:00
kris cfbe431222 Update .gitlab-ci.yml file 2026-01-13 04:43:44 +00:00
aguhh18 f7a392be52 feat[BE]: add GetPenjualanByProjectFlockKandang endpoint and update related services 2026-01-13 11:37:23 +07:00
kris 4c434899aa Update .gitlab-ci.yml file 2026-01-13 04:36:34 +00:00
kris 7fd90f3268 Update .gitlab-ci.yml file 2026-01-13 04:19:00 +00:00
kris d26c2dba3f Update .gitlab-ci.yml file 2026-01-13 04:15:08 +00:00
M1 AIR f8415ea15d Update gitlab 2026-01-13 10:59:51 +07:00
M1 AIR 64fe845128 Update CICD 2026-01-13 10:46:55 +07:00
aguhh18 4bd8319e3b FIX[BE] : fixing typografical error on report marketing 2026-01-13 10:16:28 +07:00
aguhh18 bba2dec8c6 FEAT[BE] :update route 2026-01-13 09:52:25 +07:00
Hafizh A. Y. f7b70d4b14 Merge branch 'feat/BE/Rekapitulasi-hutang-supplier' into 'development'
[FIX/BE] adjustment response

See merge request mbugroup/lti-api!162
2026-01-13 01:55:59 +00:00
Hafizh A. Y. 9f28294dc3 Merge branch 'FIX/BE/fix_chickin_can't_recording_because_replenish_isn't_correct_for_one_flag_product' into 'development'
FIX[BE] ; fixing chikin replenish. and other logic

See merge request mbugroup/lti-api!161
2026-01-13 01:55:42 +00:00
ragilap 6a166ceb86 [FIX/BE-US-390] dashboard statistic hpp global and avg seling price not refrence to filter 2026-01-13 00:15:48 +07:00
aguhh18 f0b4fe916c FEAT[BE] ;: inisiate customer payment report route and related DTOs 2026-01-12 20:00:49 +07:00
ragilap f37bf4d22d Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/Rekapitulasi-hutang-supplier 2026-01-12 16:37:31 +07:00
ragilap ac5edb36e7 [FIX/BE] adjustment response 2026-01-12 16:28:03 +07:00
Hafizh A. Y 8fab5d7d91 feat(BE): price-product-supplier 2026-01-12 14:54:14 +07:00
Hafizh A. Y. 5ddfb2c745 Merge branch 'Feat/BE/Expense_adjust_approval_flow' into 'development'
[Feat][BE}: expense adjust approval flow get rid approval manager change to head area and add business unit vice president approval

See merge request mbugroup/lti-api!159
2026-01-12 06:39:22 +00:00
Hafizh A. Y. 5cfa4d4a59 Merge branch 'fix/daily-checklist' into 'development'
fix route daily checklist

See merge request mbugroup/lti-api!158
2026-01-12 06:38:51 +00:00
aguhh18 80b2cafd2f FIX[BE] ; fixing chikin replenish. and other logic 2026-01-12 13:29:24 +07:00
MacBook Air M1 b47f26d448 adjust max limit location and kandang 2026-01-12 11:30:57 +07:00
M1 AIR 2f22182605 Merge branch 'staging' of https://gitlab.com/mbugroup/lti-api into staging 2026-01-12 11:16:43 +07:00
M1 AIR e2d352721c Merge from development 2026-01-12 11:15:59 +07:00
M1 AIR 068fe4329e Merge remote-tracking branch 'origin/development' into staging 2026-01-12 11:13:24 +07:00
MacBook Air M1 15be8dcbea fix route daily checklist 2026-01-12 11:09:32 +07:00
Hafizh A. Y. 041e8763ac Merge branch 'fix/not-showed-product-supplier' into 'development'
fix(BE): is visible to true in product service

See merge request mbugroup/lti-api!157
2026-01-12 03:39:59 +00:00
Hafizh A. Y. 644e9911e4 Merge branch 'FIX/BE/Case-sensitive' into 'development'
[FIX/BE] adjust case sensitive search To Incase sensitive

See merge request mbugroup/lti-api!156
2026-01-12 03:39:48 +00:00
Hafizh A. Y. bb04cb53d9 Merge branch 'feat/BE/Rekapitulasi-hutang-supplier' into 'development'
feat(BE):Rekapitulasi hutang supplier

See merge request mbugroup/lti-api!155
2026-01-12 03:39:26 +00:00
Hafizh A. Y. 048e607290 Merge branch 'feat/daily-checklist-upload-documents' into 'development'
[FEAT][BE]: add api upload documents daily checklist

See merge request mbugroup/lti-api!154
2026-01-12 03:39:06 +00:00
Hafizh A. Y. 18441eb19f Merge branch 'feat/BE/US-390-Dashboard' into 'development'
[FEAT/BE][US-390 dashboard calculation standart]

See merge request mbugroup/lti-api!152
2026-01-12 03:38:51 +00:00
Hafizh A. Y. 526e14f26e Merge branch 'FIX/BE/Transfer_to_laying' into 'development'
[FIX][BE]: fixing transfer to laying qty doesn't  listed on product warehouse and fixing wrong implementation of fifo stock on laying transfer

See merge request mbugroup/lti-api!151
2026-01-12 03:38:27 +00:00
Hafizh A. Y 539081ce99 fix(BE): is visible to true in product service 2026-01-12 10:37:55 +07:00
MacBook Air M1 d568b87e01 adjust response api summary daily checklist 2026-01-12 10:37:33 +07:00
aguhh18 9515848d8f feat(BE): update approval flow to use head area instead of manager 2026-01-12 10:11:31 +07:00
ragilap c15ff8a211 [FIX/BE] add percent rasio in statistic dashboard 2026-01-12 01:15:31 +07:00
ragilap d1d94357cf [FIX/BE] add clamp maximum value 2026-01-12 00:27:53 +07:00
ragilap 67f5165bfb [FIX/BE] adjust case sensitive search 2026-01-11 23:47:28 +07:00
ragilap 1217f34dcd feat(BE):change standart egg in fcr master data 2026-01-11 22:19:20 +07:00
MacBook Air M1 ae41422776 add api upload documents daily checklist 2026-01-11 22:02:21 +07:00
aguhh18 3978951d8f Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into Feat/BE/Expense_adjust_approval_flow 2026-01-11 21:19:35 +07:00
aguhh18 3422fceec7 feat(BE-ExpenseApproval): add unit vice president approval step and permissions 2026-01-11 20:10:19 +07:00
ragilap 09f1b29359 feat(BE):Rekapitulasi hutang supplier 2026-01-11 19:41:21 +07:00
ragilap 167d18fe87 feat(BE-309): add permission dashboard 2026-01-11 19:26:25 +07:00
ragilap 473f4504ea feat(BE-309): changes COMPARASION TO COMPARISON 2026-01-11 19:09:43 +07:00
ragilap dc7dc0ba47 adjustment meta 2026-01-11 18:54:05 +07:00
ragilap a54129866e feat(BE-390): adjustment calculate dashboard 2026-01-11 18:35:23 +07:00
ragilap d40243be4b Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/US-390-Dashboard 2026-01-11 18:26:40 +07:00
ragilap 525ff650f2 feat(BE-390): calculation dashboard 2026-01-11 15:40:47 +07:00
aguhh18 c1e9b5a975 FIX[BE]: add laying transfer source and target repositories to transfer laying service 2026-01-11 13:30:19 +07:00
aguhh18 272367d8ef FIX[BE]: fixing transfer to laying and implement correct fifo stock 2026-01-11 12:51:37 +07:00
Hafizh A. Y. d3c7d65bf5 Merge branch 'fix/not-showed-product-supplier' into 'development'
[FIX][BE] Permission in payment route

See merge request mbugroup/lti-api!150
2026-01-11 01:44:41 +00:00
Hafizh A. Y. 944fd860a3 Merge branch 'feat/BE/US-74-76-78-278/adjustment_recording_purchase_project_flock' into 'development'
[FIX][BE-74-76-78-278]:adjustment project flock,recording,purchase getall

See merge request mbugroup/lti-api!149
2026-01-11 01:44:25 +00:00
Hafizh A. Y af79db8726 fix(BE): permission in payment route 2026-01-11 08:41:45 +07:00
ragilap b42ca5e6fb feat(BE-74-76-78-278):delete unused code recording 2026-01-10 21:34:19 +07:00
ragilap 3b2c6f16c3 feat(BE-74-76-78-278):adjustment project flock,recording,purchase getall 2026-01-10 21:22:54 +07:00
Hafizh A. Y. 359e982e76 Merge branch 'fix/not-showed-product-supplier' into 'development'
[FIX][BE] Not showed supplier in master data product

See merge request mbugroup/lti-api!148
2026-01-10 11:41:54 +00:00
Hafizh A. Y bc0bf7fe16 fix(BE): not showed supplier in master data product 2026-01-10 18:25:04 +07:00
Hafizh A. Y. 70a7b1b888 Merge branch 'fix/master-data-internal-server-error' into 'development'
[FIX][BE]: code 500 when delete master data foreign to others table

See merge request mbugroup/lti-api!147
2026-01-09 09:44:21 +00:00
Hafizh A. Y 17d55bd2c0 fix(BE): fix code 500 when delete master data foreign to others table 2026-01-09 16:43:20 +07:00
Hafizh A. Y. 9cc86df1ed Merge branch 'fix/seeder-and-finance' into 'development'
[FIX][BE]: Add party account number in payments

See merge request mbugroup/lti-api!146
2026-01-09 09:06:40 +00:00
Hafizh A. Y b7914e8294 fix(BE): add party account number in payments 2026-01-09 16:03:41 +07:00
kris d33119661a Update .gitlab-ci.yml file 2026-01-09 08:37:55 +00:00
Hafizh A. Y 8a57d439dc unfinish: seeder and fix migration 2026-01-09 14:18:28 +07:00
kris 3d76854273 Update .gitlab-ci.yml file 2026-01-09 04:27:45 +00:00
kris b7a3882f20 Update .gitlab-ci.yml file 2026-01-09 04:19:24 +00:00
M1 AIR 29933a5df9 change cicd 2026-01-09 11:17:49 +07:00
M1 AIR f8aee4be7b penyesuaian flow cicid 2026-01-09 10:58:11 +07:00
Hafizh A. Y. 4ee5bf3628 Merge branch 'feat/BE/US-281-uniformity' into 'development'
Feat/be/us 281 uniformity

See merge request mbugroup/lti-api!145
2026-01-09 03:52:26 +00:00
Hafizh A. Y. 0f06dff761 Merge branch 'dev/teguh' into 'development'
FEAT[BE]: add expense to transfer stock, make  document optional on transfer stock,  fixing closing penjualan bad request

See merge request mbugroup/lti-api!144
2026-01-09 03:51:48 +00:00
Hafizh A. Y. 0629c5ccf6 Merge branch 'dev/daily-checklist' into 'development'
adjust validate patch daily checklist

See merge request mbugroup/lti-api!143
2026-01-09 03:44:27 +00:00
ragilap 43eb1df118 feat(BE-281): fixing duplicate 2026-01-09 10:06:22 +07:00
ragilap 338312edd1 feat(BE-281): unique uniformity weeks 2026-01-09 10:04:31 +07:00
ragilap f7522636e2 feat(BE-281): unique uniformity weeks 2026-01-09 09:27:49 +07:00
aguhh18 b11f03dfda feat(BE): fixing wrong perhitungan biaya 2026-01-09 09:15:53 +07:00
aguhh18 76e65704d7 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-08 22:02:59 +07:00
aguhh18 857a3c284b feat(BE): implement movement number generation and refactor transfer creation logic 2026-01-08 22:00:32 +07:00
aguhh18 5606b9c4a3 FIX(BE): fix closing marketing 500 2026-01-08 20:44:56 +07:00
aguhh18 7af78d04dd feat(BE): add file size validation and improve document indexing for transfer creation 2026-01-08 18:52:12 +07:00
aguhh18 2650e919e7 feat(BE): implement expense tracking for stock transfers and enhance related services 2026-01-08 15:14:06 +07:00
Hafizh A. Y. 7b2d3ae025 Merge branch 'dev/daily-checklist' into 'development'
adjust get all phase activity

See merge request mbugroup/lti-api!142
2026-01-08 07:25:06 +00:00
Hafizh A. Y. 64e8de2344 Merge branch 'feat/BE/US-281-uniformity' into 'development'
feat(BE-281): add types uniformity

See merge request mbugroup/lti-api!141
2026-01-08 06:12:41 +00:00
Hafizh A. Y. 2be9ae36c1 Merge branch 'dev/daily-checklist' into 'development'
Adjust limit for get all employee

See merge request mbugroup/lti-api!140
2026-01-08 06:12:06 +00:00
ragilap 6c08fe23ca feat(BE-281): add types uniformity 2026-01-08 12:40:36 +07:00
Hafizh A. Y. 8a64300ddd Merge branch 'dev/daily-checklist' into 'development'
add master data config checklist

See merge request mbugroup/lti-api!139
2026-01-08 02:18:22 +00:00
Hafizh A. Y. 9164550263 Merge branch 'feat/BE/US-281-uniformity' into 'development'
feat(BE-281): fixing recording error, fixing limit upload uniformity and...

See merge request mbugroup/lti-api!138
2026-01-08 02:17:49 +00:00
ragilap a2d2c4269a feat(BE-281): fixing recording error, fixing limit upload uniformity and purchase, add filter and statistic uniformity 2026-01-07 20:26:27 +07:00
Hafizh A. Y. 90f363bfdb Merge branch 'dev/daily-checklist' into 'development'
add module daily checklist

See merge request mbugroup/lti-api!137
2026-01-07 10:55:49 +00:00
Hafizh A. Y. a7a784970d Merge branch 'dev/teguh' into 'development'
FIX[BE]: fix transfer to laying, fix delete biaya, fix chickin, fix nominal expense, and other

See merge request mbugroup/lti-api!136
2026-01-07 07:25:09 +00:00
aguhh18 18b0663dc6 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-07 14:03:08 +07:00
aguhh18 375e057e7c feat(BE): enhance chickin and transfer laying services with product warehouse validation and stockable support 2026-01-07 14:02:39 +07:00
aguhh18 9336289573 feat(BE): add excluded stockables support in FIFO allocation and fetching methods 2026-01-07 13:54:55 +07:00
aguhh18 76d5b6b69a feat(BE): enhance ProjectFlockKandang structure and approval fetching methods 2026-01-07 13:39:54 +07:00
aguhh18 0a84e427c1 FIX[BE]: fixing bug transfer to laying, delet biaya, nominal expesen e, chickin 2026-01-07 09:27:39 +07:00
M1 AIR cad91957b3 Merge development into staging 2026-01-06 18:58:48 +07:00
Hafizh A. Y. fca2d63c6e Merge branch 'dev/gio' into 'development'
fix init population

See merge request mbugroup/lti-api!135
2026-01-06 11:27:13 +00:00
MacBook Air M1 f5a016b74b adjust init population 2026-01-06 17:23:06 +07:00
Hafizh A. Y. 82a7bada05 Merge branch 'dev/gio' into 'development'
feat[BE]: api production result

See merge request mbugroup/lti-api!131
2026-01-06 10:11:25 +00:00
Hafizh A. Y. c6626cb6f5 Merge branch 'development' into 'dev/gio'
# Conflicts:
#   internal/modules/repports/route.go
2026-01-06 10:09:45 +00:00
Hafizh A. Y. ebfa88e721 Merge branch 'dev/daily-checklist' into 'development'
add module daily checklist and master data employee, phase

See merge request mbugroup/lti-api!134
2026-01-06 10:09:12 +00:00
Hafizh A. Y. 705138795c Merge branch 'feat/BE/US-281-adjustment_recording' into 'development'
feat(BE-281): adjustment recording to cascade

See merge request mbugroup/lti-api!133
2026-01-06 10:08:54 +00:00
Hafizh A. Y. 538372a43a Merge branch 'feat/BE/US-281-uniformity' into 'development'
[FIX/BE-281] adjustment sso redirect,adjustment response closing,adjustment uniformity

See merge request mbugroup/lti-api!132
2026-01-06 10:08:24 +00:00
ragilap 7a26ca5fe5 feat(BE-281): adjustment recording to cascade 2026-01-06 17:01:09 +07:00
aguhh18 a08466a28e FIX(BE): update foreign key constraints to use ON DELETE NO ACTION for expense and marketing tables 2026-01-06 12:43:52 +07:00
ragilap 1bdaf63763 feat(BE-281): adjustment sso redirect,adjustment response closing,adjustment uniformity 2026-01-06 12:02:19 +07:00
aguhh18 d8fb427734 feat(BE): add grand total calculation to ExpenseListDTO and update CreateOne method in expense service 2026-01-06 11:12:41 +07:00
aguhh18 c9ebd88e9d Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2026-01-06 10:10:37 +07:00
aguhh18 0c6d42070a feat(BE): add items field to TransferDeliveryDTO in ToTransferDetailDTO function 2026-01-06 09:03:39 +07:00
MacBook Air M1 8725d79f8f Merge branch 'feat/BE/Sprint-8' into dev/gio 2026-01-02 12:25:50 +07:00
MacBook Air M1 39909d1c2e first commit api production-result 2026-01-02 11:24:26 +07:00
aguhh18 556540e97f Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2025-12-31 14:04:25 +07:00
aguhh18 e421307965 feat(BE): add validation for product category based on flock category in CreateOne method 2025-12-31 13:29:46 +07:00
aguhh18 1b5437bc01 FIX[BE]Lock chickins, accumulate pending qty, use qty key 2025-12-31 13:09:13 +07:00
aguhh18 7d6573fabd FIC[BE]Use qty column for warehouse updates 2025-12-31 13:05:54 +07:00
aguhh18 ce083bccdc feat(BE): add project flock ID to product warehouse creation for approval process 2025-12-31 12:59:17 +07:00
aguhh18 dc4729c3b9 Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2025-12-31 11:44:02 +07:00
aguhh18 bec6a93152 FIX[BE]Stop adjusting target product warehouse quantity
Avoid double counting: population entries and ConsumeChickinStocks already update inventory. Pullet/layer for the flock will
be added via other flows (purchase, transfer, etc.)
2025-12-31 11:43:03 +07:00
aguhh18 42853aaac0 fix[BE]Reset chickin pending usage and skip zero entries 2025-12-31 11:34:57 +07:00
aguhh18 610555c3cf Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into dev/teguh 2025-12-31 10:29:32 +07:00
aguhh18 c60c40af03 feat(be): add GetByProjectFlockKandangIDForUpdate method to lock chickin rows and prevent race conditions 2025-12-31 10:27:15 +07:00
Hafizh A. Y. 2d098cb6b1 Merge branch 'feat/BE/US-281-uniformity' into 'feat/BE/Sprint-8'
feat(BE-281): uniformity and create project flock triger... unfinished s3 read

See merge request mbugroup/lti-api!121
2025-12-31 02:20:01 +00:00
kris 30231fabe9 Edit Dockerfile 2025-12-18 06:51:52 +00:00
kris e738a97e4c Delete docker-compose.yaml 2025-12-18 06:50:41 +00:00
kris 81f4a5e33e Delete docker-compose.local.yml 2025-12-18 06:50:22 +00:00
kris 1e9fdd2b0d Update .gitlab-ci.yml file 2025-12-18 06:41:04 +00:00
GitLab Deploy Bot b6a60d5009 remove 2025-12-15 09:25:50 +07:00
298 changed files with 21329 additions and 5783 deletions
Vendored
BIN
View File
Binary file not shown.
+4 -1
View File
@@ -9,11 +9,13 @@ main
bin/ bin/
*.exe *.exe
*.out *.out
.air.toml
Makefile Makefile
docker-compose.local.yml docker-compose.local.yml
docker-compose.yaml docker-compose.yaml
Dockerfile
Dockerfile.local Dockerfile.local
.gitlab-ci.yml
# Go build cache # Go build cache
.gocache/ .gocache/
vendor vendor
@@ -27,3 +29,4 @@ coverage/
.vscode/ .vscode/
.idea/ .idea/
*.swp *.swp
.DS_Store
+29 -84
View File
@@ -1,90 +1,35 @@
stages: workflow:
- deploy rules:
# MR pipeline
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
deploy-dev: # Push pipeline hanya untuk env branch
stage: deploy - if: '$CI_COMMIT_BRANCH == "development"'
image: alpine:3.20 when: always
variables: - if: '$CI_COMMIT_BRANCH == "staging"'
DEPLOY_APP: "LTI-MBUGROUP" when: always
# Opsional: kalau pakai submodule, ini bikin clone submodule pakai SSH juga - if: '$CI_COMMIT_BRANCH == "production"'
GIT_SUBMODULE_STRATEGY: recursive when: always
GIT_DEPTH: "1"
before_script: # Selain itu jangan buat pipeline
- echo "🧰 Installing dependencies..." - when: never
- apk update && apk add --no-cache openssh git curl bash
# Setup SSH di runner include:
- mkdir -p ~/.ssh # khusus MR (notif)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa - local: "ci/merge_request.yml"
- chmod 600 ~/.ssh/id_rsa rules:
- eval "$(ssh-agent -s)" - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- ssh-add ~/.ssh/id_rsa
# Trust host keys (server + gitlab) biar SSH gak nanya interaktif # khusus push ke branch env
- ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts - local: "ci/development.yml"
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts rules:
- if: '$CI_COMMIT_BRANCH == "development"'
script: - local: "ci/staging.yml"
- echo "🚀 Deploying latest code to $SERVER_USER@$SERVER_IP" rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
- > - local: "ci/production.yml"
if ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" " rules:
set -e - if: '$CI_COMMIT_BRANCH == "production"'
cd /home/devops/docker/deployment/development/lti-api
# Pastikan remote origin SSH (antisipasi kalau pernah ke-set HTTPS)
git remote set-url origin git@gitlab.com:mbugroup/lti-api.git
# Pastikan server percaya gitlab.com juga (untuk git fetch via SSH)
mkdir -p ~/.ssh
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
# Fetch/reset pakai SSH
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git fetch origin development
git reset --hard origin/development
docker compose restart dev-api-lti || docker compose up -d dev-api-lti
"; then
STATUS='success';
else
STATUS='failed';
fi;
RUN_URL="${CI_PROJECT_URL}/-/pipelines/${CI_PIPELINE_ID}";
if [ "$STATUS" = "success" ]; then
COLOR=3066993;
TITLE="✅ Deployment API Succeeded";
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` completed successfully.";
else
COLOR=15158332;
TITLE="❌ Deployment API Failed Gaes";
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` failed.";
fi;
echo "{
\"username\": \"CI Bot\",
\"embeds\": [{
\"title\": \"$TITLE\",
\"description\": \"$DESC\",
\"color\": $COLOR,
\"fields\": [
{\"name\": \"Repository\", \"value\": \"${CI_PROJECT_PATH}\", \"inline\": true},
{\"name\": \"Actor\", \"value\": \"${GITLAB_USER_LOGIN}\", \"inline\": true},
{\"name\": \"Commit\", \"value\": \"${CI_COMMIT_SHA}\", \"inline\": false},
{\"name\": \"Pipeline\", \"value\": \"[Open run](${RUN_URL})\", \"inline\": false}
]
}]
}" > payload.json;
echo "📡 Sending notification to Discord...";
curl -sS -H "Content-Type: application/json" \
-d @payload.json "$DISCORD_WEBHOOK_URL";
only:
- development
environment:
name: development
+29 -11
View File
@@ -1,20 +1,38 @@
FROM golang:1.23-alpine # =========================
# Builder stage
# =========================
FROM golang:1.23-alpine AS builder
# Install dependensi dasar RUN apk add --no-cache git ca-certificates tzdata
RUN apk add --no-cache git curl bash build-base WORKDIR /app
# Install Air (pakai repo baru air-verse)
RUN go install github.com/air-verse/air@v1.52.3
WORKDIR /lti-api
# Cache dependencies
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN go mod download
# Copy source code
COPY . . COPY . .
# Build API binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o lti-api ./cmd/api
# Build SEED binary (pastikan cmd/seed ada)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o lti-seed ./cmd/seed
# =========================
# Runtime stage
# =========================
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata curl bash postgresql-client \
&& adduser -D -H -u 10001 appuser
WORKDIR /app
COPY --from=builder /app/lti-api /app/lti-api
COPY --from=builder /app/lti-seed /app/lti-seed
USER appuser
EXPOSE 8081 EXPOSE 8081
CMD ["air", "-c", ".air.toml"] CMD ["/app/lti-api"]
+1 -1
View File
@@ -110,4 +110,4 @@ IT Development PT Mitra Berlian Unggas Group
## 📃 License ## 📃 License
This project is private. All rights reserved. > This project is private. All rights reserved.
+91
View File
@@ -0,0 +1,91 @@
stages:
- deploy
deploy-dev:
stage: deploy
image: alpine:3.20
rules:
- if: '$CI_COMMIT_BRANCH == "development"'
when: on_success
- when: never
variables:
DEPLOY_APP: "LTI-MBUGROUP"
GIT_SUBMODULE_STRATEGY: recursive
GIT_DEPTH: "1"
before_script:
- echo "🧰 Installing dependencies..."
- apk update && apk add --no-cache openssh git curl bash
# Setup SSH di runner
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
# Trust host keys (server + gitlab) biar SSH gak nanya interaktif
- ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
script:
- echo "🚀 Deploying latest code to $SERVER_USER@$SERVER_IP"
- >
if ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "
set -e
cd /home/devops/docker/deployment/development/lti-api
# Pastikan remote origin SSH (antisipasi kalau pernah ke-set HTTPS)
git remote set-url origin git@gitlab.com:mbugroup/lti-api.git
# Pastikan server percaya gitlab.com juga (untuk git fetch via SSH)
mkdir -p ~/.ssh
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
# Fetch/reset pakai SSH
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git fetch origin development
git reset --hard origin/development
docker compose restart dev-api-lti || docker compose up -d dev-api-lti
"; then
STATUS='success';
else
STATUS='failed';
fi;
RUN_URL="${CI_PROJECT_URL}/-/pipelines/${CI_PIPELINE_ID}";
if [ "$STATUS" = "success" ]; then
COLOR=3066993;
TITLE="✅ Deployment API Succeeded";
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` completed successfully.";
else
COLOR=15158332;
TITLE="❌ Deployment API Failed Gaes";
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` failed.";
fi;
echo "{
\"username\": \"CI Bot\",
\"embeds\": [{
\"title\": \"$TITLE\",
\"description\": \"$DESC\",
\"color\": $COLOR,
\"fields\": [
{\"name\": \"Repository\", \"value\": \"${CI_PROJECT_PATH}\", \"inline\": true},
{\"name\": \"Actor\", \"value\": \"${GITLAB_USER_LOGIN}\", \"inline\": true},
{\"name\": \"Commit\", \"value\": \"${CI_COMMIT_SHA}\", \"inline\": false},
{\"name\": \"Pipeline\", \"value\": \"[Open run](${RUN_URL})\", \"inline\": false}
]
}]
}" > payload.json;
echo "📡 Sending notification to Discord...";
curl -sS -H "Content-Type: application/json" \
-d @payload.json "$DISCORD_WEBHOOK_URL";
environment:
name: development
+48
View File
@@ -0,0 +1,48 @@
stages:
- notify
notify_discord_on_mr_request_main_dev:
stage: notify
image: alpine:3.20
rules:
# hanya MR yang target ke main atau development
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "development")'
when: on_success
- when: never
script:
- apk add --no-cache curl jq coreutils
- |
TIME_HUMAN="$(date '+%d/%m/%y, %H.%M')"
TIME_ISO="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
TITLE="${CI_MERGE_REQUEST_TITLE}"
IID="!${CI_MERGE_REQUEST_IID}"
USER_LINE="${GITLAB_USER_NAME} (${GITLAB_USER_LOGIN})"
PROJECT_PATH="${CI_PROJECT_PATH}"
USERNAME="${GITLAB_USER_LOGIN}"
MR_URL="${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}"
DESC="$(printf "**%s**\n\n%s opened merge request %s %s\n%s" \
"$USERNAME" "$USER_LINE" "$IID" "$TITLE" "$TIME_HUMAN")"
payload=$(jq -n \
--arg desc "$DESC" \
--arg project "$PROJECT_PATH" \
--arg timeiso "$TIME_ISO" \
--arg mrurl "$MR_URL" \
'{
"username": "Mock-api - Merge Requests",
"embeds": [
{
"description": ($desc + "\n" + $mrurl),
"color": 15105570,
"footer": { "text": $project },
"timestamp": $timeiso
}
]
}')
curl -sS -H "Content-Type: application/json" \
-d "$payload" \
"$DISCORD_WEBHOOK_URL"
+155
View File
@@ -0,0 +1,155 @@
stages:
- build
- migrate
- deploy
- seed
default:
tags:
- self-hosted-prod
variables:
DOCKER_BUILDKIT: "1"
IMAGE_TAG: "production_${CI_COMMIT_SHORT_SHA}"
IMAGE_NAME: "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
IMAGE_LATEST: "${CI_REGISTRY_IMAGE}:production_latest"
DEPLOY_DIR: "/opt/deploy/lti"
COMPOSE_FILE: "docker-compose.yaml"
# =========================
# BUILD (AUTO)
# =========================
build_production:
stage: build
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: on_success
- when: never
script: |
set -e
docker info
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
echo "✅ Build image: $IMAGE_NAME"
docker build -t "$IMAGE_NAME" -f Dockerfile .
echo "✅ Push image: $IMAGE_NAME"
docker push "$IMAGE_NAME"
echo "✅ Tag latest: $IMAGE_LATEST"
docker tag "$IMAGE_NAME" "$IMAGE_LATEST"
docker push "$IMAGE_LATEST"
# =========================
# MIGRATE (PRODUCTION)
# =========================
migrate_production:
stage: migrate
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: on_success
- when: never
needs:
- job: build_production
artifacts: false
script: |
set -e
echo "✅ Running migrations (production) ..."
cd "$DEPLOY_DIR"
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
test -f .env || (echo "❌ .env not found in $DEPLOY_DIR" && exit 1)
set -a
. ./.env
set +a
test -n "$DB_HOST" || (echo "❌ DB_HOST empty" && exit 1)
test -n "$DB_PORT" || (echo "❌ DB_PORT empty" && exit 1)
test -n "$DB_USER" || (echo "❌ DB_USER empty" && exit 1)
test -n "$DB_PASSWORD" || (echo "❌ DB_PASSWORD empty" && exit 1)
test -n "$DB_NAME" || (echo "❌ DB_NAME empty" && exit 1)
export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSLMODE:-disable}"
echo "✅ DATABASE_URL=$DATABASE_URL"
# NOTE: pastikan nama servicenya benar untuk production (ini sebelumnya masih stg-*)
docker compose -f "$COMPOSE_FILE" up -d stg-postgres-lti stg-redis-lti || true
COMPOSE_NETWORK_KEY="$(docker compose -f "$COMPOSE_FILE" config | awk '/networks:/ {getline; print $1}' | tr -d ':')"
NETWORK_NAME="$(docker network ls --format '{{.Name}}' | grep "_${COMPOSE_NETWORK_KEY}$" | head -n 1)"
test -n "$NETWORK_NAME" || (echo "❌ Cannot find docker network for compose ($COMPOSE_NETWORK_KEY)" && exit 1)
echo "✅ Checking migrations from repo..."
ls -lah "$CI_PROJECT_DIR/internal/database/migrations"
echo "✅ Running migrations via migrate/migrate container"
set +e
out=$(docker run --rm \
--network "$NETWORK_NAME" \
-v "$CI_PROJECT_DIR/internal/database/migrations:/migrations:ro" \
migrate/migrate:v4.15.2 \
-path=/migrations -database "$DATABASE_URL" up 2>&1)
code=$?
set -e
echo "$out"
if echo "$out" | grep -qi "no change"; then
echo "✅ No change (already up to date)"
exit 0
fi
if [ $code -ne 0 ]; then
echo "❌ Migration failed with exit code $code"
exit $code
fi
echo "✅ Migration applied successfully"
# =========================
# DEPLOY (AUTO)
# =========================
deploy_production:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: on_success
- when: never
needs:
- job: build_production
artifacts: false
script: |
set -e
docker info
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
cd "$DEPLOY_DIR"
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
test -f .env || (echo "❌ .env not found in $DEPLOY_DIR" && exit 1)
docker compose -f "$COMPOSE_FILE" pull
docker compose -f "$COMPOSE_FILE" up -d --force-recreate
docker image prune -f
# =========================
# SEED (MANUAL)
# =========================
seed_production:
stage: seed
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: manual
- when: never
script: |
set -e
cd "$DEPLOY_DIR"
test -f .env || (echo "❌ .env not found" && exit 1)
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
docker compose --env-file .env pull seed
docker compose --env-file .env run --rm seed
+164
View File
@@ -0,0 +1,164 @@
stages:
- build
- migrate
- deploy
- seed
default:
tags:
- self-hosted-stg
variables:
DOCKER_BUILDKIT: "1"
IMAGE_TAG: "staging_${CI_COMMIT_SHORT_SHA}"
IMAGE_NAME: "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
IMAGE_LATEST: "${CI_REGISTRY_IMAGE}:staging_latest"
DEPLOY_DIR: "/opt/deploy/stg-lti-api"
COMPOSE_FILE: "docker-compose.yaml"
# =========================
# BUILD (AUTO)
# =========================
build_staging:
stage: build
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
when: on_success
- when: never
script: |
set -e
docker info
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
echo "✅ Build image: $IMAGE_NAME"
docker build -t "$IMAGE_NAME" -f Dockerfile .
echo "✅ Push image: $IMAGE_NAME"
docker push "$IMAGE_NAME"
echo "✅ Tag latest: $IMAGE_LATEST"
docker tag "$IMAGE_NAME" "$IMAGE_LATEST"
docker push "$IMAGE_LATEST"
# =========================
# MIGRATE (AUTO)
# =========================
migrate_staging:
stage: migrate
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
when: on_success
- when: never
needs:
- job: build_staging
artifacts: false
script: |
set -e
echo "✅ Running migrations (staging) ..."
cd "$DEPLOY_DIR"
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
test -f .env || (echo "❌ .env not found in $DEPLOY_DIR" && exit 1)
set -a
. ./.env
set +a
test -n "$DB_HOST" || (echo "❌ DB_HOST empty" && exit 1)
test -n "$DB_PORT" || (echo "❌ DB_PORT empty" && exit 1)
test -n "$DB_USER" || (echo "❌ DB_USER empty" && exit 1)
test -n "$DB_PASSWORD" || (echo "❌ DB_PASSWORD empty" && exit 1)
test -n "$DB_NAME" || (echo "❌ DB_NAME empty" && exit 1)
export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSLMODE:-disable}"
echo "✅ DATABASE_URL=$DATABASE_URL"
echo "✅ Ensuring postgres & redis running ..."
docker compose -f "$COMPOSE_FILE" up -d stg-postgres-lti stg-redis-lti || true
COMPOSE_NETWORK_KEY="$(docker compose -f "$COMPOSE_FILE" config | awk '/networks:/ {getline; print $1}' | tr -d ':')"
echo "✅ Compose network key: $COMPOSE_NETWORK_KEY"
NETWORK_NAME="$(docker network ls --format '{{.Name}}' | grep "_${COMPOSE_NETWORK_KEY}$" | head -n 1)"
test -n "$NETWORK_NAME" || (echo "❌ Cannot find docker network for compose ($COMPOSE_NETWORK_KEY)" && exit 1)
echo "✅ Docker network detected: $NETWORK_NAME"
echo "✅ Checking migrations from repo..."
ls -lah "$CI_PROJECT_DIR/internal/database/migrations"
echo "✅ Running migrations via migrate/migrate container"
set +e
out=$(docker run --rm \
--network "$NETWORK_NAME" \
-v "$CI_PROJECT_DIR/internal/database/migrations:/migrations:ro" \
migrate/migrate:v4.15.2 \
-path=/migrations -database "$DATABASE_URL" up 2>&1)
code=$?
set -e
echo "$out"
if echo "$out" | grep -qi "no change"; then
echo "✅ No change (already up to date)"
exit 0
fi
if [ $code -ne 0 ]; then
echo "❌ Migration failed with exit code $code"
exit $code
fi
echo "✅ Migration applied successfully"
# =========================
# DEPLOY (AUTO)
# =========================
deploy_staging:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
when: on_success
- when: never
needs:
- job: migrate_staging
artifacts: false
- job: build_staging
artifacts: false
script: |
set -e
docker info
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
cd "$DEPLOY_DIR"
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
test -f .env || (echo "❌ .env not found in $DEPLOY_DIR" && exit 1)
docker compose -f "$COMPOSE_FILE" pull
docker compose -f "$COMPOSE_FILE" up -d --force-recreate
docker image prune -f
# =========================
# SEED (MANUAL)
# =========================
seed_staging:
stage: seed
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
when: manual
- when: never
needs:
- job: deploy_staging
artifacts: false
allow_failure: false
script: |
set -e
cd "$DEPLOY_DIR"
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found" && exit 1)
test -f .env || (echo "❌ .env not found" && exit 1)
docker compose -f "$COMPOSE_FILE" pull seed || true
docker compose -f "$COMPOSE_FILE" run --rm seed
+1 -1
View File
@@ -14,8 +14,8 @@ import (
"gitlab.com/mbugroup/lti-api.git/internal/database" "gitlab.com/mbugroup/lti-api.git/internal/database"
"gitlab.com/mbugroup/lti-api.git/internal/middleware" "gitlab.com/mbugroup/lti-api.git/internal/middleware"
"gitlab.com/mbugroup/lti-api.git/internal/modules/sso/session" "gitlab.com/mbugroup/lti-api.git/internal/modules/sso/session"
sso "gitlab.com/mbugroup/lti-api.git/internal/modules/sso/verifier"
"gitlab.com/mbugroup/lti-api.git/internal/route" "gitlab.com/mbugroup/lti-api.git/internal/route"
"gitlab.com/mbugroup/lti-api.git/internal/sso"
"gitlab.com/mbugroup/lti-api.git/internal/utils" "gitlab.com/mbugroup/lti-api.git/internal/utils"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
-77
View File
@@ -1,77 +0,0 @@
services:
postgresdb:
image: postgres:alpine
restart: always
ports:
- "${DB_PORT_HOST:-5542}:5432"
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-db_lti_erp}
volumes:
- dbdata:/var/lib/postgresql/data
- ./internal/database/init:/docker-entrypoint-initdb.d
networks: [go-network]
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-db_lti_erp}",
]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
restart: unless-stopped
ports:
- "${REDIS_PORT_HOST:-6381}:6379"
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 5s
timeout: 3s
retries: 10
networks: [go-network]
app:
build:
context: .
dockerfile: Dockerfile.local
image: cosmtrek/air:v1.52.3
working_dir: /lti-api
volumes:
- .:/lti-api
- ./internal/config/jwtRS256.key:/run/keys/jwtRS256.key
- ./internal/config/jwtRS256.key.pub:/run/keys/jwtRS256.key.pub
command: air -c .air.toml
env_file:
- .env
environment:
DB_HOST: postgresdb
DB_PORT: 5432
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
DB_NAME: ${DB_NAME:-db_lti_erp}
REDIS_URL: ${REDIS_URL:-redis://redis:6379/0}
ports:
- "${APP_PORT:-8081}:8081"
depends_on:
postgresdb:
condition: service_healthy
networks: [go-network]
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8081/healthz || exit 1"]
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
volumes:
dbdata:
go-mod-cache:
go-build-cache:
networks:
go-network:
name: lti-api_go-network
driver: bridge
-98
View File
@@ -1,98 +0,0 @@
services:
dev-api-lti:
build:
context: .
dockerfile: Dockerfile
container_name: dev-api-lti
working_dir: /lti-api
command: ["/bin/sh", "scripts/entrypoint.sh"]
ports:
- "8081:8081"
env_file:
- .env
environment:
# override agar koneksi ke container internal
DB_HOST: dev-postgres-lti
DB_PORT: 5432
REDIS_URL: redis://dev-redis-lti:6379/0
volumes:
- .:/lti-api
- ./.air.toml:/lti-api/.air.toml:ro
- ./internal/config/jwtRS256.key:/run/keys/jwtRS256.key
- ./internal/config/jwtRS256.key.pub:/run/keys/jwtRS256.key.pub
depends_on:
- dev-postgres-lti
- dev-redis-lti
networks:
- lti-network
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8081/healthz || exit 1"]
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
deploy:
resources:
limits:
cpus: "2.0"
memory: 2G
reservations:
cpus: "1.0"
memory: 512M
dev-postgres-lti:
image: postgres:15-alpine
container_name: dev-postgres-lti
restart: always
env_file:
- credential/.env.db
ports:
- "5433:5432"
volumes:
- dev-postgres-lti-data:/var/lib/postgresql/data
- ./credential:/docker-entrypoint-initdb.d:ro
networks:
- lti-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-db_lti_erp}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
deploy:
resources:
limits:
cpus: "1.0"
memory: 2G
reservations:
cpus: "0.5"
memory: 512M
dev-redis-lti:
image: redis:7-alpine
container_name: dev-redis-lti
restart: always
ports:
- "6380:6379"
networks:
- lti-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 10
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.2"
memory: 256M
networks:
lti-network:
driver: bridge
volumes:
dev-postgres-lti-data:
+1 -1
View File
@@ -16,6 +16,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/jackc/pgconn v1.14.1 github.com/jackc/pgconn v1.14.1
github.com/jackc/pgx/v5 v5.5.5
github.com/redis/go-redis/v9 v9.14.0 github.com/redis/go-redis/v9 v9.14.0
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.19.0 github.com/spf13/viper v1.19.0
@@ -60,7 +61,6 @@ require (
github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
-4
View File
@@ -262,14 +262,10 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY= github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY=
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8=
github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.9.0 h1:1tgOaEq92IOEumR1/JfYS/eR0KHOCsRv/rYXXh6YJQE= github.com/xuri/excelize/v2 v2.9.0 h1:1tgOaEq92IOEumR1/JfYS/eR0KHOCsRv/rYXXh6YJQE=
github.com/xuri/excelize/v2 v2.9.0/go.mod h1:uqey4QBZ9gdMeWApPLdhm9x+9o2lq4iVmjiLfBS5hdE= github.com/xuri/excelize/v2 v2.9.0/go.mod h1:uqey4QBZ9gdMeWApPLdhm9x+9o2lq4iVmjiLfBS5hdE=
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A= github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A=
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 h1:+C0TIdyyYmzadGaL/HBLbf3WdLgC29pgyhTjAT/0nuE=
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@@ -0,0 +1,309 @@
package repository
import (
"context"
"time"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
"gitlab.com/mbugroup/lti-api.git/internal/utils"
"gitlab.com/mbugroup/lti-api.git/internal/utils/fifo"
"gorm.io/gorm"
)
type HppCostRepository interface {
GetProjectFlockKandangIDs(ctx context.Context, projectFlockId uint) ([]uint, error)
GetDocCost(ctx context.Context, projectFlockKandangIDs []uint) (float64, error)
GetBudgetCostByProjectFlockId(ctx context.Context, projectFlockId uint) (float64, error)
GetExpedisionCost(ctx context.Context, projectFlockKandangIDs []uint) (float64, error)
GetFeedUsageCost(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, error)
GetOvkUsageCost(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, error)
GetTotalPopulation(ctx context.Context, projectFlockKandangIDs []uint) (float64, error)
GetPulletCost(ctx context.Context, projectFlockKandangId uint) (float64, error)
GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, float64, error)
GetEggTerjualPiecesAndWeightKgByProjectFlockKandangIds(ctx context.Context, projectFlockKandangIDs []uint, startDate *time.Time, endDate *time.Time) (float64, float64, error)
GetProjectFlockIDByProjectFlockKandangID(ctx context.Context, projectFlockKandangId uint) (uint, error)
GetTransferSourceSummary(ctx context.Context, projectFlockKandangId uint) (uint, float64, error)
}
type HppRepositoryImpl struct {
db *gorm.DB
}
func NewHppCostRepository(db *gorm.DB) HppCostRepository {
return &HppRepositoryImpl{db: db}
}
func (r *HppRepositoryImpl) GetProjectFlockKandangIDs(ctx context.Context, projectFlockId uint) ([]uint, error) {
var ids []uint
err := r.db.WithContext(ctx).
Table("project_flock_kandangs").
Select("id").
Where("project_flock_id = ?", projectFlockId).
Scan(&ids).Error
if err != nil {
return nil, err
}
return ids, nil
}
func (r *HppRepositoryImpl) GetDocCost(ctx context.Context, projectFlockKandangIDs []uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("project_chickins AS pc").
Select("COALESCE(SUM(pc.usage_qty * COALESCE(pi.price, 0)), 0)").
Joins("JOIN stock_allocations AS sa ON sa.usable_type = ? AND sa.usable_id = pc.id AND sa.stockable_type = ?", fifo.UsableKeyProjectChickin.String(), fifo.StockableKeyPurchaseItems.String()).
Joins("JOIN purchase_items AS pi ON pi.id = sa.stockable_id").
Where("pc.project_flock_kandang_id IN (?)", projectFlockKandangIDs).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetBudgetCostByProjectFlockId(ctx context.Context, projectFlockId uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("project_budgets AS pb").
Select("COALESCE(SUM(pb.qty * pb.price), 0)").
Where("pb.project_flock_id = ?", projectFlockId).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetExpedisionCost(ctx context.Context, projectFlockKandangIDs []uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("expense_nonstocks AS en").
Select("COALESCE(SUM(er.qty * er.price), 0)").
Joins("JOIN expense_realizations AS er ON er.expense_nonstock_id = en.id").
Joins("JOIN flags AS f ON f.flagable_id = en.nonstock_id AND f.flagable_type = ?", entity.FlagableTypeNonstock).
Where("en.project_flock_kandang_id IN (?)", projectFlockKandangIDs).
Where("f.name = ?", utils.FlagEkspedisi).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetFeedUsageCost(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, error) {
if date == nil {
now := time.Now()
date = &now
}
var total float64
err := r.db.WithContext(ctx).
Table("recordings AS r").
Select("COALESCE(SUM(rs.usage_qty * COALESCE(pi.price, 0)), 0)").
Joins("JOIN recording_stocks AS rs ON rs.recording_id = r.id").
Joins("JOIN product_warehouses AS pw ON pw.id = rs.product_warehouse_id").
Joins("JOIN flags AS f ON f.flagable_id = pw.product_id AND f.flagable_type = ?", entity.FlagableTypeProduct).
Joins("JOIN stock_allocations AS sa ON sa.usable_type = ? AND sa.usable_id = rs.id AND sa.stockable_type = ?", fifo.UsableKeyRecordingStock.String(), fifo.StockableKeyPurchaseItems.String()).
Joins("JOIN purchase_items AS pi ON pi.id = sa.stockable_id").
Where("r.project_flock_kandangs_id IN (?)", projectFlockKandangIDs).
Where("r.record_datetime <= ?", *date).
Where("f.name = ?", utils.FlagPakan).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetOvkUsageCost(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, error) {
if date == nil {
now := time.Now()
date = &now
}
flags := []utils.FlagType{
utils.FlagOVK,
utils.FlagObat,
utils.FlagVitamin,
utils.FlagKimia,
}
var total float64
err := r.db.WithContext(ctx).
Table("recordings AS r").
Select("COALESCE(SUM(rs.usage_qty * COALESCE(pi.price, 0)), 0)").
Joins("JOIN recording_stocks AS rs ON rs.recording_id = r.id").
Joins("JOIN product_warehouses AS pw ON pw.id = rs.product_warehouse_id").
Joins("JOIN flags AS f ON f.flagable_id = pw.product_id AND f.flagable_type = ?", entity.FlagableTypeProduct).
Joins("JOIN stock_allocations AS sa ON sa.usable_type = ? AND sa.usable_id = rs.id AND sa.stockable_type = ?", fifo.UsableKeyRecordingStock.String(), fifo.StockableKeyPurchaseItems.String()).
Joins("JOIN purchase_items AS pi ON pi.id = sa.stockable_id").
Where("r.project_flock_kandangs_id IN (?)", projectFlockKandangIDs).
Where("r.record_datetime <= ?", *date).
Where("f.name IN ?", flags).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetTotalPopulation(ctx context.Context, projectFlockKandangIDs []uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("project_chickins AS pc").
Select("COALESCE(SUM(pc.usage_qty), 0)").
Where("pc.project_flock_kandang_id IN (?)", projectFlockKandangIDs).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetPulletCost(ctx context.Context, projectFlockKandangId uint) (float64, error) {
stockablePurchase := fifo.StockableKeyPurchaseItems.String()
stockableTransferIn := fifo.StockableKeyStockTransferIn.String()
usableProjectChickin := fifo.UsableKeyProjectChickin.String()
var total float64
err := r.db.WithContext(ctx).
Table("project_chickins AS pc").
Select(`
COALESCE(SUM(pc.usage_qty * CASE
WHEN sa.stockable_type = ? THEN COALESCE(pi.price, 0)
WHEN sa.stockable_type = ? THEN COALESCE(tpi.price, 0)
ELSE 0
END), 0)`,
stockablePurchase, stockableTransferIn).
Joins("JOIN stock_allocations AS sa ON sa.usable_type = ? AND sa.usable_id = pc.id", usableProjectChickin).
Joins("LEFT JOIN purchase_items AS pi ON pi.id = sa.stockable_id AND sa.stockable_type = ?", stockablePurchase).
Joins("LEFT JOIN stock_allocations AS tsa ON tsa.usable_type = ? AND tsa.usable_id = sa.stockable_id AND sa.stockable_type = ? AND tsa.stockable_type = ?", stockableTransferIn, stockableTransferIn, stockablePurchase).
Joins("LEFT JOIN purchase_items AS tpi ON tpi.id = tsa.stockable_id").
Where("pc.project_flock_kandang_id = ?", projectFlockKandangId).
Scan(&total).Error
if err != nil {
return 0, err
}
return total, nil
}
func (r *HppRepositoryImpl) GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds(ctx context.Context, projectFlockKandangIDs []uint, date *time.Time) (float64, float64, error) {
if date == nil {
now := time.Now()
date = &now
}
var totals struct {
TotalPieces float64
TotalWeightKg float64
}
err := r.db.WithContext(ctx).
Table("recordings AS r").
Select("COALESCE(SUM(re.qty), 0) AS total_pieces, COALESCE(SUM(re.weight), 0)AS total_weight_kg").
Joins("JOIN recording_eggs AS re ON re.recording_id = r.id").
Where("r.project_flock_kandangs_id IN (?)", projectFlockKandangIDs).
Where("r.record_datetime <= ?", *date).
Scan(&totals).Error
if err != nil {
return 0, 0, err
}
return totals.TotalPieces, totals.TotalWeightKg, nil
}
func (r *HppRepositoryImpl) GetEggTerjualPiecesAndWeightKgByProjectFlockKandangIds(
ctx context.Context,
projectFlockKandangIDs []uint,
startDate *time.Time,
endDate *time.Time,
) (float64, float64, error) {
if endDate == nil {
now := time.Now()
endDate = &now
}
type subResult struct {
UsableID uint
MdpUsageQty float64
MdpWeight float64
}
subQuery := r.db.WithContext(ctx).
Table("recordings AS r").
Select(`
DISTINCT sa.usable_id,
mdp.usage_qty AS mdp_usage_qty,
mdp.total_weight AS mdp_weight
`).
Joins("JOIN recording_eggs re ON re.recording_id = r.id").
Joins(
"JOIN stock_allocations sa ON sa.stockable_type = ? AND sa.stockable_id = re.id AND sa.usable_type = ?",
fifo.StockableKeyRecordingEgg.String(),
fifo.UsableKeyMarketingDelivery.String(),
).
Joins("JOIN marketing_delivery_products mdp ON mdp.id = sa.usable_id").
Where("r.project_flock_kandangs_id IN (?)", projectFlockKandangIDs).
Where("r.record_datetime <= ?", *endDate).
Where("mdp.delivery_date <= ?", *startDate)
var totals struct {
TotalPieces float64
TotalWeight float64
}
err := r.db.WithContext(ctx).
Table("(?) AS x", subQuery).
Select(`
COALESCE(SUM(x.mdp_usage_qty), 0) AS total_pieces,
COALESCE(SUM(x.mdp_weight), 0) AS total_weight
`).
Scan(&totals).Error
if err != nil {
return 0, 0, err
}
return totals.TotalPieces, totals.TotalWeight, nil
}
func (r *HppRepositoryImpl) GetProjectFlockIDByProjectFlockKandangID(ctx context.Context, projectFlockKandangId uint) (uint, error) {
var projectFlockID uint
err := r.db.WithContext(ctx).
Table("project_flock_kandangs").
Select("project_flock_id").
Where("id = ?", projectFlockKandangId).
Scan(&projectFlockID).Error
if err != nil {
return 0, err
}
return projectFlockID, nil
}
func (r *HppRepositoryImpl) GetTransferSourceSummary(ctx context.Context, projectFlockKandangId uint) (uint, float64, error) {
var summary struct {
ProjectFlockID uint
TotalQty float64
}
err := r.db.WithContext(ctx).
Table("laying_transfer_targets AS ltt").
Select("lt.from_project_flock_id AS project_flock_id, COALESCE(SUM(ltt.total_qty), 0) AS total_qty").
Joins("JOIN laying_transfers AS lt ON lt.id = ltt.laying_transfer_id").
Where("ltt.target_project_flock_kandang_id = ?", projectFlockKandangId).
Group("lt.from_project_flock_id").
Scan(&summary).Error
if err != nil {
return 0, 0, err
}
return summary.ProjectFlockID, summary.TotalQty, nil
}
@@ -15,7 +15,7 @@ type ApprovalService interface {
WorkflowSteps(workflow approvalutils.ApprovalWorkflowKey) map[approvalutils.ApprovalStep]string WorkflowSteps(workflow approvalutils.ApprovalWorkflowKey) map[approvalutils.ApprovalStep]string
WorkflowStepName(workflow approvalutils.ApprovalWorkflowKey, step approvalutils.ApprovalStep) (string, bool) WorkflowStepName(workflow approvalutils.ApprovalWorkflowKey, step approvalutils.ApprovalStep) (string, bool)
CreateApproval(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, step approvalutils.ApprovalStep, action *entity.ApprovalAction, actorID uint, note *string) (*entity.Approval, error) CreateApproval(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, step approvalutils.ApprovalStep, action *entity.ApprovalAction, actorID uint, note *string) (*entity.Approval, error)
List(ctx context.Context, module string, approvableID *uint, page, limit int, search string) ([]entity.Approval, int64, error) List(ctx context.Context, module string, approvableID *uint, page, limit int, search string, orderByDate string) ([]entity.Approval, int64, error)
ListByTarget(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, modifier func(*gorm.DB) *gorm.DB) ([]entity.Approval, error) ListByTarget(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, modifier func(*gorm.DB) *gorm.DB) ([]entity.Approval, error)
LatestByTarget(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, modifier func(*gorm.DB) *gorm.DB) (*entity.Approval, error) LatestByTarget(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableID uint, modifier func(*gorm.DB) *gorm.DB) (*entity.Approval, error)
LatestByTargets(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableIDs []uint, modifier func(*gorm.DB) *gorm.DB) (map[uint]*entity.Approval, error) LatestByTargets(ctx context.Context, workflow approvalutils.ApprovalWorkflowKey, approvableIDs []uint, modifier func(*gorm.DB) *gorm.DB) (map[uint]*entity.Approval, error)
@@ -70,9 +70,14 @@ func (s *approvalService) List(
approvableID *uint, approvableID *uint,
page, limit int, page, limit int,
search string, search string,
orderByDate string,
) ([]entity.Approval, int64, error) { ) ([]entity.Approval, int64, error) {
module = strings.TrimSpace(strings.ToUpper(module)) module = strings.TrimSpace(strings.ToUpper(module))
search = strings.TrimSpace(search) search = strings.TrimSpace(search)
orderByDate = strings.TrimSpace(strings.ToUpper(orderByDate))
if orderByDate != "ASC" && orderByDate != "DESC" {
orderByDate = "DESC"
}
if limit <= 0 { if limit <= 0 {
limit = 10 limit = 10
@@ -90,7 +95,7 @@ func (s *approvalService) List(
func(db *gorm.DB) *gorm.DB { func(db *gorm.DB) *gorm.DB {
query := db. query := db.
Where("approvable_type = ?", module). Where("approvable_type = ?", module).
Order("action_at DESC"). Order("action_at " + orderByDate).
Preload("ActionUser") Preload("ActionUser")
if approvableID != nil { if approvableID != nil {
@@ -20,7 +20,7 @@ import (
) )
const ( const (
defaultDocumentPathLimit = 50 defaultDocumentPathLimit = 255
defaultDocumentKeyPrefix = "docs" defaultDocumentKeyPrefix = "docs"
maxDocumentNameLength = 50 maxDocumentNameLength = 50
) )
@@ -363,13 +363,19 @@ func (s *documentService) generateObjectKey(ext string) (string, error) {
} }
u := uuid.New().String() u := uuid.New().String()
key := fmt.Sprintf("%s/%s%s", strings.Trim(s.keyPrefix, "/"), u, normalizedExt) keyPrefix := strings.Trim(s.keyPrefix, "/")
if s.keyPrefix == "" { key := fmt.Sprintf("%s%s", u, normalizedExt)
key = fmt.Sprintf("%s%s", u, normalizedExt) if keyPrefix != "" {
key = fmt.Sprintf("%s/%s%s", keyPrefix, u, normalizedExt)
} }
if len(key) > s.maxPathLength { if len(key) > s.maxPathLength {
key = fmt.Sprintf("%s%s", u, normalizedExt) compact := strings.ReplaceAll(u, "-", "")
if keyPrefix != "" {
key = fmt.Sprintf("%s/%s%s", keyPrefix, compact, normalizedExt)
} else {
key = fmt.Sprintf("%s%s", compact, normalizedExt)
}
} }
if len(key) > s.maxPathLength { if len(key) > s.maxPathLength {
+163 -24
View File
@@ -25,6 +25,8 @@ type FifoService interface {
Replenish(ctx context.Context, req StockReplenishRequest) (*StockReplenishResult, error) Replenish(ctx context.Context, req StockReplenishRequest) (*StockReplenishResult, error)
Consume(ctx context.Context, req StockConsumeRequest) (*StockConsumeResult, error) Consume(ctx context.Context, req StockConsumeRequest) (*StockConsumeResult, error)
ReleaseUsage(ctx context.Context, req StockReleaseRequest) error ReleaseUsage(ctx context.Context, req StockReleaseRequest) error
AdjustStockableQuantity(ctx context.Context, req StockAdjustRequest) error
ResolvePending(ctx context.Context, req PendingResolveRequest) ([]PendingResolution, error)
} }
type fifoService struct { type fifoService struct {
@@ -95,12 +97,26 @@ type StockReplenishRequest struct {
Tx *gorm.DB Tx *gorm.DB
} }
type StockAdjustRequest struct {
StockableKey fifo.StockableKey
StockableID uint
ProductWarehouseID uint
Quantity float64
Note *string
Tx *gorm.DB
}
type PendingResolution struct { type PendingResolution struct {
UsableKey fifo.UsableKey UsableKey fifo.UsableKey
UsableID uint UsableID uint
Quantity float64 Quantity float64
} }
type PendingResolveRequest struct {
ProductWarehouseID uint
Tx *gorm.DB
}
type StockReplenishResult struct { type StockReplenishResult struct {
AddedQuantity float64 AddedQuantity float64
PendingResolved []PendingResolution PendingResolved []PendingResolution
@@ -138,6 +154,38 @@ type StockReleaseRequest struct {
Tx *gorm.DB Tx *gorm.DB
} }
func (s *fifoService) AdjustStockableQuantity(ctx context.Context, req StockAdjustRequest) error {
if req.StockableID == 0 || strings.TrimSpace(req.StockableKey.String()) == "" {
return errors.New("stockable key and id are required")
}
if req.ProductWarehouseID == 0 {
return errors.New("product warehouse id is required")
}
if req.Quantity == 0 {
return nil
}
if req.Quantity > 0 {
return errors.New("quantity must be negative")
}
cfg, ok := fifo.Stockable(req.StockableKey)
if !ok {
return fmt.Errorf("stockable %q is not registered", req.StockableKey)
}
return s.withTransaction(ctx, req.Tx, func(tx *gorm.DB) error {
if err := s.incrementStockableQty(ctx, tx, cfg, req.StockableID, req.Quantity); err != nil {
return err
}
return s.productWarehouseRepo.AdjustQuantities(ctx, map[uint]float64{
req.ProductWarehouseID: req.Quantity,
}, func(db *gorm.DB) *gorm.DB {
return s.txOrDB(tx, db)
})
})
}
func (s *fifoService) Replenish(ctx context.Context, req StockReplenishRequest) (*StockReplenishResult, error) { func (s *fifoService) Replenish(ctx context.Context, req StockReplenishRequest) (*StockReplenishResult, error) {
if req.StockableID == 0 || strings.TrimSpace(req.StockableKey.String()) == "" { if req.StockableID == 0 || strings.TrimSpace(req.StockableKey.String()) == "" {
return nil, errors.New("stockable key and id are required") return nil, errors.New("stockable key and id are required")
@@ -185,6 +233,23 @@ func (s *fifoService) Replenish(ctx context.Context, req StockReplenishRequest)
return result, nil return result, nil
} }
func (s *fifoService) ResolvePending(ctx context.Context, req PendingResolveRequest) ([]PendingResolution, error) {
if req.ProductWarehouseID == 0 {
return nil, errors.New("product warehouse id is required")
}
var resolved []PendingResolution
err := s.withTransaction(ctx, req.Tx, func(tx *gorm.DB) error {
var err error
resolved, err = s.resolvePendingForWarehouse(ctx, tx, req.ProductWarehouseID)
return err
})
if err != nil {
return nil, err
}
return resolved, nil
}
func (s *fifoService) Consume(ctx context.Context, req StockConsumeRequest) (*StockConsumeResult, error) { func (s *fifoService) Consume(ctx context.Context, req StockConsumeRequest) (*StockConsumeResult, error) {
if req.UsableID == 0 || strings.TrimSpace(req.UsableKey.String()) == "" { if req.UsableID == 0 || strings.TrimSpace(req.UsableKey.String()) == "" {
return nil, errors.New("usable key and id are required") return nil, errors.New("usable key and id are required")
@@ -228,7 +293,13 @@ func (s *fifoService) Consume(ctx context.Context, req StockConsumeRequest) (*St
switch { switch {
case delta > 0: case delta > 0:
allocationRes, err := s.allocateFromStock(ctx, tx, productWarehouseID, req.UsableKey, req.UsableID, delta)
var excludedStockables []fifo.StockableKey
if cfg.ExcludedStockables != nil {
excludedStockables = cfg.ExcludedStockables
}
allocationRes, err := s.allocateFromStock(ctx, tx, productWarehouseID, req.UsableKey, req.UsableID, delta, excludedStockables)
if err != nil { if err != nil {
return err return err
} }
@@ -261,7 +332,7 @@ func (s *fifoService) Consume(ctx context.Context, req StockConsumeRequest) (*St
} }
if reductionTarget > 0 { if reductionTarget > 0 {
released, err := s.releaseUsagePortion(ctx, tx, req.UsableKey, req.UsableID, reductionTarget) released, err := s.releaseUsagePortion(ctx, tx, req.UsableKey, req.UsableID, reductionTarget, productWarehouseID)
if err != nil { if err != nil {
return err return err
} }
@@ -308,7 +379,7 @@ func (s *fifoService) ReleaseUsage(ctx context.Context, req StockReleaseRequest)
} }
var usageDelta, pendingDelta float64 var usageDelta, pendingDelta float64
if ctxRow.UsageQty > 0 { if ctxRow.UsageQty > 0 {
if _, err := s.releaseUsagePortion(ctx, tx, req.UsableKey, req.UsableID, ctxRow.UsageQty); err != nil { if _, err := s.releaseUsagePortion(ctx, tx, req.UsableKey, req.UsableID, ctxRow.UsageQty, ctxRow.ProductWarehouseID); err != nil {
return err return err
} }
usageDelta -= ctxRow.UsageQty usageDelta -= ctxRow.UsageQty
@@ -410,8 +481,9 @@ func (s *fifoService) allocateFromStock(
usableKey fifo.UsableKey, usableKey fifo.UsableKey,
usableID uint, usableID uint,
requestQty float64, requestQty float64,
excludedStockables []fifo.StockableKey,
) (*allocationOutcome, error) { ) (*allocationOutcome, error) {
lots, err := s.fetchStockLots(ctx, tx, productWarehouseID) lots, err := s.fetchStockLots(ctx, tx, productWarehouseID, excludedStockables)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -492,14 +564,24 @@ func (s *fifoService) allocateFromStock(
}, nil }, nil
} }
func (s *fifoService) fetchStockLots(ctx context.Context, tx *gorm.DB, productWarehouseID uint) ([]stockLot, error) { func (s *fifoService) fetchStockLots(ctx context.Context, tx *gorm.DB, productWarehouseID uint, excludedStockables []fifo.StockableKey) ([]stockLot, error) {
configs := fifo.Stockables() configs := fifo.Stockables()
if len(configs) == 0 { if len(configs) == 0 {
return nil, nil return nil, nil
} }
// Create exclusion set for faster lookup
excludedSet := make(map[fifo.StockableKey]bool)
for _, key := range excludedStockables {
excludedSet[key] = true
}
var lots []stockLot var lots []stockLot
for key, cfg := range configs { for key, cfg := range configs {
// Skip excluded stockables
if excludedSet[key] {
continue
}
usesNumericTime := cfg.Columns.CreatedAt == cfg.Columns.ID usesNumericTime := cfg.Columns.CreatedAt == cfg.Columns.ID
@@ -616,7 +698,13 @@ func (s *fifoService) resolvePendingForWarehouse(ctx context.Context, tx *gorm.D
continue continue
} }
outcome, err := s.allocateFromStock(ctx, tx, productWarehouseID, candidate.UsableKey, candidate.UsableID, candidate.Pending) // Get excluded stockables from candidate usable config
var excludedStockables []fifo.StockableKey
if candidate.Config.ExcludedStockables != nil {
excludedStockables = candidate.Config.ExcludedStockables
}
outcome, err := s.allocateFromStock(ctx, tx, productWarehouseID, candidate.UsableKey, candidate.UsableID, candidate.Pending, excludedStockables)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -657,6 +745,7 @@ func (s *fifoService) releaseUsagePortion(
usableKey fifo.UsableKey, usableKey fifo.UsableKey,
usableID uint, usableID uint,
target float64, target float64,
expectedWarehouseID uint,
) (float64, error) { ) (float64, error) {
if target <= 0 { if target <= 0 {
return 0, nil return 0, nil
@@ -672,6 +761,18 @@ func (s *fifoService) releaseUsagePortion(
if len(allocations) == 0 { if len(allocations) == 0 {
return 0, nil return 0, nil
} }
for i := range allocations {
alloc := &allocations[i]
if expectedWarehouseID == 0 || alloc.ProductWarehouseId == expectedWarehouseID {
continue
}
if err := tx.Model(&entities.StockAllocation{}).
Where("id = ?", alloc.Id).
Update("product_warehouse_id", expectedWarehouseID).Error; err != nil {
return 0, err
}
alloc.ProductWarehouseId = expectedWarehouseID
}
var ( var (
remaining = target remaining = target
@@ -768,30 +869,30 @@ func (s *fifoService) fetchPendingCandidates(ctx context.Context, tx *gorm.DB, p
cfg.Columns.CreatedAt, cfg.Columns.CreatedAt,
) )
var rows []struct { if cfg.Columns.CreatedAt == cfg.Columns.ID {
ID uint var rows []struct {
Pending float64 ID uint
CreatedAt time.Time Pending float64 `gorm:"column:pending_qty"`
} CreatedAt int64 `gorm:"column:created_at"`
}
query := tx.Table(cfg.Table). query := tx.Table(cfg.Table).
Select(selectStmt). Select(selectStmt).
Where(fmt.Sprintf("%s = ?", cfg.Columns.ProductWarehouseID), productWarehouseID). Where(fmt.Sprintf("%s = ?", cfg.Columns.ProductWarehouseID), productWarehouseID).
Where(fmt.Sprintf("%s > 0", cfg.Columns.PendingQuantity)). Where(fmt.Sprintf("%s > 0", cfg.Columns.PendingQuantity)).
Limit(s.pendingBatchPerUsable) Limit(s.pendingBatchPerUsable)
if cfg.Scope != nil { if cfg.Scope != nil {
query = cfg.Scope(query) query = cfg.Scope(query)
} }
for _, order := range s.orderClauses(cfg.OrderBy) { for _, order := range s.orderClauses(cfg.OrderBy) {
query = query.Order(order) query = query.Order(order)
} }
if err := query.Find(&rows).Error; err != nil { if err := query.Find(&rows).Error; err != nil {
return nil, err return nil, err
} }
for _, row := range rows { for _, row := range rows {
if row.Pending <= 0 { if row.Pending <= 0 {
continue continue
@@ -801,9 +902,47 @@ func (s *fifoService) fetchPendingCandidates(ctx context.Context, tx *gorm.DB, p
Config: cfg, Config: cfg,
UsableID: row.ID, UsableID: row.ID,
Pending: row.Pending, Pending: row.Pending,
CreatedAt: row.CreatedAt, CreatedAt: time.Unix(0, row.CreatedAt),
}) })
} }
} else {
var rows []struct {
ID uint
Pending float64 `gorm:"column:pending_qty"`
CreatedAt time.Time `gorm:"column:created_at"`
}
query := tx.Table(cfg.Table).
Select(selectStmt).
Where(fmt.Sprintf("%s = ?", cfg.Columns.ProductWarehouseID), productWarehouseID).
Where(fmt.Sprintf("%s > 0", cfg.Columns.PendingQuantity)).
Limit(s.pendingBatchPerUsable)
if cfg.Scope != nil {
query = cfg.Scope(query)
}
for _, order := range s.orderClauses(cfg.OrderBy) {
query = query.Order(order)
}
if err := query.Find(&rows).Error; err != nil {
return nil, err
}
for _, row := range rows {
if row.Pending <= 0 {
continue
}
candidates = append(candidates, pendingCandidate{
UsableKey: key,
Config: cfg,
UsableID: row.ID,
Pending: row.Pending,
CreatedAt: row.CreatedAt,
})
}
}
} }
if len(candidates) == 0 { if len(candidates) == 0 {
@@ -0,0 +1,272 @@
package service
import (
"context"
"math"
"time"
commonRepo "gitlab.com/mbugroup/lti-api.git/internal/common/repository"
)
type HppService interface {
CalculateHppCost(projectFlockKandangId uint, date *time.Time) (*HppCostResponse, error)
GetTotalDepresiasiFlockGrowing(sourceProjectFlockID uint, date *time.Time) (float64, error)
GetTotalProductionCost(projectFlockKandangId uint, endDate *time.Time, depresiasiTransfer float64) (float64, error)
GetBudgetKandangLaying(projectFlockKandangId uint, endDate *time.Time) (float64, error)
GetDepresiasiTransfer(projectFlockKandangId uint, date *time.Time) (float64, error)
GetHppEstimationDanRealisasi(totalProductionCost float64, projectFlockKandangId uint, startDate *time.Time, endDate *time.Time) (*HppCostResponse, error)
}
type HppCostResponse struct {
Estimation HppCostDetail `json:"estimation"`
Real HppCostDetail `json:"real"`
}
type HppCostDetail struct {
HargaKg float64 `json:"harga_kg"`
HargaButir float64 `json:"harga_butir"`
Total float64 `json:"total"`
Kg float64 `json:"kg"`
Butir float64 `json:"butir"`
}
type hppService struct {
hppRepo commonRepo.HppCostRepository
}
func NewHppService(hppRepo commonRepo.HppCostRepository) HppService {
return &hppService{hppRepo: hppRepo}
}
func (s *hppService) CalculateHppCost(projectFlockKandangId uint, date *time.Time) (*HppCostResponse, error) {
if date == nil {
now := time.Now()
date = &now
}
location, err := time.LoadLocation("Asia/Jakarta")
if err != nil {
return nil, err
}
startOfDay := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, location)
endOfDay := startOfDay.Add(24 * time.Hour)
depresiasiTransfer, err := s.GetDepresiasiTransfer(projectFlockKandangId, &endOfDay)
if err != nil {
return nil, err
}
totalProductionCost, err := s.GetTotalProductionCost(projectFlockKandangId, &endOfDay, depresiasiTransfer)
if err != nil {
return nil, err
}
return s.GetHppEstimationDanRealisasi(totalProductionCost, projectFlockKandangId, &startOfDay, &endOfDay)
}
func (s *hppService) GetTotalDepresiasiFlockGrowing(sourceProjectFlockID uint, date *time.Time) (float64, error) {
if date == nil {
now := time.Now()
date = &now
}
if s.hppRepo == nil {
return 0, nil
}
kandangIDs, err := s.hppRepo.GetProjectFlockKandangIDs(context.Background(), sourceProjectFlockID)
if err != nil {
return 0, err
}
docCost, err := s.hppRepo.GetDocCost(context.Background(), kandangIDs)
if err != nil {
return 0, err
}
budgetCost, err := s.hppRepo.GetBudgetCostByProjectFlockId(context.Background(), sourceProjectFlockID)
if err != nil {
return 0, err
}
expedisionCost, err := s.hppRepo.GetExpedisionCost(context.Background(), kandangIDs)
if err != nil {
return 0, err
}
feedCost, err := s.hppRepo.GetFeedUsageCost(context.Background(), kandangIDs, date)
if err != nil {
return 0, err
}
ovkCost, err := s.hppRepo.GetOvkUsageCost(context.Background(), kandangIDs, date)
if err != nil {
return 0, err
}
return docCost + budgetCost + expedisionCost + feedCost + ovkCost, nil
}
func (s *hppService) GetTotalProductionCost(projectFlockKandangId uint, endDate *time.Time, depresiasiTransfer float64) (float64, error) {
// if date == nil {
// now := time.Now()
// date = &now
// }
costPullet, err := s.hppRepo.GetPulletCost(context.Background(), projectFlockKandangId)
if err != nil {
return 0, err
}
costFeed, err := s.hppRepo.GetFeedUsageCost(context.Background(), []uint{projectFlockKandangId}, endDate)
if err != nil {
return 0, err
}
costOvk, err := s.hppRepo.GetOvkUsageCost(context.Background(), []uint{projectFlockKandangId}, endDate)
if err != nil {
return 0, err
}
costExpedision, err := s.hppRepo.GetExpedisionCost(context.Background(), []uint{projectFlockKandangId})
if err != nil {
return 0, err
}
costBudget, err := s.GetBudgetKandangLaying(projectFlockKandangId, endDate)
if err != nil {
return 0, err
}
return depresiasiTransfer + costPullet + costFeed + costOvk + costExpedision + costBudget, nil
}
func (s *hppService) GetBudgetKandangLaying(projectFlockKandangId uint, endDate *time.Time) (float64, error) {
// if date == nil {
// now := time.Now()
// date = &now
// }
if s.hppRepo == nil {
return 0, nil
}
projectFlockId, err := s.hppRepo.GetProjectFlockIDByProjectFlockKandangID(context.Background(), projectFlockKandangId)
if err != nil {
return 0, err
}
projectFlockKandangIds, err := s.hppRepo.GetProjectFlockKandangIDs(context.Background(), projectFlockId)
if err != nil {
return 0, err
}
eggProduksiPiecesFlock, _, err := s.hppRepo.GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds(context.Background(), projectFlockKandangIds, endDate)
if err != nil {
return 0, err
}
eggProduksiPiecesKandang, _, err := s.hppRepo.GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds(context.Background(), []uint{projectFlockKandangId}, endDate)
if err != nil {
return 0, err
}
totalBudgetCost, err := s.hppRepo.GetBudgetCostByProjectFlockId(context.Background(), projectFlockId)
if err != nil {
return 0, err
}
if eggProduksiPiecesFlock == 0 {
return 0, nil
}
return (totalBudgetCost * eggProduksiPiecesKandang) / eggProduksiPiecesFlock, nil
}
func (s *hppService) GetDepresiasiTransfer(projectFlockKandangId uint, endDate *time.Time) (float64, error) {
// if endDate == nil {
// now := time.Now()
// endDate = &now
// }
if s.hppRepo == nil {
return 0, nil
}
sourceProjectFlockID, transferTotalQty, err := s.hppRepo.GetTransferSourceSummary(context.Background(), projectFlockKandangId)
if err != nil {
return 0, err
}
kandangIDsGrowing, err := s.hppRepo.GetProjectFlockKandangIDs(context.Background(), sourceProjectFlockID)
if err != nil {
return 0, err
}
totalPopulationFlockGrowing, err := s.hppRepo.GetTotalPopulation(context.Background(), kandangIDsGrowing)
if err != nil {
return 0, err
}
if totalPopulationFlockGrowing == 0 {
return 0, nil
}
totalDepresiasiFlockGrowing, err := s.GetTotalDepresiasiFlockGrowing(sourceProjectFlockID, endDate)
if err != nil {
return 0, err
}
return (totalDepresiasiFlockGrowing * transferTotalQty) / totalPopulationFlockGrowing, nil
}
func (s *hppService) GetHppEstimationDanRealisasi(totalProductionCost float64, projectFlockKandangId uint, startDate *time.Time, endDate *time.Time) (*HppCostResponse, error) {
if s.hppRepo == nil {
return &HppCostResponse{}, nil
}
estimPieces, estimWeightKg, err := s.hppRepo.GetEggProduksiPiecesAndWeightKgByProjectFlockKandangIds(context.Background(), []uint{projectFlockKandangId}, endDate)
if err != nil {
return nil, err
}
realPieces, realWeightKg, err := s.hppRepo.GetEggTerjualPiecesAndWeightKgByProjectFlockKandangIds(context.Background(), []uint{projectFlockKandangId}, startDate, endDate)
if err != nil {
return nil, err
}
estimation := HppCostDetail{
Total: totalProductionCost,
Kg: estimWeightKg,
Butir: estimPieces,
}
if estimWeightKg > 0 {
estimation.HargaKg = roundToTwoDecimals(totalProductionCost / estimWeightKg)
}
if estimPieces > 0 {
estimation.HargaButir = roundToTwoDecimals(totalProductionCost / estimPieces)
}
real := HppCostDetail{
Total: totalProductionCost,
Kg: realWeightKg,
Butir: realPieces,
}
if realWeightKg > 0 {
real.HargaKg = roundToTwoDecimals(totalProductionCost / realWeightKg)
}
if realPieces > 0 {
real.HargaButir = roundToTwoDecimals(totalProductionCost / realPieces)
}
return &HppCostResponse{
Estimation: estimation,
Real: real,
}, nil
}
func roundToTwoDecimals(value float64) float64 {
return math.Round(value*100) / 100
}
+25 -1
View File
@@ -54,12 +54,14 @@ var (
SSOAuthorizeURL string SSOAuthorizeURL string
SSOTokenURL string SSOTokenURL string
SSOGetMeURL string SSOGetMeURL string
SSOPortalURL string
SSOClients map[string]SSOClientConfig SSOClients map[string]SSOClientConfig
SSOAccessCookieName string SSOAccessCookieName string
SSORefreshCookieName string SSORefreshCookieName string
SSOCookieDomain string SSOCookieDomain string
SSOCookieSecure bool SSOCookieSecure bool
SSOCookieSameSite string SSOCookieSameSite string
SSOAccessTokenMaxBytes int
SSOTokenBlacklistPrefix string SSOTokenBlacklistPrefix string
SSOPKCETTL time.Duration SSOPKCETTL time.Duration
SSOUserSyncDrift time.Duration SSOUserSyncDrift time.Duration
@@ -72,6 +74,7 @@ var (
S3SecretKey string S3SecretKey string
S3ForcePathStyle bool S3ForcePathStyle bool
S3PublicBaseURL string S3PublicBaseURL string
S3EnvPrefix string
S3DocumentKeyPrefix string S3DocumentKeyPrefix string
) )
@@ -122,7 +125,12 @@ func init() {
S3SecretKey = strings.TrimSpace(viper.GetString("S3_SECRET_KEY")) S3SecretKey = strings.TrimSpace(viper.GetString("S3_SECRET_KEY"))
S3ForcePathStyle = viper.GetBool("S3_FORCE_PATH_STYLE") S3ForcePathStyle = viper.GetBool("S3_FORCE_PATH_STYLE")
S3PublicBaseURL = strings.TrimSuffix(strings.TrimSpace(viper.GetString("S3_PUBLIC_BASE_URL")), "/") S3PublicBaseURL = strings.TrimSuffix(strings.TrimSpace(viper.GetString("S3_PUBLIC_BASE_URL")), "/")
S3DocumentKeyPrefix = defaultString(strings.Trim(strings.TrimSpace(viper.GetString("S3_DOCUMENT_PREFIX")), "/"), "docs") S3EnvPrefix = defaultString(strings.Trim(strings.TrimSpace(viper.GetString("S3_ENV_PREFIX")), "/"), "local")
docPrefix := strings.Trim(strings.TrimSpace(viper.GetString("S3_DOCUMENT_PREFIX")), "/")
if docPrefix == "" {
docPrefix = "docs"
}
S3DocumentKeyPrefix = joinPath(S3EnvPrefix, docPrefix)
// SSO integration // SSO integration
SSOIssuer = viper.GetString("SSO_ISSUER") SSOIssuer = viper.GetString("SSO_ISSUER")
@@ -131,11 +139,16 @@ func init() {
SSOAuthorizeURL = viper.GetString("SSO_AUTHORIZE_URL") SSOAuthorizeURL = viper.GetString("SSO_AUTHORIZE_URL")
SSOTokenURL = viper.GetString("SSO_TOKEN_URL") SSOTokenURL = viper.GetString("SSO_TOKEN_URL")
SSOGetMeURL = viper.GetString("SSO_GETME_URL") SSOGetMeURL = viper.GetString("SSO_GETME_URL")
SSOPortalURL = strings.TrimSpace(viper.GetString("SSO_PORTAL_URL"))
SSOAccessCookieName = defaultString(viper.GetString("SSO_ACCESS_COOKIE_NAME"), "sso_access") SSOAccessCookieName = defaultString(viper.GetString("SSO_ACCESS_COOKIE_NAME"), "sso_access")
SSORefreshCookieName = defaultString(viper.GetString("SSO_REFRESH_COOKIE_NAME"), "sso_refresh") SSORefreshCookieName = defaultString(viper.GetString("SSO_REFRESH_COOKIE_NAME"), "sso_refresh")
SSOCookieDomain = viper.GetString("SSO_COOKIE_DOMAIN") SSOCookieDomain = viper.GetString("SSO_COOKIE_DOMAIN")
SSOCookieSecure = viper.GetBool("SSO_COOKIE_SECURE") SSOCookieSecure = viper.GetBool("SSO_COOKIE_SECURE")
SSOCookieSameSite = defaultString(viper.GetString("SSO_COOKIE_SAMESITE"), "Lax") SSOCookieSameSite = defaultString(viper.GetString("SSO_COOKIE_SAMESITE"), "Lax")
SSOAccessTokenMaxBytes = viper.GetInt("SSO_ACCESS_TOKEN_MAX_BYTES")
if SSOAccessTokenMaxBytes <= 0 {
SSOAccessTokenMaxBytes = 4096
}
SSOTokenBlacklistPrefix = defaultString(viper.GetString("SSO_TOKEN_BLACKLIST_PREFIX"), "sso:blacklist") SSOTokenBlacklistPrefix = defaultString(viper.GetString("SSO_TOKEN_BLACKLIST_PREFIX"), "sso:blacklist")
if ttl := viper.GetInt("SSO_PKCE_TTL_SECONDS"); ttl > 0 { if ttl := viper.GetInt("SSO_PKCE_TTL_SECONDS"); ttl > 0 {
SSOPKCETTL = time.Duration(ttl) * time.Second SSOPKCETTL = time.Duration(ttl) * time.Second
@@ -240,6 +253,17 @@ func defaultString(v, def string) string {
return v return v
} }
func joinPath(parts ...string) string {
out := make([]string, 0, len(parts))
for _, part := range parts {
part = strings.Trim(part, "/")
if part != "" {
out = append(out, part)
}
}
return strings.Join(out, "/")
}
func ensureProdConfig() { func ensureProdConfig() {
if SSOAuthorizeURL == "" || !strings.HasPrefix(SSOAuthorizeURL, "https://") { if SSOAuthorizeURL == "" || !strings.HasPrefix(SSOAuthorizeURL, "https://") {
panic("SSO_AUTHORIZE_URL must be https in production") panic("SSO_AUTHORIZE_URL must be https in production")
+1
View File
@@ -13,6 +13,7 @@ func FiberConfig() fiber.Config {
CaseSensitive: true, CaseSensitive: true,
ServerHeader: "Fiber", ServerHeader: "Fiber",
AppName: "Fiber API", AppName: "Fiber API",
BodyLimit: 8 * 1024 * 1024,
ErrorHandler: utils.ErrorHandler, ErrorHandler: utils.ErrorHandler,
JSONEncoder: sonic.Marshal, JSONEncoder: sonic.Marshal,
JSONDecoder: sonic.Unmarshal, JSONDecoder: sonic.Unmarshal,
@@ -1 +1,2 @@
DROP SEQUENCE IF EXISTS expenses_ref_seq;
DROP TABLE IF EXISTS expenses; DROP TABLE IF EXISTS expenses;
@@ -1,3 +1,3 @@
-- Drop function and sequence for sales order numbers -- Drop function and sequence for sales order numbers
DROP FUNCTION IF EXISTS generate_so_number();
DROP SEQUENCE IF EXISTS so_number_seq; DROP SEQUENCE IF EXISTS so_number_seq;
DROP FUNCTION IF EXISTS generate_so_number();
@@ -1,6 +1,8 @@
DROP TABLE IF EXISTS daily_checklist_tasks; -- Drop tables in correct order (child tables before parent tables)
DROP TABLE IF EXISTS daily_checklist_activity_task_assignments; -- Child table with FK to daily_checklist_activity_tasks
DROP TABLE IF EXISTS daily_checklist_activity_task_assignees; DROP TABLE IF EXISTS daily_checklist_activity_task_assignees;
DROP TABLE IF EXISTS daily_checklist_activity_tasks; DROP TABLE IF EXISTS daily_checklist_activity_tasks;
DROP TABLE IF EXISTS daily_checklist_tasks;
DROP TABLE IF EXISTS daily_checklist_phases; DROP TABLE IF EXISTS daily_checklist_phases;
DROP TABLE IF EXISTS daily_checklists; DROP TABLE IF EXISTS daily_checklists;
DROP TABLE IF EXISTS checklists; DROP TABLE IF EXISTS checklists;
@@ -0,0 +1,21 @@
BEGIN;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'fk_recordings_project_flock_kandang'
) THEN
ALTER TABLE recordings
DROP CONSTRAINT fk_recordings_project_flock_kandang;
END IF;
END $$;
ALTER TABLE recordings
ADD CONSTRAINT fk_recordings_project_flock_kandang
FOREIGN KEY (project_flock_kandangs_id)
REFERENCES project_flock_kandangs (id)
ON DELETE RESTRICT ON UPDATE CASCADE;
COMMIT;
@@ -0,0 +1,21 @@
BEGIN;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'fk_recordings_project_flock_kandang'
) THEN
ALTER TABLE recordings
DROP CONSTRAINT fk_recordings_project_flock_kandang;
END IF;
END $$;
ALTER TABLE recordings
ADD CONSTRAINT fk_recordings_project_flock_kandang
FOREIGN KEY (project_flock_kandangs_id)
REFERENCES project_flock_kandangs (id)
ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
@@ -0,0 +1,15 @@
-- Revert back to NO ACTION (RESTRICT behavior)
ALTER TABLE expense_nonstocks DROP CONSTRAINT IF EXISTS fk_expense_nonstocks_expense_id;
ALTER TABLE expense_nonstocks
ADD CONSTRAINT fk_expense_nonstocks_expense_id
FOREIGN KEY (expense_id) REFERENCES expenses(id)
ON DELETE NO ACTION;
-- Revert expense_realizations FK
ALTER TABLE expense_realizations DROP CONSTRAINT IF EXISTS fk_expense_realizations_nonstock_id;
ALTER TABLE expense_realizations
ADD CONSTRAINT fk_expense_realizations_nonstock_id
FOREIGN KEY (expense_nonstock_id) REFERENCES expense_nonstocks(id)
ON DELETE NO ACTION;
@@ -0,0 +1,16 @@
-- Drop existing FK constraints
ALTER TABLE expense_nonstocks DROP CONSTRAINT IF EXISTS fk_expense_nonstocks_expense_id;
-- Recreate with ON DELETE CASCADE
ALTER TABLE expense_nonstocks
ADD CONSTRAINT fk_expense_nonstocks_expense_id
FOREIGN KEY (expense_id) REFERENCES expenses(id)
ON DELETE CASCADE;
-- Drop and recreate expense_realizations FK
ALTER TABLE expense_realizations DROP CONSTRAINT IF EXISTS fk_expense_realizations_nonstock_id;
ALTER TABLE expense_realizations
ADD CONSTRAINT fk_expense_realizations_nonstock_id
FOREIGN KEY (expense_nonstock_id) REFERENCES expense_nonstocks(id)
ON DELETE CASCADE;
@@ -0,0 +1,20 @@
-- Revert back to NO ACTION (for rollback safety)
DO $$
BEGIN
ALTER TABLE marketing_products DROP CONSTRAINT IF EXISTS fk_marketing_products_marketing_id;
ALTER TABLE marketing_products
ADD CONSTRAINT fk_marketing_products_marketing_id
FOREIGN KEY (marketing_id) REFERENCES marketings(id)
ON DELETE NO ACTION;
END $$;
DO $$
BEGIN
ALTER TABLE marketing_delivery_products DROP CONSTRAINT IF EXISTS fk_marketing_delivery_products_marketing_product_id;
ALTER TABLE marketing_delivery_products
ADD CONSTRAINT fk_marketing_delivery_products_marketing_product_id
FOREIGN KEY (marketing_product_id) REFERENCES marketing_products(id)
ON DELETE NO ACTION;
END $$;
@@ -0,0 +1,35 @@
-- Ensure marketing_products FK is CASCADE (it should already be, but let's make sure)
DO $$
BEGIN
-- Drop existing FK if exists
IF EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fk_marketing_products_marketing_id'
) THEN
ALTER TABLE marketing_products DROP CONSTRAINT fk_marketing_products_marketing_id;
END IF;
-- Recreate with ON DELETE CASCADE
ALTER TABLE marketing_products
ADD CONSTRAINT fk_marketing_products_marketing_id
FOREIGN KEY (marketing_id) REFERENCES marketings(id)
ON DELETE CASCADE;
END $$;
-- Ensure marketing_delivery_products FK is CASCADE
DO $$
BEGIN
-- Drop existing FK if exists
IF EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fk_marketing_delivery_products_marketing_product_id'
) THEN
ALTER TABLE marketing_delivery_products DROP CONSTRAINT fk_marketing_delivery_products_marketing_product_id;
END IF;
-- Recreate with ON DELETE CASCADE
ALTER TABLE marketing_delivery_products
ADD CONSTRAINT fk_marketing_delivery_products_marketing_product_id
FOREIGN KEY (marketing_product_id) REFERENCES marketing_products(id)
ON DELETE CASCADE;
END $$;
@@ -0,0 +1,9 @@
-- Drop foreign key and column
ALTER TABLE laying_transfers
DROP CONSTRAINT IF EXISTS fk_laying_transfers_product_warehouse_id;
ALTER TABLE laying_transfers
DROP COLUMN IF EXISTS product_warehouse_id;
-- Drop index
DROP INDEX IF EXISTS idx_laying_transfers_product_warehouse_id;
@@ -0,0 +1,19 @@
-- Add product_warehouse_id to laying_transfers for FIFO support
ALTER TABLE laying_transfers
ADD COLUMN product_warehouse_id BIGINT;
-- Add foreign key
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'product_warehouses') THEN
ALTER TABLE laying_transfers
ADD CONSTRAINT fk_laying_transfers_product_warehouse_id
FOREIGN KEY (product_warehouse_id)
REFERENCES product_warehouses(id)
ON DELETE SET NULL;
END IF;
END $$;
-- Add index
CREATE INDEX idx_laying_transfers_product_warehouse_id
ON laying_transfers(product_warehouse_id);
@@ -0,0 +1,14 @@
-- Rollback: Remove STOCKABLE fields from laying_transfers
-- Drop index
DROP INDEX IF EXISTS idx_laying_transfers_dest_product_warehouse_id;
-- Drop foreign key constraint
ALTER TABLE laying_transfers
DROP CONSTRAINT IF EXISTS fk_laying_transfers_dest_product_warehouse_id;
-- Drop columns
ALTER TABLE laying_transfers
DROP COLUMN IF EXISTS dest_product_warehouse_id,
DROP COLUMN IF EXISTS total_qty,
DROP COLUMN IF EXISTS total_used;
@@ -0,0 +1,30 @@
-- Add STOCKABLE fields to laying_transfers for destination warehouse
-- This enables Transfer to Laying to work as DUAL ROLE (Stockable + Usable)
-- Add columns for STOCKABLE role (destination warehouse)
ALTER TABLE laying_transfers
ADD COLUMN dest_product_warehouse_id BIGINT,
ADD COLUMN total_qty NUMERIC(15, 3) DEFAULT 0,
ADD COLUMN total_used NUMERIC(15, 3) DEFAULT 0;
-- Add foreign key constraint
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'product_warehouses') THEN
ALTER TABLE laying_transfers
ADD CONSTRAINT fk_laying_transfers_dest_product_warehouse_id
FOREIGN KEY (dest_product_warehouse_id)
REFERENCES product_warehouses(id)
ON DELETE SET NULL;
END IF;
END $$;
-- Add index for performance
CREATE INDEX idx_laying_transfers_dest_product_warehouse_id
ON laying_transfers(dest_product_warehouse_id);
-- Add comment for documentation
COMMENT ON COLUMN laying_transfers.product_warehouse_id IS 'Product warehouse at source (Growing flock) - for USABLE role';
COMMENT ON COLUMN laying_transfers.dest_product_warehouse_id IS 'Product warehouse at destination (Laying flock) - for STOCKABLE role';
COMMENT ON COLUMN laying_transfers.total_qty IS 'Total lot quantity introduced to destination warehouse - for STOCKABLE role';
COMMENT ON COLUMN laying_transfers.total_used IS 'Quantity already consumed from this lot at destination - for STOCKABLE role';
@@ -0,0 +1,7 @@
-- Remove chart_data, uniform_date, and related indexes
DROP INDEX IF EXISTS idx_project_flock_kandang_uniformity_uniform_date;
DROP INDEX IF EXISTS idx_project_flock_kandang_uniformity_unique;
ALTER TABLE project_flock_kandang_uniformity
DROP COLUMN IF EXISTS chart_data,
DROP COLUMN IF EXISTS uniform_date;
@@ -0,0 +1,25 @@
-- Add uniform_date (if missing), chart_data, and unique constraint for uniformity records
ALTER TABLE project_flock_kandang_uniformity
ADD COLUMN IF NOT EXISTS uniform_date TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS chart_data JSONB;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'project_flock_kandang_uniformity'
AND column_name = 'deleted_at'
) THEN
CREATE UNIQUE INDEX IF NOT EXISTS idx_project_flock_kandang_uniformity_unique
ON project_flock_kandang_uniformity (project_flock_kandang_id, week, uniform_date)
WHERE deleted_at IS NULL;
ELSE
CREATE UNIQUE INDEX IF NOT EXISTS idx_project_flock_kandang_uniformity_unique
ON project_flock_kandang_uniformity (project_flock_kandang_id, week, uniform_date);
END IF;
END $$;
CREATE INDEX IF NOT EXISTS idx_project_flock_kandang_uniformity_uniform_date
ON project_flock_kandang_uniformity (uniform_date);
@@ -0,0 +1,4 @@
-- Remove expense_nonstock_id from stock_transfer_details
ALTER TABLE stock_transfer_details DROP CONSTRAINT IF EXISTS fk_stock_transfer_details_expense_nonstock;
ALTER TABLE stock_transfer_details DROP COLUMN IF EXISTS expense_nonstock_id;
DROP INDEX IF EXISTS idx_stock_transfer_details_expense_nonstock_id;
@@ -0,0 +1,10 @@
-- Add expense_nonstock_id to stock_transfer_details
-- This allows tracking expedition/transport costs for stock transfers (same as purchase)
ALTER TABLE stock_transfer_details
ADD COLUMN expense_nonstock_id BIGINT,
ADD CONSTRAINT fk_stock_transfer_details_expense_nonstock
FOREIGN KEY (expense_nonstock_id) REFERENCES expense_nonstocks(id) ON DELETE SET NULL;
-- Create index for better query performance
CREATE INDEX idx_stock_transfer_details_expense_nonstock_id ON stock_transfer_details(expense_nonstock_id);
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE payments
DROP COLUMN IF EXISTS party_account_number;
COMMIT;
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE payments
ADD COLUMN IF NOT EXISTS party_account_number VARCHAR(50);
COMMIT;
@@ -0,0 +1 @@
DROP TABLE IF EXISTS projects;
@@ -0,0 +1 @@
DROP TABLE IF EXISTS projects;
@@ -0,0 +1,20 @@
-- Revert master data foreign keys to CASCADE delete (except FCR)
ALTER TABLE nonstock_suppliers
DROP CONSTRAINT IF EXISTS nonstock_suppliers_nonstock_id_fkey,
DROP CONSTRAINT IF EXISTS nonstock_suppliers_supplier_id_fkey;
ALTER TABLE nonstock_suppliers
ADD CONSTRAINT nonstock_suppliers_nonstock_id_fkey FOREIGN KEY (nonstock_id)
REFERENCES nonstocks (id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT nonstock_suppliers_supplier_id_fkey FOREIGN KEY (supplier_id)
REFERENCES suppliers (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE product_suppliers
DROP CONSTRAINT IF EXISTS product_suppliers_product_id_fkey,
DROP CONSTRAINT IF EXISTS product_suppliers_supplier_id_fkey;
ALTER TABLE product_suppliers
ADD CONSTRAINT product_suppliers_product_id_fkey FOREIGN KEY (product_id)
REFERENCES products (id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT product_suppliers_supplier_id_fkey FOREIGN KEY (supplier_id)
REFERENCES suppliers (id) ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,20 @@
-- Update master data foreign keys to RESTRICT delete (except FCR)
ALTER TABLE nonstock_suppliers
DROP CONSTRAINT IF EXISTS nonstock_suppliers_nonstock_id_fkey,
DROP CONSTRAINT IF EXISTS nonstock_suppliers_supplier_id_fkey;
ALTER TABLE nonstock_suppliers
ADD CONSTRAINT nonstock_suppliers_nonstock_id_fkey FOREIGN KEY (nonstock_id)
REFERENCES nonstocks (id) ON DELETE RESTRICT ON UPDATE CASCADE,
ADD CONSTRAINT nonstock_suppliers_supplier_id_fkey FOREIGN KEY (supplier_id)
REFERENCES suppliers (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE product_suppliers
DROP CONSTRAINT IF EXISTS product_suppliers_product_id_fkey,
DROP CONSTRAINT IF EXISTS product_suppliers_supplier_id_fkey;
ALTER TABLE product_suppliers
ADD CONSTRAINT product_suppliers_product_id_fkey FOREIGN KEY (product_id)
REFERENCES products (id) ON DELETE RESTRICT ON UPDATE CASCADE,
ADD CONSTRAINT product_suppliers_supplier_id_fkey FOREIGN KEY (supplier_id)
REFERENCES suppliers (id) ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,79 @@
-- Rollback: Revert FIFO fields back to laying_transfers from detail tables
-- ============================================================================
-- PART 1: Remove FIFO columns from detail tables
-- ============================================================================
-- Add back old qty column first
ALTER TABLE laying_transfer_sources
ADD COLUMN IF NOT EXISTS qty NUMERIC(15, 3) NOT NULL DEFAULT 0;
ALTER TABLE laying_transfer_targets
ADD COLUMN IF NOT EXISTS qty NUMERIC(15, 3) NOT NULL DEFAULT 0;
-- Now drop FIFO columns
ALTER TABLE laying_transfer_sources
DROP COLUMN IF EXISTS usage_qty,
DROP COLUMN IF EXISTS pending_usage_qty;
ALTER TABLE laying_transfer_targets
DROP COLUMN IF EXISTS total_qty,
DROP COLUMN IF EXISTS total_used;
-- ============================================================================
-- PART 2: Add back FIFO columns to laying_transfers table
-- ============================================================================
-- Add columns back for USABLE role (source warehouse)
ALTER TABLE laying_transfers
ADD COLUMN product_warehouse_id BIGINT,
ADD COLUMN pending_usage_qty NUMERIC(15, 3),
ADD COLUMN usage_qty NUMERIC(15, 3);
-- Add columns back for STOCKABLE role (destination warehouse)
ALTER TABLE laying_transfers
ADD COLUMN dest_product_warehouse_id BIGINT,
ADD COLUMN total_qty NUMERIC(15, 3) DEFAULT 0 NOT NULL,
ADD COLUMN total_used NUMERIC(15, 3) DEFAULT 0 NOT NULL;
-- ============================================================================
-- PART 3: Recreate foreign key constraints
-- ============================================================================
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'product_warehouses') THEN
-- Add source product warehouse FK
ALTER TABLE laying_transfers
ADD CONSTRAINT fk_laying_transfers_product_warehouse_id
FOREIGN KEY (product_warehouse_id)
REFERENCES product_warehouses(id)
ON DELETE SET NULL;
-- Add destination product warehouse FK
ALTER TABLE laying_transfers
ADD CONSTRAINT fk_laying_transfers_dest_product_warehouse_id
FOREIGN KEY (dest_product_warehouse_id)
REFERENCES product_warehouses(id)
ON DELETE SET NULL;
END IF;
END $$;
-- ============================================================================
-- PART 4: Recreate indexes for performance
-- ============================================================================
CREATE INDEX idx_laying_transfers_product_warehouse_id
ON laying_transfers(product_warehouse_id);
CREATE INDEX idx_laying_transfers_dest_product_warehouse_id
ON laying_transfers(dest_product_warehouse_id);
-- ============================================================================
-- PART 5: Recreate comments for documentation
-- ============================================================================
COMMENT ON COLUMN laying_transfers.product_warehouse_id IS 'Product warehouse at source (Growing flock) - for USABLE role';
COMMENT ON COLUMN laying_transfers.dest_product_warehouse_id IS 'Product warehouse at destination (Laying flock) - for STOCKABLE role';
COMMENT ON COLUMN laying_transfers.total_qty IS 'Total lot quantity introduced to destination warehouse - for STOCKABLE role';
COMMENT ON COLUMN laying_transfers.total_used IS 'Quantity already consumed from this lot at destination - for FIFO STOCKABLE role';
@@ -0,0 +1,73 @@
-- Move FIFO fields from laying_transfers to detail tables (sources & targets)
-- This enables proper FIFO integration for transfer laying with multiple sources and targets
-- ============================================================================
-- PART 1: Remove FIFO-related columns from laying_transfers table
-- ============================================================================
-- Drop foreign key constraints first
DO $$
BEGIN
-- Drop source product warehouse FK
IF EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fk_laying_transfers_product_warehouse_id'
) THEN
ALTER TABLE laying_transfers
DROP CONSTRAINT fk_laying_transfers_product_warehouse_id;
END IF;
-- Drop destination product warehouse FK
IF EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fk_laying_transfers_dest_product_warehouse_id'
) THEN
ALTER TABLE laying_transfers
DROP CONSTRAINT fk_laying_transfers_dest_product_warehouse_id;
END IF;
END $$;
-- Drop indexes
DROP INDEX IF EXISTS idx_laying_transfers_product_warehouse_id;
DROP INDEX IF EXISTS idx_laying_transfers_dest_product_warehouse_id;
-- Remove columns from laying_transfers
ALTER TABLE laying_transfers
DROP COLUMN IF EXISTS product_warehouse_id,
DROP COLUMN IF EXISTS dest_product_warehouse_id,
DROP COLUMN IF EXISTS pending_usage_qty,
DROP COLUMN IF EXISTS usage_qty,
DROP COLUMN IF EXISTS total_qty,
DROP COLUMN IF EXISTS total_used;
-- ============================================================================
-- PART 2: Add FIFO columns to laying_transfer_sources (USABLE role)
-- ============================================================================
ALTER TABLE laying_transfer_sources
ADD COLUMN usage_qty NUMERIC(15, 3) DEFAULT 0 NOT NULL,
ADD COLUMN pending_usage_qty NUMERIC(15, 3) DEFAULT 0 NOT NULL;
-- Add comments for documentation
COMMENT ON COLUMN laying_transfer_sources.usage_qty IS 'Quantity consumed from this source - for FIFO USABLE role';
COMMENT ON COLUMN laying_transfer_sources.pending_usage_qty IS 'Quantity pending to consume from this source - for FIFO USABLE role';
-- Drop old qty column as it's replaced by usage_qty
ALTER TABLE laying_transfer_sources
DROP COLUMN IF EXISTS qty;
-- ============================================================================
-- PART 3: Add FIFO columns to laying_transfer_targets (STOCKABLE role)
-- ============================================================================
ALTER TABLE laying_transfer_targets
ADD COLUMN total_qty NUMERIC(15, 3) DEFAULT 0 NOT NULL,
ADD COLUMN total_used NUMERIC(15, 3) DEFAULT 0 NOT NULL;
-- Add comments for documentation
COMMENT ON COLUMN laying_transfer_targets.total_qty IS 'Total lot quantity introduced to this target warehouse - for FIFO STOCKABLE role';
COMMENT ON COLUMN laying_transfer_targets.total_used IS 'Quantity already consumed from this lot at target warehouse - for FIFO STOCKABLE role';
-- Drop old qty column as it's replaced by total_qty
ALTER TABLE laying_transfer_targets
DROP COLUMN IF EXISTS qty;
@@ -0,0 +1,59 @@
BEGIN;
ALTER TABLE recordings
DROP CONSTRAINT IF EXISTS chk_recordings_nonnegatives_v4;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'hen_day'
) THEN
ALTER TABLE recordings RENAME COLUMN hen_day TO hand_day;
END IF;
END $$;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'hen_house'
) THEN
ALTER TABLE recordings RENAME COLUMN hen_house TO hand_house;
END IF;
END $$;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'egg_mass'
) THEN
ALTER TABLE recordings RENAME COLUMN egg_mass TO egg_mesh;
END IF;
END $$;
ALTER TABLE recordings
ADD COLUMN IF NOT EXISTS daily_gain NUMERIC(7,3),
ADD COLUMN IF NOT EXISTS avg_daily_gain NUMERIC(7,3);
ALTER TABLE recordings
ADD CONSTRAINT chk_recordings_nonnegatives_v3 CHECK (
(total_depletion_qty IS NULL OR total_depletion_qty >= 0) AND
(cum_depletion_rate IS NULL OR cum_depletion_rate >= 0) AND
(daily_gain IS NULL OR daily_gain >= 0) AND
(avg_daily_gain IS NULL OR avg_daily_gain >= 0) AND
(cum_intake IS NULL OR cum_intake >= 0) AND
(fcr_value IS NULL OR fcr_value >= 0) AND
(total_chick_qty IS NULL OR total_chick_qty >= 0) AND
(hand_day IS NULL OR hand_day >= 0) AND
(hand_house IS NULL OR hand_house >= 0) AND
(feed_intake IS NULL OR feed_intake >= 0) AND
(egg_mesh IS NULL OR egg_mesh >= 0) AND
(egg_weight IS NULL OR egg_weight >= 0)
);
COMMIT;
@@ -0,0 +1,57 @@
BEGIN;
ALTER TABLE recordings
DROP CONSTRAINT IF EXISTS chk_recordings_nonnegatives_v3;
ALTER TABLE recordings
DROP COLUMN IF EXISTS daily_gain,
DROP COLUMN IF EXISTS avg_daily_gain;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'hand_day'
) THEN
ALTER TABLE recordings RENAME COLUMN hand_day TO hen_day;
END IF;
END $$;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'hand_house'
) THEN
ALTER TABLE recordings RENAME COLUMN hand_house TO hen_house;
END IF;
END $$;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'recordings' AND column_name = 'egg_mesh'
) THEN
ALTER TABLE recordings RENAME COLUMN egg_mesh TO egg_mass;
END IF;
END $$;
ALTER TABLE recordings
ADD CONSTRAINT chk_recordings_nonnegatives_v4 CHECK (
(total_depletion_qty IS NULL OR total_depletion_qty >= 0) AND
(cum_depletion_rate IS NULL OR cum_depletion_rate >= 0) AND
(cum_intake IS NULL OR cum_intake >= 0) AND
(fcr_value IS NULL OR fcr_value >= 0) AND
(total_chick_qty IS NULL OR total_chick_qty >= 0) AND
(hen_day IS NULL OR hen_day >= 0) AND
(hen_house IS NULL OR hen_house >= 0) AND
(feed_intake IS NULL OR feed_intake >= 0) AND
(egg_mass IS NULL OR egg_mass >= 0) AND
(egg_weight IS NULL OR egg_weight >= 0)
);
COMMIT;
@@ -0,0 +1,6 @@
-- Rollback: remove price from supplier relations
ALTER TABLE product_suppliers
DROP COLUMN IF EXISTS price;
ALTER TABLE nonstock_suppliers
DROP COLUMN IF EXISTS price;
@@ -0,0 +1,6 @@
-- Migration: add price to supplier relations
ALTER TABLE product_suppliers
ADD COLUMN IF NOT EXISTS price NUMERIC(15, 3) NOT NULL DEFAULT 0;
ALTER TABLE nonstock_suppliers
ADD COLUMN IF NOT EXISTS price NUMERIC(15, 3) NOT NULL DEFAULT 0;
@@ -0,0 +1,3 @@
ALTER TABLE recording_eggs
DROP COLUMN IF EXISTS total_used,
DROP COLUMN IF EXISTS total_qty;
@@ -0,0 +1,7 @@
ALTER TABLE recording_eggs
ADD COLUMN total_qty NUMERIC(15, 3) DEFAULT 0 NOT NULL,
ADD COLUMN total_used NUMERIC(15, 3) DEFAULT 0 NOT NULL;
UPDATE recording_eggs
SET total_qty = qty
WHERE total_qty = 0;
@@ -0,0 +1,3 @@
-- Rollback: add price back to nonstock_suppliers
ALTER TABLE nonstock_suppliers
ADD COLUMN IF NOT EXISTS price NUMERIC(15, 3) NOT NULL DEFAULT 0;
@@ -0,0 +1,3 @@
-- Migration: remove price from nonstock_suppliers
ALTER TABLE nonstock_suppliers
DROP COLUMN IF EXISTS price;
@@ -0,0 +1,4 @@
-- Rollback: Remove requested_qty column from laying_transfer_sources table
ALTER TABLE laying_transfer_sources
DROP COLUMN IF EXISTS requested_qty;
@@ -0,0 +1,9 @@
-- Add requested_qty column to laying_transfer_sources table
-- This field stores the quantity requested by user during create/update
-- Separate from UsageQty (FIFO consumed) and PendingUsageQty (FIFO pending)
ALTER TABLE laying_transfer_sources
ADD COLUMN requested_qty NUMERIC(15,3) DEFAULT 0 NOT NULL;
-- Add comment for documentation
COMMENT ON COLUMN laying_transfer_sources.requested_qty IS 'Quantity requested by user during create/update';
@@ -0,0 +1,3 @@
ALTER TABLE recording_depletions
DROP COLUMN IF EXISTS pending_qty,
DROP COLUMN IF EXISTS source_product_warehouse_id;
@@ -0,0 +1,17 @@
ALTER TABLE recording_depletions
ADD COLUMN IF NOT EXISTS pending_qty numeric(15,3) NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS source_product_warehouse_id bigint;
UPDATE recording_depletions rd
SET source_product_warehouse_id = src.product_warehouse_id
FROM recordings r
JOIN LATERAL (
SELECT pfp.product_warehouse_id
FROM project_chickins pc
JOIN project_flock_populations pfp ON pfp.project_chickin_id = pc.id
WHERE pc.project_flock_kandang_id = r.project_flock_kandangs_id
ORDER BY pfp.created_at ASC, pfp.id ASC
LIMIT 1
) AS src ON true
WHERE r.id = rd.recording_id
AND rd.source_product_warehouse_id IS NULL;
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE payments
ALTER COLUMN bank_id SET NOT NULL;
COMMIT;
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE payments
ALTER COLUMN bank_id DROP NOT NULL;
COMMIT;
@@ -0,0 +1,3 @@
ALTER TABLE adjustment_stocks ADD COLUMN stock_log_id INTEGER;
CREATE INDEX idx_adjustment_stocks_stock_log_id ON adjustment_stocks (stock_log_id);
@@ -0,0 +1 @@
ALTER TABLE adjustment_stocks DROP COLUMN IF EXISTS stock_log_id;
@@ -0,0 +1,56 @@
BEGIN;
DO $$
DECLARE
t text;
seq_name text;
BEGIN
FOREACH t IN ARRAY ARRAY[
'daily_checklist_activity_task_assignments',
'daily_checklist_activity_tasks',
'daily_checklist_phases',
'daily_checklist_tasks',
'daily_checklists',
'employee_kandangs',
'employees',
'phase_activities',
'phases'
]
LOOP
-- Sequence name convention
seq_name := format('public.%I_id_seq', t);
-- 1) Drop default nextval (bigserial behavior)
EXECUTE format(
'ALTER TABLE public.%I ALTER COLUMN id DROP DEFAULT',
t
);
-- 2) Add IDENTITY back (BY DEFAULT is safer for rollback)
EXECUTE format(
'ALTER TABLE public.%I ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY',
t
);
-- 3) Detach & optionally drop sequence (safe)
IF EXISTS (
SELECT 1 FROM pg_class
WHERE relkind = 'S'
AND relname = t || '_id_seq'
) THEN
EXECUTE format(
'ALTER SEQUENCE %s OWNED BY NONE',
seq_name
);
-- Optional: drop sequence (comment if you want to keep it)
EXECUTE format(
'DROP SEQUENCE IF EXISTS %s',
seq_name
);
END IF;
END LOOP;
END $$;
COMMIT;
@@ -0,0 +1,59 @@
BEGIN;
DO $$
DECLARE
t text;
seq_name text;
max_id bigint;
BEGIN
FOREACH t IN ARRAY ARRAY[
'daily_checklist_activity_task_assignments',
'daily_checklist_activity_tasks',
'daily_checklist_phases',
'daily_checklist_tasks',
'daily_checklists',
'employee_kandangs',
'employees',
'phase_activities',
'phases'
]
LOOP
-- Sequence name convention: public.<table>_id_seq
seq_name := format('public.%I_id_seq', t);
-- Drop IDENTITY only if the column is identity (safe to re-run)
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = t
AND column_name = 'id'
AND is_identity = 'YES'
) THEN
EXECUTE format('ALTER TABLE public.%I ALTER COLUMN id DROP IDENTITY', t);
END IF;
-- Ensure sequence exists
EXECUTE format('CREATE SEQUENCE IF NOT EXISTS %s', seq_name);
-- Set default like bigserial
EXECUTE format(
'ALTER TABLE public.%I ALTER COLUMN id SET DEFAULT nextval(''%s'')',
t, seq_name
);
-- Own the sequence by the column
EXECUTE format(
'ALTER SEQUENCE %s OWNED BY public.%I.id',
seq_name, t
);
-- Sync sequence to MAX(id) + 1 to avoid duplicate key
EXECUTE format('SELECT COALESCE(MAX(id), 0) FROM public.%I', t) INTO max_id;
EXECUTE format('SELECT setval(''%s'', $1, false)', seq_name)
USING (max_id + 1);
END LOOP;
END $$;
COMMIT;
@@ -0,0 +1,2 @@
ALTER TABLE stock_logs
DROP COLUMN stock;
@@ -0,0 +1,18 @@
ALTER TABLE stock_logs
ADD COLUMN stock NUMERIC(15, 3) NOT NULL DEFAULT 0;
WITH calc AS (
SELECT
id,
SUM(COALESCE(increase, 0) - COALESCE(decrease, 0))
OVER (
PARTITION BY product_warehouse_id
ORDER BY id
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_stock
FROM stock_logs
)
UPDATE stock_logs t
SET stock = c.running_stock
FROM calc c
WHERE t.id = c.id;
@@ -0,0 +1,7 @@
BEGIN;
-- Migration: revert documents.path length
ALTER TABLE documents
ALTER COLUMN path TYPE VARCHAR(50);
COMMIT;
@@ -0,0 +1,7 @@
BEGIN;
-- Migration: extend documents.path length for environment prefixes
ALTER TABLE documents
ALTER COLUMN path TYPE VARCHAR(255);
COMMIT;
@@ -0,0 +1,2 @@
-- Drop transfer laying sequence
DROP SEQUENCE IF EXISTS transfer_laying_seq;
@@ -0,0 +1,33 @@
-- Create sequence for transfer laying movement number
CREATE SEQUENCE IF NOT EXISTS transfer_laying_seq START
WITH
1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 99999 NO CYCLE;
-- Set sequence starting value based on existing data (if any)
-- This prevents duplicate movement numbers if there's already data
DO $$ DECLARE max_existing INTEGER;
BEGIN
-- Check if table exists and has data
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE
table_schema = 'public'
AND table_name = 'transfer_to_layings'
) THEN
-- Get max ID from existing records
SELECT COALESCE(MAX(id), 0) INTO max_existing
FROM transfer_to_layings;
-- Set sequence to start after the highest existing ID
IF max_existing > 0 THEN PERFORM setval (
'transfer_laying_seq',
max_existing
);
END IF;
END IF;
END $$;
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE adjustment_stocks
DROP COLUMN adj_number;
COMMIT;
@@ -0,0 +1,10 @@
BEGIN;
ALTER TABLE adjustment_stocks
ADD COLUMN adj_number VARCHAR(255);
UPDATE adjustment_stocks
SET adj_number = CONCAT('ADJ-', LPAD(id::text, 5, '0'))
WHERE adj_number IS NULL;
COMMIT;
@@ -0,0 +1,8 @@
-- Remove columns from marketing_products
ALTER TABLE marketing_products
DROP COLUMN IF EXISTS week,
DROP COLUMN IF EXISTS weight_per_convertion,
DROP COLUMN IF EXISTS convertion_unit;
-- Remove column from marketings
ALTER TABLE marketings DROP COLUMN IF EXISTS marketing_type;
@@ -0,0 +1,9 @@
-- Add marketing_type to marketings table
ALTER TABLE marketings
ADD COLUMN IF NOT EXISTS marketing_type VARCHAR(50);
-- Add convertion fields to marketing_products table
ALTER TABLE marketing_products
ADD COLUMN IF NOT EXISTS convertion_unit VARCHAR(20),
ADD COLUMN IF NOT EXISTS weight_per_convertion NUMERIC(15, 3),
ADD COLUMN IF NOT EXISTS week INTEGER;
@@ -0,0 +1,47 @@
BEGIN;
DO $$
DECLARE
fallback_fcr_id BIGINT;
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'project_flocks'
AND column_name = 'fcr_id'
) THEN
ALTER TABLE project_flocks
ADD COLUMN fcr_id BIGINT;
END IF;
SELECT id INTO fallback_fcr_id
FROM fcrs
ORDER BY id ASC
LIMIT 1;
IF fallback_fcr_id IS NOT NULL THEN
UPDATE project_flocks
SET fcr_id = fallback_fcr_id
WHERE fcr_id IS NULL;
ALTER TABLE project_flocks
ALTER COLUMN fcr_id SET NOT NULL;
END IF;
IF EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'project_flocks_fcr_id_fkey'
) THEN
ALTER TABLE project_flocks
DROP CONSTRAINT project_flocks_fcr_id_fkey;
END IF;
ALTER TABLE project_flocks
ADD CONSTRAINT project_flocks_fcr_id_fkey
FOREIGN KEY (fcr_id) REFERENCES fcrs(id)
ON DELETE RESTRICT ON UPDATE CASCADE;
END $$;
COMMIT;
@@ -0,0 +1,26 @@
BEGIN;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'project_flocks'
AND column_name = 'fcr_id'
) THEN
IF EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'project_flocks_fcr_id_fkey'
) THEN
ALTER TABLE project_flocks
DROP CONSTRAINT project_flocks_fcr_id_fkey;
END IF;
ALTER TABLE project_flocks
DROP COLUMN fcr_id;
END IF;
END $$;
COMMIT;
+26 -5
View File
@@ -74,7 +74,7 @@ func seedUsers(tx *gorm.DB) (map[string]uint, error) {
} }
func seedUoms(tx *gorm.DB, createdBy uint) (map[string]uint, error) { func seedUoms(tx *gorm.DB, createdBy uint) (map[string]uint, error) {
names := []string{"Kilogram", "Gram", "Liter", "Unit", "Ekor"} names := []string{"Kilogram", "Gram", "Liter", "Unit", "Ekor", "Butir"}
result := make(map[string]uint, len(names)) result := make(map[string]uint, len(names))
for _, name := range names { for _, name := range names {
@@ -235,7 +235,7 @@ func seedProducts(tx *gorm.DB, createdBy uint, uoms map[string]uint, categories
Name: "Telur Utuh", Name: "Telur Utuh",
Brand: "-", Brand: "-",
Sku: "4", Sku: "4",
Uom: "Gram", Uom: "Butir",
Category: "Telur", Category: "Telur",
Price: 1, Price: 1,
Flags: []utils.FlagType{utils.FlagTelurUtuh}, Flags: []utils.FlagType{utils.FlagTelurUtuh},
@@ -245,7 +245,7 @@ func seedProducts(tx *gorm.DB, createdBy uint, uoms map[string]uint, categories
Name: "Telur Pecah", Name: "Telur Pecah",
Brand: "-", Brand: "-",
Sku: "5", Sku: "5",
Uom: "Gram", Uom: "Butir",
Category: "Telur", Category: "Telur",
Price: 1, Price: 1,
Flags: []utils.FlagType{utils.FlagTelurPecah}, Flags: []utils.FlagType{utils.FlagTelurPecah},
@@ -255,7 +255,7 @@ func seedProducts(tx *gorm.DB, createdBy uint, uoms map[string]uint, categories
Name: "Telur Putih", Name: "Telur Putih",
Brand: "-", Brand: "-",
Sku: "6", Sku: "6",
Uom: "Gram", Uom: "Butir",
Category: "Telur", Category: "Telur",
Price: 1, Price: 1,
Flags: []utils.FlagType{utils.FlagTelurPutih}, Flags: []utils.FlagType{utils.FlagTelurPutih},
@@ -265,12 +265,32 @@ func seedProducts(tx *gorm.DB, createdBy uint, uoms map[string]uint, categories
Name: "Telur Retak", Name: "Telur Retak",
Brand: "-", Brand: "-",
Sku: "7", Sku: "7",
Uom: "Gram", Uom: "Butir",
Category: "Telur", Category: "Telur",
Price: 1, Price: 1,
Flags: []utils.FlagType{utils.FlagTelurRetak}, Flags: []utils.FlagType{utils.FlagTelurRetak},
IsVisible: false, IsVisible: false,
}, },
{
Name: "Telur Papacal",
Brand: "-",
Sku: "8",
Uom: "Butir",
Category: "Telur",
Price: 1,
Flags: []utils.FlagType{utils.FlagTelur},
IsVisible: false,
},
{
Name: "Telur Jumbo",
Brand: "-",
Sku: "9",
Uom: "Butir",
Category: "Telur",
Price: 1,
Flags: []utils.FlagType{utils.FlagTelur},
IsVisible: false,
},
} }
for _, seed := range seeds { for _, seed := range seeds {
@@ -299,6 +319,7 @@ func seedProducts(tx *gorm.DB, createdBy uint, uoms map[string]uint, categories
Tax: tax, Tax: tax,
ExpiryPeriod: seed.Expiry, ExpiryPeriod: seed.Expiry,
CreatedBy: createdBy, CreatedBy: createdBy,
IsVisible: seed.IsVisible,
} }
if err := tx.Create(&product).Error; err != nil { if err := tx.Create(&product).Error; err != nil {
return err return err
+10 -21
View File
@@ -2,28 +2,17 @@ package entities
import "time" import "time"
// AdjustmentStock tracks FIFO allocation for stock adjustments
// - For INCREASE adjustments (Stockable): Tracks stock added to warehouse
// - For DECREASE adjustments (Usable): Tracks stock consumed from warehouse
type AdjustmentStock struct { type AdjustmentStock struct {
Id uint `gorm:"primaryKey"` Id uint `gorm:"primaryKey"`
StockLogId uint `gorm:"column:stock_log_id;not null;index"` ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"`
ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"` TotalQty float64 `gorm:"column:total_qty;default:0"`
TotalUsed float64 `gorm:"column:total_used;default:0"`
UsageQty float64 `gorm:"column:usage_qty;default:0"`
PendingQty float64 `gorm:"column:pending_qty;default:0"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
AdjNumber string `gorm:"column:adj_number;uniqueIndex;not null"`
// === FIFO FIELDS FOR INCREASE ADJUSTMENT (Stockable) ===
// Tracks stock added to warehouse via adjustment INCREASE
TotalQty float64 `gorm:"column:total_qty;default:0"` // Total lot quantity available
TotalUsed float64 `gorm:"column:total_used;default:0"` // Quantity already used from this lot
// === FIFO FIELDS FOR DECREASE ADJUSTMENT (Usable) ===
// Tracks stock consumed from warehouse via adjustment DECREASE
UsageQty float64 `gorm:"column:usage_qty;default:0"` // Actual quantity consumed
PendingQty float64 `gorm:"column:pending_qty;default:0"` // Pending quantity (waiting for stock)
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
// Relations
StockLog *StockLog `gorm:"foreignKey:StockLogId;references:Id"`
ProductWarehouse *ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"` ProductWarehouse *ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"`
StockLog *StockLog `gorm:"polymorphic:Loggable;polymorphicType:LoggableType;polymorphicId:LoggableId;polymorphicValue:ADJUSTMENT"`
} }
+18
View File
@@ -0,0 +1,18 @@
package entities
import (
"time"
"gorm.io/gorm"
)
type Dashboard struct {
Id uint `gorm:"primaryKey"`
Name string `gorm:"not null;uniqueIndex:idx_name,where:deleted_at IS NULL"`
CreatedBy uint `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
}
+1 -1
View File
@@ -7,7 +7,7 @@ type Document struct {
DocumentableType string `gorm:"size:50;not null;index:documents_documentable_polymorphic,priority:1"` DocumentableType string `gorm:"size:50;not null;index:documents_documentable_polymorphic,priority:1"`
DocumentableId uint64 `gorm:"not null;index:documents_documentable_polymorphic,priority:2"` DocumentableId uint64 `gorm:"not null;index:documents_documentable_polymorphic,priority:2"`
Type string `gorm:"size:50;not null"` Type string `gorm:"size:50;not null"`
Path string `gorm:"size:50;not null"` Path string `gorm:"size:255;not null"`
Name string `gorm:"size:50;not null"` Name string `gorm:"size:50;not null"`
Ext string `gorm:"size:50;not null"` Ext string `gorm:"size:50;not null"`
Size float64 `gorm:"type:numeric(15,3);not null"` Size float64 `gorm:"type:numeric(15,3);not null"`
+9 -9
View File
@@ -5,15 +5,15 @@ import (
) )
type ExpenseNonstock struct { type ExpenseNonstock struct {
Id uint64 `gorm:"primaryKey;autoIncrement"` Id uint64 `gorm:"primaryKey;autoIncrement"`
ExpenseId *uint64 `gorm:""` ExpenseId *uint64 `gorm:""`
ProjectFlockKandangId *uint64 `gorm:""` ProjectFlockKandangId *uint64 `gorm:""`
KandangId *uint64 `gorm:""` KandangId *uint64 `gorm:""`
NonstockId *uint64 `gorm:""` NonstockId *uint64 `gorm:""`
Qty float64 `gorm:"type:numeric(15,3);not null"` Qty float64 `gorm:"type:numeric(15,3);not null"`
Price float64 `gorm:"type:numeric(15,3);not null;column:price"` Price float64 `gorm:"type:numeric(15,3);not null;column:price"`
Notes string `gorm:"type:text;column:notes"` Notes string `gorm:"type:text;column:notes"`
CreatedAt time.Time `gorm:"type:timestamptz;default:CURRENT_TIMESTAMP"` CreatedAt time.Time `gorm:"type:timestamptz;default:CURRENT_TIMESTAMP"`
Expense *Expense `gorm:"foreignKey:ExpenseId;references:Id"` Expense *Expense `gorm:"foreignKey:ExpenseId;references:Id"`
ProjectFlockKandang *ProjectFlockKandang `gorm:"foreignKey:ProjectFlockKandangId;references:Id"` ProjectFlockKandang *ProjectFlockKandang `gorm:"foreignKey:ProjectFlockKandangId;references:Id"`
+6 -8
View File
@@ -12,18 +12,16 @@ type LayingTransfer struct {
FromProjectFlockId uint `gorm:"not null"` FromProjectFlockId uint `gorm:"not null"`
ToProjectFlockId uint `gorm:"not null"` ToProjectFlockId uint `gorm:"not null"`
TransferDate time.Time `gorm:"type:date;not null"` TransferDate time.Time `gorm:"type:date;not null"`
PendingUsageQty *float64 `gorm:"type:numeric(15,3)"`
UsageQty *float64 `gorm:"type:numeric(15,3)"`
Notes string `gorm:"type:text"` Notes string `gorm:"type:text"`
CreatedBy uint `gorm:"not null"` CreatedBy uint `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index"` DeletedAt gorm.DeletedAt `gorm:"index"`
FromProjectFlock *ProjectFlock `gorm:"foreignKey:FromProjectFlockId;references:Id"` FromProjectFlock *ProjectFlock `gorm:"foreignKey:FromProjectFlockId;references:Id"`
ToProjectFlock *ProjectFlock `gorm:"foreignKey:ToProjectFlockId;references:Id"` ToProjectFlock *ProjectFlock `gorm:"foreignKey:ToProjectFlockId;references:Id"`
CreatedUser *User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser *User `gorm:"foreignKey:CreatedBy;references:Id"`
Sources []LayingTransferSource `gorm:"foreignKey:LayingTransferId;constraint:OnDelete:CASCADE"` Sources []LayingTransferSource `gorm:"foreignKey:LayingTransferId;constraint:OnDelete:CASCADE"`
Targets []LayingTransferTarget `gorm:"foreignKey:LayingTransferId;constraint:OnDelete:CASCADE"` Targets []LayingTransferTarget `gorm:"foreignKey:LayingTransferId;constraint:OnDelete:CASCADE"`
LatestApproval *Approval `gorm:"-" json:"-"` LatestApproval *Approval `gorm:"-" json:"-"`
} }
+3 -1
View File
@@ -11,7 +11,9 @@ type LayingTransferSource struct {
LayingTransferId uint `gorm:"index;not null"` LayingTransferId uint `gorm:"index;not null"`
SourceProjectFlockKandangId uint `gorm:"not null"` SourceProjectFlockKandangId uint `gorm:"not null"`
ProductWarehouseId *uint `gorm:""` ProductWarehouseId *uint `gorm:""`
Qty float64 `gorm:"type:numeric(15,3);not null"` RequestedQty float64 `gorm:"type:numeric(15,3);default:0;not null"` // Quantity requested by user
UsageQty float64 `gorm:"type:numeric(15,3);default:0;not null"` // FIFO USABLE field
PendingUsageQty float64 `gorm:"type:numeric(15,3);default:0;not null"` // FIFO USABLE field
Note string `gorm:"type:text"` Note string `gorm:"type:text"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
+2 -1
View File
@@ -10,7 +10,8 @@ type LayingTransferTarget struct {
Id uint `gorm:"primaryKey"` Id uint `gorm:"primaryKey"`
LayingTransferId uint `gorm:"index;not null"` LayingTransferId uint `gorm:"index;not null"`
TargetProjectFlockKandangId uint `gorm:"not null"` TargetProjectFlockKandangId uint `gorm:"not null"`
Qty float64 `gorm:"type:numeric(15,3);not null"` TotalQty float64 `gorm:"type:numeric(15,3);default:0;not null"` // FIFO STOCKABLE field
TotalUsed float64 `gorm:"type:numeric(15,3);default:0;not null"` // FIFO STOCKABLE field
ProductWarehouseId *uint `gorm:""` ProductWarehouseId *uint `gorm:""`
Note string `gorm:"type:text"` Note string `gorm:"type:text"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
+1
View File
@@ -14,6 +14,7 @@ type Marketing struct {
SoDate time.Time `gorm:"type:date;not null"` SoDate time.Time `gorm:"type:date;not null"`
SalesPersonId uint `gorm:"not null"` SalesPersonId uint `gorm:"not null"`
Notes string `gorm:"type:text"` Notes string `gorm:"type:text"`
MarketingType string `gorm:"type:varchar(50)"`
CreatedBy uint `gorm:"not null"` CreatedBy uint `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
+11 -8
View File
@@ -1,14 +1,17 @@
package entities package entities
type MarketingProduct struct { type MarketingProduct struct {
Id uint `gorm:"primaryKey;autoIncrement"` Id uint `gorm:"primaryKey;autoIncrement"`
MarketingId uint `gorm:"not null"` MarketingId uint `gorm:"not null"`
ProductWarehouseId uint `gorm:"not null"` ProductWarehouseId uint `gorm:"not null"`
Qty float64 `gorm:"type:numeric(15,3);not null"` Qty float64 `gorm:"type:numeric(15,3);not null"`
UnitPrice float64 `gorm:"type:numeric(15,3);not null"` ConvertionUnit *string `gorm:"type:varchar(20)"`
AvgWeight float64 `gorm:"type:numeric(15,3);not null"` WeightPerConvertion *float64 `gorm:"type:numeric(15,3)"`
TotalWeight float64 `gorm:"type:numeric(15,3);not null"` Week *int `gorm:"type:integer"`
TotalPrice float64 `gorm:"type:numeric(15,3);not null"` UnitPrice float64 `gorm:"type:numeric(15,3);not null"`
AvgWeight float64 `gorm:"type:numeric(15,3);not null"`
TotalWeight float64 `gorm:"type:numeric(15,3);not null"`
TotalPrice float64 `gorm:"type:numeric(15,3);not null"`
Marketing Marketing `gorm:"foreignKey:MarketingId;references:Id"` Marketing Marketing `gorm:"foreignKey:MarketingId;references:Id"`
ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"` ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"`
+17 -16
View File
@@ -7,22 +7,23 @@ import (
) )
type Payment struct { type Payment struct {
Id uint `gorm:"primaryKey;autoIncrement"` Id uint `gorm:"primaryKey;autoIncrement"`
PaymentCode string `gorm:"type:varchar(50);not null"` PaymentCode string `gorm:"type:varchar(50);not null"`
ReferenceNumber *string `gorm:"type:varchar(100)"` ReferenceNumber *string `gorm:"type:varchar(100)"`
TransactionType string `gorm:"type:varchar(50)"` TransactionType string `gorm:"type:varchar(50)"`
PartyType string `gorm:"type:varchar(50);not null;index:payments_party_polymorphic,priority:1"` PartyType string `gorm:"type:varchar(50);not null;index:payments_party_polymorphic,priority:1"`
PartyId uint `gorm:"not null;index:payments_party_polymorphic,priority:2"` PartyId uint `gorm:"not null;index:payments_party_polymorphic,priority:2"`
PaymentDate time.Time `gorm:"not null"` PartyAccountNumber *string `gorm:"type:varchar(50)"`
PaymentMethod string `gorm:"type:varchar(20);not null"` PaymentDate time.Time `gorm:"not null"`
BankId *uint `gorm:"not null;index:idx_payments_bank_id"` PaymentMethod string `gorm:"type:varchar(20);not null"`
Direction string `gorm:"type:varchar(5);not null"` BankId *uint `gorm:"not null;index:idx_payments_bank_id"`
Nominal float64 `gorm:"type:numeric(15,3);not null"` Direction string `gorm:"type:varchar(5);not null"`
Notes string `gorm:"type:text;not null"` Nominal float64 `gorm:"type:numeric(15,3);not null"`
CreatedAt time.Time `gorm:"autoCreateTime"` Notes string `gorm:"type:text;not null"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
CreatedBy uint `gorm:"index" json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CreatedBy uint `gorm:"index" json:"-"`
BankWarehouse Bank `gorm:"foreignKey:BankId;references:Id"` BankWarehouse Bank `gorm:"foreignKey:BankId;references:Id"`
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
+7 -6
View File
@@ -7,12 +7,13 @@ import (
) )
type Phases struct { type Phases struct {
Id uint `gorm:"primaryKey"` Id uint `gorm:"primaryKey"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
IsActive bool `gorm:"not null;default:true"` IsActive bool `gorm:"not null;default:true"`
Category string `gorm:"type:category_code;not null"` Category string `gorm:"type:category_code;not null"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
ActivityCount int `gorm:"-" json:"-"`
Activities []PhaseActivity `gorm:"foreignKey:PhaseId;references:Id"` Activities []PhaseActivity `gorm:"foreignKey:PhaseId;references:Id"`
} }
+1 -1
View File
@@ -21,7 +21,7 @@ type Product struct {
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
IsVisible bool `gorm:"column:is_visible;default:true"` IsVisible bool ``
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
Uom Uom `gorm:"foreignKey:UomId;references:Id"` Uom Uom `gorm:"foreignKey:UomId;references:Id"`
+1
View File
@@ -5,6 +5,7 @@ import "time"
type ProductSupplier struct { type ProductSupplier struct {
ProductId uint `gorm:"not null"` ProductId uint `gorm:"not null"`
SupplierId uint `gorm:"not null"` SupplierId uint `gorm:"not null"`
Price float64 `gorm:"type:numeric(15,3);not null;default:0"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
Product Product `gorm:"foreignKey:ProductId;references:Id"` Product Product `gorm:"foreignKey:ProductId;references:Id"`
@@ -1,20 +1,24 @@
package entities package entities
import "time" import (
"encoding/json"
"time"
)
type ProjectFlockKandangUniformity struct { type ProjectFlockKandangUniformity struct {
Id uint `gorm:"primaryKey"` Id uint `gorm:"primaryKey"`
Uniformity float64 `gorm:"type:numeric(15,3)"` Uniformity float64 `gorm:"type:numeric(15,3)"`
Week int `gorm:"not null"` Week int `gorm:"not null"`
Cv float64 `gorm:"type:numeric(15,3)"` Cv float64 `gorm:"type:numeric(15,3)"`
ChickQtyOfWeight float64 `gorm:"type:numeric(15,3)"` ChickQtyOfWeight float64 `gorm:"type:numeric(15,3)"`
MeanUp float64 `gorm:"type:numeric(15,3)"` MeanUp float64 `gorm:"type:numeric(15,3)"`
MeanDown float64 `gorm:"type:numeric(15,3)"` MeanDown float64 `gorm:"type:numeric(15,3)"`
ProjectFlockKandangId uint `gorm:"not null"` ProjectFlockKandangId uint `gorm:"not null"`
UniformQty float64 `gorm:"type:numeric(15,3)"` UniformQty float64 `gorm:"type:numeric(15,3)"`
NotUniformQty float64 `gorm:"type:numeric(15,3)"` NotUniformQty float64 `gorm:"type:numeric(15,3)"`
UniformDate *time.Time `gorm:"type:timestamptz"` ChartData json.RawMessage `gorm:"type:jsonb"`
CreatedBy uint `gorm:"not null"` UniformDate *time.Time `gorm:"type:timestamptz"`
CreatedBy uint `gorm:"not null"`
ProjectFlockKandang ProjectFlockKandang `gorm:"foreignKey:ProjectFlockKandangId;references:Id"` ProjectFlockKandang ProjectFlockKandang `gorm:"foreignKey:ProjectFlockKandangId;references:Id"`
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
-2
View File
@@ -11,7 +11,6 @@ type ProjectFlock struct {
FlockName string `gorm:"type:varchar(255);not null;uniqueIndex"` FlockName string `gorm:"type:varchar(255);not null;uniqueIndex"`
AreaId uint `gorm:"not null"` AreaId uint `gorm:"not null"`
Category string `gorm:"type:varchar(20);not null"` Category string `gorm:"type:varchar(20);not null"`
FcrId uint `gorm:"not null"`
ProductionStandardId uint `gorm:"column:production_standard_id"` ProductionStandardId uint `gorm:"column:production_standard_id"`
LocationId uint `gorm:"not null"` LocationId uint `gorm:"not null"`
CreatedBy uint `gorm:"not null"` CreatedBy uint `gorm:"not null"`
@@ -20,7 +19,6 @@ type ProjectFlock struct {
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Area Area `gorm:"foreignKey:AreaId;references:Id"` Area Area `gorm:"foreignKey:AreaId;references:Id"`
Fcr Fcr `gorm:"foreignKey:FcrId;references:Id"`
ProductionStandard ProductionStandard `gorm:"foreignKey:ProductionStandardId;references:Id"` ProductionStandard ProductionStandard `gorm:"foreignKey:ProductionStandardId;references:Id"`
Location Location `gorm:"foreignKey:LocationId;references:Id"` Location Location `gorm:"foreignKey:LocationId;references:Id"`
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
+5 -4
View File
@@ -10,8 +10,9 @@ type ProjectFlockKandang struct {
ClosedAt *time.Time `gorm:"index"` ClosedAt *time.Time `gorm:"index"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
ProjectFlock ProjectFlock `gorm:"foreignKey:ProjectFlockId;references:Id"` ProjectFlock ProjectFlock `gorm:"foreignKey:ProjectFlockId;references:Id"`
Kandang Kandang `gorm:"foreignKey:KandangId;references:Id"` Kandang Kandang `gorm:"foreignKey:KandangId;references:Id"`
Chickins []ProjectChickin `gorm:"foreignKey:ProjectFlockKandangId;references:Id"` Chickins []ProjectChickin `gorm:"foreignKey:ProjectFlockKandangId;references:Id"`
LatestApproval *Approval `gorm:"-" json:"-"` LatestProjectFlockApproval *Approval `gorm:"-" json:"-"`
LatestChickinApproval *Approval `gorm:"-" json:"-"`
} }
+1
View File
@@ -21,6 +21,7 @@ type PurchaseItem struct {
Price float64 `gorm:"type:numeric(15,3);default:0"` Price float64 `gorm:"type:numeric(15,3);default:0"`
TotalPrice float64 `gorm:"type:numeric(15,3);default:0"` TotalPrice float64 `gorm:"type:numeric(15,3);default:0"`
ExpenseNonstockId *uint64 ExpenseNonstockId *uint64
HasChickin bool `gorm:"-" json:"-"`
// Relations // Relations
ExpenseNonstock *ExpenseNonstock `gorm:"foreignKey:ExpenseNonstockId;references:Id"` ExpenseNonstock *ExpenseNonstock `gorm:"foreignKey:ExpenseNonstockId;references:Id"`
+8 -6
View File
@@ -12,14 +12,16 @@ type Recording struct {
RecordDatetime time.Time `gorm:"column:record_datetime;not null"` RecordDatetime time.Time `gorm:"column:record_datetime;not null"`
Day *int `gorm:"column:day"` Day *int `gorm:"column:day"`
TotalDepletionQty *float64 `gorm:"column:total_depletion_qty"` TotalDepletionQty *float64 `gorm:"column:total_depletion_qty"`
TotalDepletionCumQty *float64 `gorm:"-"`
CumDepletionRate *float64 `gorm:"column:cum_depletion_rate"` CumDepletionRate *float64 `gorm:"column:cum_depletion_rate"`
DepletionRate *float64 `gorm:"-"`
CumIntake *int `gorm:"column:cum_intake"` CumIntake *int `gorm:"column:cum_intake"`
FcrValue *float64 `gorm:"column:fcr_value"` FcrValue *float64 `gorm:"column:fcr_value"`
TotalChickQty *float64 `gorm:"column:total_chick_qty"` TotalChickQty *float64 `gorm:"column:total_chick_qty"`
HandDay *float64 `gorm:"column:hand_day"` HenDay *float64 `gorm:"column:hen_day"`
HandHouse *float64 `gorm:"column:hand_house"` HenHouse *float64 `gorm:"column:hen_house"`
FeedIntake *float64 `gorm:"column:feed_intake"` FeedIntake *float64 `gorm:"column:feed_intake"`
EggMesh *float64 `gorm:"column:egg_mesh"` EggMass *float64 `gorm:"column:egg_mass"`
EggWeight *float64 `gorm:"column:egg_weight"` EggWeight *float64 `gorm:"column:egg_weight"`
CreatedBy uint `gorm:"column:created_by"` CreatedBy uint `gorm:"column:created_by"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
@@ -34,11 +36,11 @@ type Recording struct {
LatestApproval *Approval `gorm:"-" json:"-"` LatestApproval *Approval `gorm:"-" json:"-"`
StandardHandDay *float64 `gorm:"-"` StandardHenDay *float64 `gorm:"-"`
StandardHandHouse *float64 `gorm:"-"` StandardHenHouse *float64 `gorm:"-"`
StandardFeedIntake *float64 `gorm:"-"` StandardFeedIntake *float64 `gorm:"-"`
StandardMaxDepletion *float64 `gorm:"-"` StandardMaxDepletion *float64 `gorm:"-"`
StandardEggMesh *float64 `gorm:"-"` StandardEggMass *float64 `gorm:"-"`
StandardEggWeight *float64 `gorm:"-"` StandardEggWeight *float64 `gorm:"-"`
StandardFcr *float64 `gorm:"-"` StandardFcr *float64 `gorm:"-"`
} }
+6 -4
View File
@@ -1,10 +1,12 @@
package entities package entities
type RecordingDepletion struct { type RecordingDepletion struct {
Id uint `gorm:"primaryKey"` Id uint `gorm:"primaryKey"`
RecordingId uint `gorm:"column:recording_id;not null;index"` RecordingId uint `gorm:"column:recording_id;not null;index"`
ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"` ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"`
Qty float64 `gorm:"column:qty;not null"` SourceProductWarehouseId *uint `gorm:"column:source_product_warehouse_id"`
Qty float64 `gorm:"column:qty;not null"`
PendingQty float64 `gorm:"column:pending_qty"`
Recording Recording `gorm:"foreignKey:RecordingId;references:Id"` Recording Recording `gorm:"foreignKey:RecordingId;references:Id"`
ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"` ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"`
+3
View File
@@ -7,11 +7,14 @@ type RecordingEgg struct {
RecordingId uint `gorm:"column:recording_id;not null;index"` RecordingId uint `gorm:"column:recording_id;not null;index"`
ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"` ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null"`
Qty int `gorm:"column:qty;not null"` Qty int `gorm:"column:qty;not null"`
TotalQty float64 `gorm:"column:total_qty"`
TotalUsed float64 `gorm:"column:total_used"`
Weight *float64 `gorm:"column:weight"` Weight *float64 `gorm:"column:weight"`
CreatedBy uint `gorm:"column:created_by"` CreatedBy uint `gorm:"column:created_by"`
CreatedAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"`
ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"` ProductWarehouse ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"`
ProductFlagName *string `gorm:"->;column:product_flag_name" json:"-"`
CreatedUser *User `gorm:"foreignKey:CreatedBy;references:Id"` CreatedUser *User `gorm:"foreignKey:CreatedBy;references:Id"`
Recording Recording `gorm:"foreignKey:RecordingId;references:Id"` Recording Recording `gorm:"foreignKey:RecordingId;references:Id"`
} }
+1
View File
@@ -9,6 +9,7 @@ type StockLog struct {
Increase float64 `gorm:"column:increase;type:numeric(15,3);default:0"` Increase float64 `gorm:"column:increase;type:numeric(15,3);default:0"`
Decrease float64 `gorm:"column:decrease;type:numeric(15,3);default:0"` Decrease float64 `gorm:"column:decrease;type:numeric(15,3);default:0"`
Stock float64 `gorm:"column:stock;type:numeric(15,3);not null;default:0"`
LoggableType string `gorm:"column:loggable_type;type:varchar(50);not null"` LoggableType string `gorm:"column:loggable_type;type:varchar(50);not null"`
LoggableId uint `gorm:"column:loggable_id;not null"` LoggableId uint `gorm:"column:loggable_id;not null"`
+1 -1
View File
@@ -6,7 +6,7 @@ import "time"
type StockTransferDelivery struct { type StockTransferDelivery struct {
Id uint64 `gorm:"primaryKey;autoIncrement"` Id uint64 `gorm:"primaryKey;autoIncrement"`
StockTransferId uint64 StockTransferId uint64
SupplierId uint64 SupplierId *uint64
VehiclePlate string VehiclePlate string
DriverName string DriverName string
DocumentNumber string DocumentNumber string
+8 -13
View File
@@ -8,27 +8,22 @@ type StockTransferDetail struct {
StockTransferId uint64 StockTransferId uint64
ProductId uint64 ProductId uint64
// === FIFO FIELDS - SOURCE WAREHOUSE (Usable) ===
// Tracking stock yang DIAMBIL dari source warehouse
SourceProductWarehouseID *uint64 `gorm:"column:source_product_warehouse_id"` SourceProductWarehouseID *uint64 `gorm:"column:source_product_warehouse_id"`
UsageQty float64 `gorm:"column:usage_qty;default:0"` // Actual yang berhasil diambil UsageQty float64 `gorm:"column:usage_qty;default:0"` // Actual yang berhasil diambil
PendingQty float64 `gorm:"column:pending_qty;default:0"` // Yang pending (nunggu stock) PendingQty float64 `gorm:"column:pending_qty;default:0"` // Yang pending (nunggu stock)
DestProductWarehouseID *uint64 `gorm:"column:dest_product_warehouse_id"`
// === FIFO FIELDS - DESTINATION WAREHOUSE (Stockable) === TotalQty float64 `gorm:"column:total_qty;default:0"` // Total lot yang tersedia
// Tracking stock yang DITAMBAHKAN ke destination warehouse TotalUsed float64 `gorm:"column:total_used;default:0"` // Yang sudah dipakai dari lot ini
DestProductWarehouseID *uint64 `gorm:"column:dest_product_warehouse_id"` ExpenseNonstockId *uint64 `gorm:"column:expense_nonstock_id"`
TotalQty float64 `gorm:"column:total_qty;default:0"` // Total lot yang tersedia CreatedAt time.Time
TotalUsed float64 `gorm:"column:total_used;default:0"` // Yang sudah dipakai dari lot ini UpdatedAt time.Time
DeletedAt *time.Time `gorm:"index"`
// === METADATA ===
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `gorm:"index"`
// === RELATIONS === // === RELATIONS ===
StockTransfer *StockTransfer `gorm:"foreignKey:StockTransferId"` StockTransfer *StockTransfer `gorm:"foreignKey:StockTransferId"`
Product *Product `gorm:"foreignKey:ProductId"` Product *Product `gorm:"foreignKey:ProductId"`
SourceProductWarehouse *ProductWarehouse `gorm:"foreignKey:SourceProductWarehouseID"` SourceProductWarehouse *ProductWarehouse `gorm:"foreignKey:SourceProductWarehouseID"`
DestProductWarehouse *ProductWarehouse `gorm:"foreignKey:DestProductWarehouseID"` DestProductWarehouse *ProductWarehouse `gorm:"foreignKey:DestProductWarehouseID"`
ExpenseNonstock *ExpenseNonstock `gorm:"foreignKey:ExpenseNonstockId;references:Id"`
DeliveryItems []StockTransferDeliveryItem `gorm:"foreignKey:StockTransferDetailId"` DeliveryItems []StockTransferDeliveryItem `gorm:"foreignKey:StockTransferDetailId"`
} }

Some files were not shown because too many files have changed in this diff Show More