Life ConnectLife Connect
Wiki index
Architecture
Services
Concepts
Runbooks
Infra
Swagger Docs
GitHub
Wiki index
Architecture
Services
Concepts
Runbooks
Infra
Swagger Docs
GitHub
  • Archive
  • Data Dictionary
  • Functional Epics

    • DICTIONARY OF ATTRIBUTES
    • Search Condos
    • Display

      • DisplayAll

        • Display all - Contracts
        • Display all - invoices
        • Display all - parts
        • Display all - Persons Relationships
        • Display all - Persons
        • Display tickets
      • DisplayContract

        • Display bank account Contract
        • Display Condo Member Contract
        • Display contact contract
        • Display Employee Contract
        • Display Generic Contract
        • Display Insurance Contract
        • Display Legal Represent Contract
        • Display Oral Contract
        • Display Owner Contract
        • Display Condo Regulation Contract
        • Display rental Contract
        • Display Supplier Contract
        • Display Trustee Contract
      • DisplayDelegate

        • Display Delegate
      • DisplayHistory

        • Display history
      • DisplayPerson

        • Display Company Person
        • Display Condo Person
        • Display Division Person
        • Display Group Person
        • Display Indivision Person
        • Display Natural Person
        • Display Union Person
        • Display Unknown Person
      • DisplayPersonsContracts

        • Display all Interventions
      • DisplayProperty

        • Display part
        • Display part
      • UiPerson

        • Display "mini" Persons
    • Process

      • Create

        • Create property & condo
      • Delete

        • Delete objects according to state machine
      • RC Renewal

        • RC RESIDENTIAL - automatic renewal
      • Review

        • rent amount review - RC residential - creation
        • rent amount review - RC residential - take-over
      • Sell

        • Sell a unit
    • Reporting

      • GRR

        • GLOBAL RENT REPORT
    • Search

      • Search
    • StateMachine

      • CreatingContract

        • State machine - creating a rental contract
        • State machine - creating a rental delegate contract
        • State machine - Referencing a abstract part contract
        • State machine - Referencing a bank contract
        • State machine - Referencing a condo regulation contract
        • State machine - Referencing a contact contract
        • State machine - Referencing an employee contract
        • State machine - Referencing a generic contract
        • State machine - Referencing a legal represent contract
        • State machine - Referencing a owner contract
        • State machine - Referencing a rental contract
        • State machine - Referencing a supplier contract
        • State machine - Referencing a trustee contract
      • CreatingIntervention

        • State machine - creating a ticket
        • State machine - Referencing a message
      • CreatingInvoice

        • State machine - creating a incoming (supplier) invoice
      • CreatingPayments

        • State machine - creating an incoming payment
      • EncodingPart

        • CreatingPart

          • State machine - Referencing part relationships
          • State machine - Referencing a part
      • EncodingPerson

        • CreatingAddresses

          • State machine - Creating email address
          • State machine - Creating phone address
          • State machine - Creating postal address
          • State machine - Creating web address
        • CreatingPerson

          • State machine - Referencing a company person
          • State machine - Referencing a condo person
          • State machine - Referencing a division person
          • State machine - Referencing an group person
          • State machine - Referencing an indivision person
          • State machine - Referencing a natural person
          • State machine - Referencing a union person
        • CreatingShareHolders

          • State machine - valuing a shareholder
      • Scanning

        • State machine scanning - analyze a document
        • State machine scanning - matching a document
        • State machine scanning - encoding a document : related information
    • Utility

      • Allocation keys
      • Company settings
      • Document data & file
      • Revision Index
    • Validations

      • Shareholders validation
  • Implicit

    • Callback

      • Logging In
  • ProductBoard

    • Rental Process

      • Rental delegate process
    • Ticketing

      • Create a ticket - link a ticket in Outlook add-in - add a call - display a ticket
      • Display Person Info in Outlook add-in
  • Technical Epics

    • Indexation Feature Documentation
    • Rent Amount Management Feature Documentation
    • I have an API
    • I can store the balance of an account
    • I Have Person Notifications
    • 🧩 System Process Diagrams
    • The Team has a DEV environment
    • The Team is organized
    • Accounting

      • Re-generation of Invoices
      • I can call the rent for my Rental Contract
      • Payment Creation Strategy Feature Documentation
      • I Can Revese

        • Payment Reversal
      • I Have Invoices

        • I have direction on invoice's item level
      • I Have Subsidies

        • I Can Receive Family Allowance Payments - Technical Documentation
        • Subsidies + Direct Debit Documentation
    • Communication Module

      • Communication module
    • Contracts

      • I can have contract guarantors
      • API Models
      • I Have Call For Rent Process

        • Call For Rent (CFR) Process Documentation
      • Occupancy Compensation

        • **OCCUPANCY COMPENSATION Documentation**
      • State Machine

        • I can have the Rental Contract state machine
    • Database

      • Database Indexes
    • E2e Testing

      • I can create an E2E dataset
    • Env Setup

      • Adapt env to stateless UI build
      • Blockhound
      • Table of Environments and Their Specifications
      • Environment How-To
      • Java Flight Recorder Management Documentation
      • Local Environment Setup
      • Kubernetes Logs Retrieval Documentation
      • Monitoring
      • I can create a new organisation
      • Production Environment Configuration
      • Remote Environment Setup
      • Set up of separate DB for env
      • Terraform Aws S3 Buckets
      • adb-ui Service Version Update
    • Files

      • I can have tags for files
    • Globals

      • boundaries
      • boundaries
      • boundaries
      • boundaries
    • Messaging

      • MongoDB Trigger Model Documentation
    • Open Api

      • Swagger Documentation Guide
      • Swagger
    • Parts

      • I Have A Forecast And Actuals Module
      • I can have part equipments
    • Process

      • Pre-Meeting Questionnaire
      • I Can Release My Feature
    • Security

      • I can create and provision an organisation
      • a user is granted access to the application
    • Stress Test

      • Introduction
      • Reports

        • Introduction
        • Introduction
        • Introduction
        • Introduction
        • Introduction
        • Table of contents
    • Tickets

      • Ticket Details Functionality
    • Troubleshooting

      • Prometheus Memory Issue Handling
Last updated 2025-01-27⚠️ 1 year 4 months old — verify against current code before relying on details.

Re-generation of Invoices

The process includes two main steps: clean-up of old invoices and invoice creation using the new API.


Step 1: Invoice Clean-up (Script Execution)

Objective:
This step removes invoices with the INVOICE_ORIGIN.CALL_FOR_RENT and INVOICE_ORIGIN.INSURANCE origins that have already been processed.

Script Execution:
The script performs the following tasks:

let invoices = db.getSiblingDB("adb-accounting").getCollection('invoices');
let events = db.getSiblingDB("adb-accounting").getCollection('accounting_event');
let entries = db.getSiblingDB("adb-accounting").getCollection('domain_object_accounting_entry');

var organisationId = "62d4ffdd0fa1798e82091168";
var invoiceOrigin = "INVOICE_ORIGIN.CALL_FOR_RENT"; //Available: INVOICE_ORIGIN.CALL_FOR_RENT, INVOICE_ORIGIN.INSURANCE
var removeProcessedInvoices = false;

// Find invoices that need to be cleaned up
invoices.find({
    "organisationId": organisationId,
    "invoiceOrigin": invoiceOrigin,
    "invoiceNature": "INVOICE_NATURE.HEADER"
})
    .forEach(header => {
        // Check if the invoice is processed and has a transactionId
        if (header.state == 'PROCESSED' && header.transactionId && removeProcessedInvoices === true) {
            // Find related accounting events
            events.find({
                "$or": [
                    {"_id": ObjectId(header.transactionId)}, // Match events with the same transactionId
                    {"parent._id": ObjectId(header.transactionId)} // Match events with the parentId equal to transactionId
                ]
            }).forEach(event => {
                // If event is processed and has a transactionId, delete related accounting entries
                if (event.state == 'PROCESSED' && event.transactionId) {
                    entries.deleteMany({"transactionId": event.transactionId});
                }
                // Delete the event from the events collection
                events.deleteOne({"_id": event._id});
            })
        }

        // Delete all child invoices related to the header
        invoices.deleteMany({"parentId": header._id});
        // Delete the invoice header itself
        invoices.deleteOne({"_id": header._id});
    });

Explanation of the Script

1. Identifying Invoices to Delete:

  • The script identifies invoices from the invoices collection with the specified organisationId, invoiceOrigin ( either INVOICE_ORIGIN.CALL_FOR_RENT or INVOICE_ORIGIN.INSURANCE), and invoiceNature as INVOICE_NATURE.HEADER.

2. Processing Each Invoice Header:

  • For each invoice header, the script checks:
    • If the invoice state is PROCESSED and it has a transactionId.

3. Removing Related Events and Entries:

  • For each PROCESSED invoice header with a transactionId:
    • The script deletes related events from the accounting_event collection that match the transactionId or its parent transactionId.
    • It also deletes accounting entries from the domain_object_accounting_entry collection linked to the transactionId.

4. Deleting Invoices:

  • Deletes all child invoices (where the parentId matches the header._id).
  • Deletes the invoice header from the invoices collection.

Invoice Origins for Deletion:

  • INVOICE_ORIGIN.CALL_FOR_RENT
  • INVOICE_ORIGIN.INSURANCE

Step 2: Create New Invoices via Technical API

Objective:

This step re-generates invoices using the new technical API endpoint.

API Endpoint:

POST /adb-accounting/accounting/invoices/creation

Request Body:

The API requires the following fields in the request body:

{
"origin": "CALL_FOR_RENT", // Available: INSURANCE, CALL_FOR_RENT
"callForRentPeriod": "2025-02", // Period for the call-for-rent invoice
"rentalDelegateContractId": "62d51bcf89483a34a515267b", // Optional, can be null if not relevant
"rentalContractId": null // Optional, can be null if not relevant
}

Execution

1. Open Postman and navigate to the following collection:

  • ADB-2.0 E2E API tests [development]
  • ADB-2.0-ACCOUNTING-E2E
  • I can generate invoices
  • I can generate invoices by a request

2. Send a POST request to the API endpoint /adb-accounting/accounting/invoices/creation with the required JSON body.

3. The system will re-generate the invoices based on the provided details.

Edit this page
Last Updated:
Contributors: Yevhenii Khudolii
Next
I can call the rent for my Rental Contract