Skip to main content

Contracts

Contracts handle relationships between customers, products, services, and accounting in Flux CRM. This module is a core component of the system, supporting workflows like contract creation, upgrades, and integration with other business processes.

Quick Overview

  • Core Features: Contract creation, management, tracking, upgrades, and duplication.
  • Key Integrations: Customers, products, accounting, notifications, and inventory.
  • Workflow: Draft → Active → Delivered/Completed → Archived.

Workflow

1. Contracts List

  • Purpose: Display all contracts.
  • Filters: Status, customer, date range, or contract type.

2. Creating a Contract

  • Steps:
    1. Select a customer.
    2. Add products/services.
    3. Define terms: start/end dates, delivery conditions, and special notes.
    4. Validate all required fields.
    5. Submit to create the contract.
  • Validation: Ensures required fields (e.g., customer, terms) are completed.
  • Integration: Automatically links to inventory and accounting modules.

3. Types of Contracts

Different contracts meet various business needs:

  • Sales Contracts: For purchasing physical products.
  • Service Contracts: For recurring or one-time services.
  • Project Contracts: For long-term, multi-phase projects.

4. Contract Details

  • Overview: Displays all key details for a contract:
    • Customer information
    • Products/services involved
    • Payment and balance details
    • Manufacturing and delivery status
  • Actions Available:
    • View details
    • Edit contracts
    • Upgrade or duplicate contracts
    • Delete contracts (permissions apply)
    • Modify status (e.g., "in progress", "completed")
    • Add notes or attachments

5. Updating Contracts

Contracts evolve through their lifecycle:

  • Update statuses as progress is made (e.g., delivery completed).
  • Adjust products/services based on changes.
  • Track all modifications in the contract history.

6. Upgrading/Duplicating Contracts

  • Upgrade Contracts: Modify an existing contract to add items, services, or terms.
  • Duplicate Contracts: Copy an existing contract as a template for a new one.

Integration with Other Modules

1. Customer Management

  • Contracts are directly linked to customer profiles.
  • Updates in contracts reflect in transaction histories.

2. Accounting

  • Contracts handle payment schedules, balances, and invoice generation.
  • Data is synchronized with the accounting module.

3. Product/Service Tracking

  • Changes in contracts (e.g., product substitutions) reflect in inventory management.
  • Service updates are logged and tracked.

4. Order Tracking

  • Tracks the lifecycle of products from order to delivery.
  • Ensures timely fulfillment based on contract terms.

Code Structure

Frontend (Vue.js)

  • Contracts List Page: Displays all contracts with filters and actions.
  • Create Contract Page: Form for adding customers, products, and terms.
  • Contract Details Page: View and update detailed contract information.
  • Contracts drafts page: Displays all contracts in draft, offer and offer_archived status.
  • Contract create page: Create and setup everything related a new contract.
  • Contract manage page: Contract manage interface.

Backend (Controllers and Functions)

Action Functions

  • createDraft(): Create a draft contract.
  • update(): Update a draft contract.
  • updateRightOfWithdrawal(): Update the right of withdrawal date for a contract.
  • create(): Validate and save a new contract.
  • upgrade(): Upgrade a contract to a new version.
  • duplicate(): Duplicate an existing contract.
  • edit(): Edit an existing contract.
  • cancel(): Cancel a contract.
  • delete(): Delete a contract.

Loader Functions

  • checkRequired(): Check if the required conditions are met for a given contract.
  • getDraftContracts(): Fetch all draft contracts.
  • connectedContracts(): Retrieve contracts linked to a specific one.
  • customerContracts(): Retrieve contracts for a customer.
  • contract(): Fetch contract details.
  • checkIsDraft(): Check if a contract is not in a draft-related status.
  • contractDetailOptions(): Retrieve contract detail options for the active company.
  • contractHistory(): Retrieve and format the revision history of a specific contract.
  • contractProductsHistory(): Retrieve revision history for all products in a specific contract.
  • filterVue(): Retrieves all contracts for the list page.
  • search(): Retrieves all contracts for the list page according to the search_value input.

Helper Functions

  • loadNumbers(): Load the highest available free contract number for a branch.
  • addProductRemoveServices(): Add a product to the contract if none exists and remove associated services and items.
  • addServiceRemoveProducts(): Add a service to the contract if none exists and remove incomplete products and items.
  • addItemRemoveProducts(): Remove incomplete products and all services associated with a contract.
  • getOrCreateCustomer(): Retrieve an unused customer or create a new one for the current company.
  • contractSyncRelations(): Sync related data from one contract to another.
  • syncSpecialConditions(): Sync special conditions.
  • syncProducts(): Sync product data between contracts.
  • syncOrders(): Sync orders and related data.
  • syncDeductions(): Sync deductions.
  • syncVouchers(): Sync vouchers.
  • recreateProductParts(): Recreate product-part relationships for a new contract.
  • checkAndFixVAT(): Ensure VAT compliance for contract items.
  • updateVATForRelation(): Update VAT for a given relationship.
  • errorChecks(): Perform error checks on various aspects of the contract.
  • getBaseContractFile(): Retrieve the base contract file from the contract's ancestors.
  • createOrUpdatePaymentHistory(): Create or update the payment history for a contract.
  • shouldUpdatePaymentHistoryName(): Determine if a payment history name should be updated.
  • setAncestorsUpgraded(): Mark all ancestors of a contract as upgraded and update their product statuses.
  • deleteDrafOrdersOfAncestors(): Delete draft orders associated with the products of a contract's ancestors.
  • informAccountantCancel(): Notify the accountant about a cancelled contract.

Routes

Web Routes

  • /contracts: Fetches the contracts list view.
  • /contracts/details: Displays details of a specific contract.
  • /contracts/drafts-offers: Shows draft contracts and offers.
  • /contracts/create: Opens the form to create a new contract.
  • /contracts/manage: Opens the contract management interface.

API Endpoints

GET

  • /contracts/search: Searches for contracts based on filters and criteria.
  • /contracts/offers: Retrieves offers related to contracts.
  • /contract/details: Fetches the detailed information of a specific contract.
  • /contract/check-is-draft: Checks if a contract is still in draft status.
  • /contracts/detail-options: Provides additional detail options for a contract.
  • /contracts-connected/by-contract: Retrieves contracts that are connected to a specific contract.
  • /contracts-create/get-drafts: Fetches draft contracts.
  • /contracts/filter: Filters contracts based on criteria (used in Vue.js).

POST

  • /contract/draft/create: Creates a draft contract.
  • /contract/create: Creates a new contract.
  • /contract/upgrade: Upgrades an existing contract (e.g., by adding services or products).
  • /contract/edit: Edits an existing contract.
  • /contract/cancel: Cancels a contract.
  • /contract/duplicate: Duplicates an existing contract.
  • /contract/update: Updates contract details (e.g., status, terms).

DELETE

  • /contract/delete: Deletes a contract.

Future Enhancements

  • Improved Reporting: Add analytics and dashboards for contracts.
  • Enhanced Notifications: Better customer and employee alerts for contract changes.
  • Streamlined Integrations: Deeper integration with suppliers and manufacturing.