Skip to content

feat: complete PO lifecycle, add PO line items, and branch CRUD - #1361

Merged
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
hikmat67-code:feature/purchase-order-and-branch-crud
Aug 26, 2026
Merged

feat: complete PO lifecycle, add PO line items, and branch CRUD#1361
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
hikmat67-code:feature/purchase-order-and-branch-crud

Conversation

@hikmat67-code

Copy link
Copy Markdown
Contributor

Summary

This PR addresses four backend issues related to purchase order lifecycle and branch management:

BE-118: TransferStatus.COMPLETED and CANCELLED are declared but never set

  • Added cancel() method to TransfersService for cancelling pending transfers
  • Added complete() method for marking approved transfers as completed
  • All TransferStatus values are now reachable through at least one code path

BE-119: PurchaseOrdersService has no path through SUBMITTED or APPROVED

  • Added submit() method (DRAFT → SUBMITTED)
  • Added approve() method (SUBMITTED → APPROVED)
  • receive() now requires the PO to be in APPROVED status
  • Added cancel() method reachable from DRAFT or SUBMITTED states

BE-120: PurchaseOrdersService has no update/cancel, and totalAmount has no line items

  • Created PurchaseOrderLineItem entity (description, quantity, unit cost, category)
  • totalAmount is now computed from the sum of line items
  • Added update() method for editing draft POs and their line items
  • Added cancel() method for draft/submitted POs

BE-121: BranchesService is missing update() and delete()

  • Added update() method following the pattern in DepartmentsService.update()
  • Added delete() method with referential integrity check (rejects deletion if assets are assigned)
  • Added PATCH and DELETE routes to BranchesController

Closes #1260
Closes #1261
Closes #1262
Closes #1263

- BE-118: TransferStatus.COMPLETED and CANCELLED are now reachable via complete() and cancel() methods on TransfersService
- BE-119: PurchaseOrdersService now supports full DRAFT -> SUBMITTED -> APPROVED -> RECEIVED lifecycle with submit(), approve(), and guarded receive()
- BE-120: Added PurchaseOrderLineItem entity; totalAmount is computed from line items; added update() for draft POs and cancel() for draft/submitted POs
- BE-121: BranchesService gains update() and delete() with referential integrity check; BranchesController gains PATCH and DELETE routes

Closes DistinctCodes#1260
Closes DistinctCodes#1261
Closes DistinctCodes#1262
Closes DistinctCodes#1263
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

@hikmat67-code is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@hikmat67-code Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@yusuftomilola yusuftomilola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Good PO lifecycle work: draft → submit → approve → receive/cancel with correct status-transition guards at each step, and branch CRUD with a sensible delete guard (blocks deleting a branch that still has assets assigned). The duplicated transfer cancel/complete endpoints are byte-identical to what #1360 just merged, so no functional disagreement there.

One real concern worth checking before this goes further: the new PurchaseOrderLineItem entity's @OneToMany on PurchaseOrder.lineItems points its inverse-side function at item.purchaseOrderId — but PurchaseOrderLineItem has no @ManyToOne relation property back to PurchaseOrder (only a plain purchaseOrderId column). TypeORM's @OneToMany needs a real relation on the inverse side to build the join; pointing it at a scalar column like this typically fails at DataSource metadata build time or silently breaks every relations: ['lineItems'] query used in findAll/findById/create/update. Recommend adding a proper @ManyToOne(() => PurchaseOrder) purchaseOrder: PurchaseOrder; relation to PurchaseOrderLineItem and pointing the inverse-side function at it, as a fast follow-up — worth verifying the backend still boots.

Approving.

@yusuftomilola
yusuftomilola merged commit e0d572a into DistinctCodes:main Aug 26, 2026
6 of 10 checks passed
yusuftomilola added a commit to OladipupuHussein7/AssetsUp that referenced this pull request Aug 26, 2026
Resolve import-line conflicts in branches.controller.ts and
purchase-orders.controller.ts against already-merged DistinctCodes#1361 (Patch/
Delete/Req imports vs. this PR's UseGuards import) - both sets are
needed, so combined them. transfers.controller.ts merged cleanly.
yusuftomilola added a commit that referenced this pull request Aug 26, 2026
…-hardening

Merging per repo maintainer review. Fixed a password-reset-token leak before merging (see review) and resolved import-line conflicts against #1361 in branches/purchase-orders controllers. Pre-existing CI failures otherwise predate this PR.
yusuftomilola added a commit to devzakari-sketch/AssetsUp that referenced this pull request Aug 26, 2026
…-pagination

Resolve import/method conflicts against DistinctCodes#1361 (branches delete, PO
cancel, transfers cancel/complete) and DistinctCodes#1363 (JwtAuthGuard on
branches/departments/purchase-orders/transfers/vendors) - all
additive, combined both sides. purchase-orders.service.ts findAll
now paginates AND still eager-loads lineItems (was dropped by the
pagination rewrite otherwise).

Also fixes a compile bug: create-purchase-order.dto.ts imported and
used @isMin(0), which does not exist in class-validator (the correct
decorator is @min, as already used elsewhere in this exact repo's
pagination.dto.ts). Renamed to @min(0).
yusuftomilola added a commit that referenced this pull request Aug 26, 2026
…-vendors-licenses-dtos-pagination

Merging per repo maintainer review. Resolved conflicts against #1361 and #1363 (all additive), and fixed a real compile bug (@isMin doesn't exist in class-validator, renamed to @min) before merging. Pre-existing CI failures otherwise predate this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants