Download the PHP package azaharizaman/nexus-sales without Composer
On this page you can find all versions of the php package azaharizaman/nexus-sales. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azaharizaman/nexus-sales
More information about azaharizaman/nexus-sales
Files in azaharizaman/nexus-sales
Package nexus-sales
Short Description Framework-agnostic sales management package for quotation-to-order lifecycle
License MIT
Informations about the package nexus-sales
Nexus\Sales
Framework-agnostic sales management package for quotation-to-order commercial contract lifecycle.
Overview
Nexus\Sales manages the complete sales process from quotation to order fulfillment, including:
- Sales Quotations: Price quotes with validity periods and versioning
- Sales Orders: Confirmed customer orders with payment terms and fulfillment tracking
- Pricing Engine: Multi-strategy pricing (list price, tiered discounts, customer-specific, promotional)
- Tax Calculation: Pluggable tax calculation interface
- Exchange Rate Locking: Foreign currency order protection
- Stock Reservation: Real-time inventory integration with automatic reservation
- Invoice Generation: Seamless integration with accounts receivable
- Credit Limit Checking: Real-time customer credit validation
- Sales Returns (RMA): Return order processing and validation
Key Features
1. Quotation-to-Order Workflow
Sales Order Workflow:
2. Pricing Strategies
- List Price: Standard price list pricing
- Tiered Discount: Quantity-based pricing tiers (matrix pricing foundation)
- Customer-Specific: Customer-negotiated pricing
- Promotional: Time-sensitive promotional campaigns
3. Integrated Services
The package includes the following production-ready services:
| Service | Purpose | Integration |
|---|---|---|
QuoteToOrderConverter |
Converts accepted quotes to sales orders | Nexus\Sequencing |
SalesOrderManager |
Full order lifecycle management | All packages |
ReceivableCreditLimitChecker |
Real-time credit limit validation | Nexus\Receivable |
SalesReturnManager |
Return order (RMA) processing | Nexus\Receivable (Phase 2) |
InventoryStockReservation |
Real-time stock reservation | Nexus\Inventory |
ReceivableInvoiceManager |
Invoice generation from orders | Nexus\Receivable |
4. Future-Proof Architecture
V1 includes schema fields for Phase 2 features:
- Recurring Subscriptions:
is_recurring,recurrence_rule(JSON) - Sales Commission:
salesperson_id,commission_percentage - Multi-Warehouse:
preferred_warehouse_id
All V1 stub implementations provide clear upgrade paths.
Installation
Dependencies
azaharizaman/nexus-party- Customer managementazaharizaman/nexus-product- Product catalogazaharizaman/nexus-uom- Unit of measurementazaharizaman/nexus-currency- Multi-currency supportazaharizaman/nexus-finance- Accounting integrationazaharizaman/nexus-sequencing- Auto-numberingazaharizaman/nexus-period- Fiscal period managementazaharizaman/nexus-audit-logger- Audit trailazaharizaman/nexus-inventory- Stock management (for InventoryStockReservation)azaharizaman/nexus-receivable- Accounts receivable (for credit checking and invoicing)
Architecture
This package follows the Nexus Atomic Package Pattern:
- NO Laravel dependencies - Pure PHP 8.3
- NO database schema - Contracts only
- NO Eloquent models - Entity interfaces only
- Framework-agnostic - Can run in any PHP application
Implementation is provided by apps/Atomy (Laravel orchestrator).
Quick Start Guide
Step 1: Create a Quotation
Step 2: Convert Quote to Order
Step 3: Confirm Order
The confirmation process performs three critical operations:
- Credit Limit Check - Validates customer has sufficient credit
- Stock Reservation - Reserves inventory for the order
- Exchange Rate Lock - Locks foreign currency rate (if applicable)
Step 4: Generate Invoice
Service Reference
QuoteToOrderConverter
Converts accepted quotations to sales orders, copying all line items, pricing, and customer information.
Location: src/Services/QuoteToOrderConverter.php
Constructor Dependencies:
QuotationRepositoryInterfaceSalesOrderRepositoryInterfaceSequenceGeneratorInterfaceTransactionManagerInterfaceAuditLogManagerInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
convertToOrder(string $quotationId, array $orderData = []): SalesOrderInterface |
Converts accepted quote to order |
canConvertToOrder(string $quotationId): bool |
Validates if quote can be converted |
SalesOrderManager
Manages the complete sales order lifecycle including creation, confirmation, shipping, invoicing, and cancellation.
Location: src/Services/SalesOrderManager.php
Constructor Dependencies:
SalesOrderRepositoryInterfaceSequenceGeneratorInterfaceExchangeRateServiceInterfaceCreditLimitCheckerInterfaceStockReservationInterfaceInvoiceManagerInterfaceAuditLogManagerInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
createOrder(string $tenantId, string $customerId, array $lines, array $data): SalesOrderInterface |
Creates a new draft order |
confirmOrder(string $orderId, string $confirmedBy): void |
Confirms order, checks credit, reserves stock |
cancelOrder(string $orderId, ?string $reason = null): void |
Cancels order and releases stock |
markAsShipped(string $orderId, bool $isPartialShipment = false): void |
Marks order as shipped |
generateInvoice(string $orderId): string |
Generates invoice from order |
findOrder(string $orderId): SalesOrderInterface |
Finds order by ID |
findOrdersByCustomer(string $tenantId, string $customerId): array |
Finds orders by customer |
ReceivableCreditLimitChecker
Integrates with Nexus\Receivable for real-time credit limit validation.
Location: src/Services/ReceivableCreditLimitChecker.php
Constructor Dependencies:
Nexus\Receivable\Contracts\CreditLimitCheckerInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
checkCreditLimit(string $tenantId, string $customerId, float $orderTotal, string $currencyCode): bool |
Validates customer credit limit |
Throws: CreditLimitExceededException when limit exceeded
SalesReturnManager
Handles return order (RMA) processing including validation and quantity checks.
Location: src/Services/SalesReturnManager.php
Constructor Dependencies:
SalesOrderRepositoryInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
createReturnOrder(string $salesOrderId, array $returnLineItems, string $returnReason): string |
Creates return order |
InventoryStockReservation
Integrates with Nexus\Inventory for real-time stock reservation.
Location: src/Services/InventoryStockReservation.php
Constructor Dependencies:
SalesOrderRepositoryInterfaceNexus\Inventory\Contracts\ReservationManagerInterfaceNexus\Inventory\Contracts\StockLevelRepositoryInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
reserveStockForOrder(string $salesOrderId): array |
Reserves stock for all order lines |
releaseStockReservation(string $salesOrderId): void |
Releases all reservations |
getOrderReservations(string $salesOrderId): array |
Gets active reservations |
checkStockAvailability(string $salesOrderId): StockAvailabilityResult |
Checks availability without reserving |
Throws: InsufficientStockException when stock unavailable
ReceivableInvoiceManager
Integrates with Nexus\Receivable for invoice generation.
Location: src/Services/ReceivableInvoiceManager.php
Constructor Dependencies:
SalesOrderRepositoryInterfaceNexus\Receivable\Contracts\ReceivableManagerInterfaceLoggerInterface
Methods:
| Method | Description |
|---|---|
generateInvoiceFromOrder(string $salesOrderId): string |
Generates invoice from sales order |
Pricing Engine
Matrix Pricing (Quantity Tiers)
The pricing engine supports quantity-based tiered pricing via dedicated price_tiers table:
Performance: SQL-based tier matching enables efficient queries:
Tax Calculation
V1 provides SimpleTaxCalculator with configurable flat tax rate.
Phase 2: Replace with tax jurisdiction engine for SST, VAT, GST compliance.
Exchange Rate Locking
For foreign currency orders, the exchange rate is locked at confirmation time:
Integration Points
Stock Reservation (Nexus\Inventory)
Production-ready via InventoryStockReservation:
Invoice Generation (Nexus\Receivable)
Production-ready via ReceivableInvoiceManager:
Credit Limit Checking (Nexus\Receivable)
Production-ready via ReceivableCreditLimitChecker:
Discount Rules
Time-sensitive promotional pricing:
Payment Terms
Standard payment terms with automatic due date calculation:
Exception Handling
All domain exceptions extend SalesException:
Audit Trail
All state changes are logged via Nexus\AuditLogger:
- Quotation sent to customer
- Quotation accepted/rejected
- Quotation converted to order
- Order confirmed (with locked exchange rate)
- Order shipped (partial/full)
- Order invoiced
- Order cancelled
- Return order created
- Stock reserved/released
Example audit log entry:
Testing
Future Enhancements (Phase 2)
-
Recurring Subscriptions
- Use
is_recurringandrecurrence_rulefields - Automatic renewal order generation
- Subscription lifecycle management
- Use
-
Sales Commission
- Track salesperson via
salesperson_id - Calculate commission via
commission_percentage - Commission payout integration
- Track salesperson via
-
Multi-Warehouse Fulfillment
- Route orders via
preferred_warehouse_id - Split shipments across warehouses
- Warehouse selection optimization
- Route orders via
-
Advanced Tax Engine
- Tax jurisdiction determination
- Multi-level tax (federal + state)
- Tax exemption certificates
- Reverse charge mechanism
- Advanced Sales Returns
- Credit note integration with Nexus\Receivable
- Restocking fee calculation
- Return quality inspection workflow
📖 Documentation
Package Documentation
- Getting Started Guide
- API Reference
- Integration Guide
- Examples
Additional Resources
IMPLEMENTATION_SUMMARY.md- Implementation progressREQUIREMENTS.md- RequirementsTEST_SUITE_SUMMARY.md- TestsVALUATION_MATRIX.md- Valuation
License
MIT License - see LICENSE file for details.
Support
For issues and questions, please use the GitHub issue tracker.