| Server IP : 103.175.220.74 / Your IP : 216.73.216.151 Web Server : nginx/1.18.0 System : Linux p-floo-wj1-db 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : deploy ( 1003) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app/onega.id/erp/demo/ |
Upload File : |
# Purchase Module Analysis
## Module Overview
The Purchase module is a comprehensive procurement system that handles vendor management, purchase requisitions, purchase orders, goods receipts, and billing. It integrates with the Inventory module for stock tracking.
## Module Structure
```
Modules/Purchase/
├── Actions/
│ ├── GenerateProductCodeAction.php
│ ├── GenerateServiceCodeAction.php
│ ├── GenerateVendorCodeAction.php
│ ├── GenerateBarcodeAction.php
│ ├── Bill/
│ ├── PurchaseOrder/
│ └── PurchaseRequisition/
├── Entities/
│ ├── PurchaseOrder.php
│ ├── PurchaseOrderDetail.php
│ ├── PurchaseRequisition.php
│ ├── PurchaseRequisitionDetail.php
│ ├── Bill.php
│ ├── BillDetail.php
│ ├── BillAdjust.php
│ ├── BillPayment.php
│ ├── BillLog.php
│ ├── BillFile.php
│ ├── GoodsReceipt.php
│ ├── GoodsReceiptDetail.php
│ ├── Vendor.php
│ ├── Product.php
│ ├── Service.php
│ ├── Warehouse.php
│ ├── PaymentRecord.php
│ ├── Customer.php
│ ├── PurchaseOrderLog.php
│ └── BillFile.php
├── Http/
│ ├── Controllers/
│ │ ├── PurchaseController.php
│ │ ├── PurchaseOrderController.php
│ │ ├── PurchaseRequisitionController.php
│ │ ├── BillController.php
│ │ ├── VendorController.php
│ │ └── API/
│ ├── Requests/V1/
│ │ ├── PurchaseOrder/
│ │ └── PurchaseRequisition/
│ └── Resources/V1/
│ ├── PurchaseOrder/
│ └── PurchaseRequisition/
├── Routes/
│ ├── web.php
│ ├── api.php
│ └── mobile.php
├── Database/
│ └── Migrations/
├── Tests/
├── Providers/
│ ├── RouteServiceProvider.php
│ └── PurchaseServiceProvider.php
└── Config/config.php
```
## Entity Relationships Diagram
```mermaid
erDiagram
PURCHASE-REQUISITION ||--o{ PURCHASE-REQUISITION-DETAIL : contains
PURCHASE-REQUISITION ||--o{ PURCHASE-ORDER : creates
PURCHASE-REQUISITION }o--|| USER : "created_by"
PURCHASE-REQUISITION }o--|| DEPARTMENT : references
PURCHASE-REQUISITION }o--|| CUSTOMER : "pelanggan_id"
PURCHASE-REQUISITION }o--|| PRODUCT : includes
PURCHASE-ORDER ||--o{ PURCHASE-ORDER-DETAIL : contains
PURCHASE-ORDER }o--|| VENDOR : "from"
PURCHASE-ORDER }o--|| WAREHOUSE : "to"
PURCHASE-ORDER }o--|| STATUS : "status_id"
PURCHASE-ORDER }o--|| PURCHASE-REQUISITION : "references"
PURCHASE-ORDER }o--|| TAX : "tax_id"
PURCHASE-ORDER ||--o{ BILL : "po_number"
PURCHASE-ORDER ||--o{ GOODS-RECEIPT : "purchase_order_id"
PURCHASE-ORDER ||--o{ PURCHASE-ORDER-LOG : logs
PURCHASE-ORDER-DETAIL }o--|| PRODUCT : "product_id"
PURCHASE-ORDER-DETAIL }o--|| WAREHOUSE : "warehouse_id"
PURCHASE-ORDER-DETAIL }o--|| TAX : "tax_id"
BILL }o--|| VENDOR : "from"
BILL }o--|| STATUS : "status_id"
BILL ||--o{ BILL-DETAIL : contains
BILL ||--o{ BILL-ADJUST : adjustments
BILL ||--o{ BILL-PAYMENT : payments
BILL ||--o{ BILL-FILE : attachments
BILL ||--o{ BILL-LOG : logs
BILL }o--|| PURCHASE-ORDER : "po_number"
BILL-DETAIL }o--|| BILL : "bill_id"
BILL-DETAIL }o--|| PRODUCT : "product_id"
BILL-DETAIL }o--|| ACCOUNT : "expense_category_id"
BILL-PAYMENT }o--|| BILL : "bill_id"
GOODS-RECEIPT }o--|| PURCHASE-ORDER : "purchase_order_id"
GOODS-RECEIPT ||--o{ GOODS-RECEIPT-DETAIL : contains
GOODS-RECEIPT-DETAIL }o--|| PRODUCT : "product_id"
VENDOR ||--o{ PURCHASE-ORDER : "supplies"
VENDOR ||--o{ BILL : "sends"
VENDOR }o--|| PROVINCE : location
VENDOR }o--|| CITY : location
PRODUCT }o--|| VENDOR : "from"
SERVICE }o--|| VENDOR : "from"
WAREHOUSE }o--|| LOCATION : represents
PAYMENT-RECORD }o--|| BILL : tracks
```
## Core Workflows
### 1. Purchase Requisition Workflow
```
User Request → Create PR → Add PR Details → Submit → Approve → Create PO
```
### 2. Purchase Order Workflow
```
PO Creation (from PR or manual) → Add Details → Submit → Vendor Sends Goods → GR Creation → Match with PO
```
### 3. Goods Receipt Workflow
```
PO Dispatched → Goods Received → Create GR → Add GR Details → Match with PO Details → Confirm Receipt
```
### 4. Bill Processing Workflow
```
PO Created → Vendor Sends Bill → Create Bill → Add Bill Details → Adjustments (if needed) → Approve → Payment
```
## Key Entities Description
| Entity | Purpose | Key Fields |
|--------|---------|-----------|
| **PurchaseRequisition** | Request for purchasing goods/services | pr_number, pr_date, status, total |
| **PurchaseOrder** | Formal order sent to vendor | po_number, po_date, due_date, eta_date, vendor_id |
| **PurchaseOrderDetail** | Line items in PO | product_id, quantity, unit_price, tax |
| **Bill** | Vendor invoice | bill_number, bill_date, due_date, total_amount |
| **BillDetail** | Line items in bill | product_id, quantity, unit_price |
| **GoodsReceipt** | Record of received goods | purchase_order_id, receipt_date |
| **GoodsReceiptDetail** | Items received | product_id, quantity_received |
| **Vendor** | Supplier information | vendor_name, vendor_code, category, contact |
| **Product** | Purchasable products | name, code, vendor_id |
| **Warehouse** | Storage locations | name, address, location |
## Controllers
| Controller | Responsibilities |
|------------|------------------|
| **PurchaseController** | Main purchase module entry point |
| **PurchaseOrderController** | CRUD for POs, approvals, document generation |
| **PurchaseRequisitionController** | CRUD for PRs, status management |
| **BillController** | Bill management, payments, adjustments |
| **VendorController** | Vendor management, category management |
## Integration Points
- **Inventory Module**: GoodsReceipt integrates with inventory for stock updates
- **Accounting Module**: Bills linked to accounting entries via Account references
- **HR Module**: Department references for requisitions
- **Core App**: User, Status, Tax, Location (Province, City)
## Action Classes
- **GenerateProductCodeAction**: Auto-generates product codes
- **GenerateServiceCodeAction**: Auto-generates service codes
- **GenerateVendorCodeAction**: Auto-generates vendor codes
- **GenerateBarcodeAction**: Auto-generates barcodes
- **PurchaseOrder/Actions**: Actions for PO operations (create, duplicate, revert)
- **PurchaseRequisition/Actions**: Actions for PR operations (create, duplicate, revert)
- **Bill/Actions**: Actions for billing operations
## Status Flow
```
Purchase Requisition: Draft → Submitted → Approved → Rejected
Purchase Order: Draft → Sent → Confirmed → Received → Billed → Closed
Bill: Draft → Submitted → Approved → Paid → Archived
```
## Key Features
1. **Multi-step Purchase Process**: PR → PO → GR → Bill
2. **Vendor Management**: Master vendor data with categories and contact information
3. **Product/Service Catalog**: With vendor associations
4. **Bill Management**: With adjustments, payments, and file attachments
5. **Tax Handling**: Support for different tax formats and rates
6. **Document Generation**: PDF export for PRs, POs, and Bills
7. **Audit Trail**: Logging of all transactions and changes
8. **Warehouse Integration**: Track goods by warehouse location
9. **Payment Tracking**: Multiple payment records per bill
10. **Status Management**: Workflow states for all transaction types