A Python implementation of a COBOL accounting system with Golden Master testing
Project description
Modernizing a Cobol accounting system to a Node.js application using GitHub Copilot
This repo contains COBOL code for a simple accounting system. You can use GitHub Copilot to transform this code to a Node.js accounting system.
Note: Keep in mind GitHub Copilot is an AI pair programmer that helps you write code. It is not a code generator and is using generative models trained on public code. It may provide completions that are not perfect, safe, or otherwise suitable for production. Always review suggestions and take a trust but verify approach.
📦 Quick Installation via PyPI
Install the modernized COBOL accounting system directly from PyPI:
# Install the package
pip install legacy-cobol-modernization
# Run the application
legacy-accounting
Alternative Installation Methods
# Install with development tools
pip install legacy-cobol-modernization[dev]
# Install with testing tools only
pip install legacy-cobol-modernization[test]
# Install from source
git clone https://github.com/math974/modernize-legacy-cobol-app.git
cd modernize-legacy-cobol-app
pip install -e .
Usage After Installation
# Run the accounting system
legacy-accounting
# Or use the alternative command
cobol-accounting
Prerequisites
- Basic understanding of programming concepts.
- Basic understanding of the COBOL programming language.
- GitHub Copilot or GitHub Copilot Chat installed in your IDE or GitHub Codespace.
Setup the development environment
Option 1: Use an IDE that supports GitHub Copilot
- IDE options for both GitHub Copilot and Copilot Chat:
Visual Studio Code
Visual Studio
JetBrains IDE
For Visual Studio Code
- Install the GitHub Copilot and GitHub Copilot Chat extensions for Visual Studio Code.
- Install the COBOL extension for Visual Studio Code.
Option 2: Use a GitHub codespace
-
Create a new codespace in this repository.
-
The configuration for the codespace is already set up with the required extensions.
- GitHub Copilot
- GitHub Copilot Chat
- COBOL
- Markdown All in One
- Mermaid Markdown
- python
About the program
This COBOL program simulates an account management system. This program will involve multiple COBOL source files and perform various operations like crediting, debiting, viewing the balance, and even exiting the program. Here’s how you its structured:
- Main Program (main.cob): The main program will handle the user interface and call subprograms for different operations.
- Operations Program (operations.cob): This program will handle the actual operations like credit, debit, and view balance.
- Data Storage Program (data.cob): This program will manage the storage of the account balance.
Steps to Compile and Run the Program
- Option 1: Install COBOL compiler on MaC If you don't already have a COBOL compiler, you'll need to install one. Common COBOL compiler is GnuCOBOL: An open-source COBOL compiler. To Install , use brew:
brew install gnucobol
- Option 2: Open the terminal in the GitHub codespace or Ubuntu Linux system and run the following command to install the COBOL compiler:
sudo apt-get update && \
sudo apt-get install gnucobol
reference: gnucobol
- Compile, link and create executable: Link the object files together to create the final executable:
cobc -x main.cob operations.cob data.cob -o accountsystem
- Run the Program: Run the executable to start the account management system:
./accountsystem
Program Interaction Example
- Program starts with user input menu
--------------------------------
Account Management System
1. View Balance
2. Credit Account
3. Debit Account
4. Exit
--------------------------------
Enter your choice (1-4):
- User Chooses to View Balance:
Current balance: 1000.00
- User Chooses to Credit:
Enter credit amount:
200.00
Amount credited. New balance: 1200.00
- User Chooses to Debit:
Enter debit amount:
300.00
Amount debited. New balance: 900.00
- User Chooses to Exit:
Exiting the program. Goodbye!
Explanation
- main.cob: This is the main interface where users select operations.
- operations.cob: It handles specific operations such as viewing, crediting, and debiting the account balance.
- data.cob: This program acts as a simple data storage, handling reading and writing of the balance.
This multi-file structure introduces modularity, making it easier to manage and extend the program. Each file has a clear responsibility, and the program flow is driven by user interaction.
Data flow
@workspace can you create a sequence diagram of the app showing the data flow of the app. Please create this in mermaid format so that I can render this in a markdown file.
sequenceDiagram
participant User
participant MainProgram
participant Operations
participant DataProgram
User->>MainProgram: Start Application
MainProgram->>User: Display Menu
User->>MainProgram: Select Option (1-4)
alt View Balance
MainProgram->>Operations: CALL 'Operations' USING 'TOTAL'
Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE
DataProgram-->>Operations: RETURN FINAL-BALANCE
Operations->>User: DISPLAY "Current balance: " FINAL-BALANCE
end
alt Credit Account
MainProgram->>Operations: CALL 'Operations' USING 'CREDIT'
Operations->>User: DISPLAY "Enter credit amount: "
User->>Operations: Enter Amount
Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE
DataProgram-->>Operations: RETURN FINAL-BALANCE
Operations->>Operations: ADD AMOUNT TO FINAL-BALANCE
Operations->>DataProgram: CALL 'DataProgram' USING 'WRITE', FINAL-BALANCE
DataProgram-->>Operations: RETURN
Operations->>User: DISPLAY "Amount credited. New balance: " FINAL-BALANCE
end
alt Debit Account
MainProgram->>Operations: CALL 'Operations' USING 'DEBIT'
Operations->>User: DISPLAY "Enter debit amount: "
User->>Operations: Enter Amount
Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE
DataProgram-->>Operations: RETURN FINAL-BALANCE
alt Sufficient Funds
Operations->>Operations: SUBTRACT AMOUNT FROM FINAL-BALANCE
Operations->>DataProgram: CALL 'DataProgram' USING 'WRITE', FINAL-BALANCE
DataProgram-->>Operations: RETURN
Operations->>User: DISPLAY "Amount debited. New balance: " FINAL-BALANCE
else Insufficient Funds
Operations->>User: DISPLAY "Insufficient funds for this debit."
end
end
alt Exit Application
MainProgram->>MainProgram: MOVE 'NO' TO CONTINUE-FLAG
MainProgram->>User: DISPLAY "Exiting the program. Goodbye!"
end
Generate a test plan
@workspace The current Cobol app has no tests. Can you please create a test plan of current business logic that I can use to validate with business stakeholders about the current implementation.
Later I would like to use this test plan to create unit and integration tests in a node.js app. I am in the middle of transforming the current Cobol app to a node.js app.
The test plan should include the following:
1. Test Case ID
2. Test Case Description
3. Pre-conditions
4. Test Steps
5. Expected Result
6. Actual Result
7. Status (Pass/Fail)
8. Comments
Please create the test plan in a markdown table format. The test plan should cover all the business logic in the current Cobol app.
Note
You may still need follow up with another prompt to generate the markdown file format for the test plan.
Convert this to markdown syntax please to insert as a new file
Convert files using prompt engineering best practices
Create the Node.js project directory
mkdir node-accounting-app
cd node-accounting-app
Use GitHub Copilot to convert the files iteratively
Convert main.cob to main.js
Convert operations.cob to operations.js
Convert data.cob to data.js
Let's link all node.js files to work together in one accounting application, and then initialize, install dependencies, and run the application.
Initialize a new Node.js project
npm init -y
Install the Node.js app
npm install
Run the Node.js app
node main.js
Generate unit and integration tests
@workspace I would like to create unit and integration tests cases form the test plan mentioned in
#file:TESTPLAN.md file The node.js code is in node-accounting-app folder and I am looking to generate tests
for #file:operations.js file. Use a popular testing framework and also provide all the dependencies required to run the tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file legacy_cobol_modernization-1.0.4.tar.gz.
File metadata
- Download URL: legacy_cobol_modernization-1.0.4.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb134345190439d2ff6869730970af017964c055c60b57f519dbc9f961777b0f
|
|
| MD5 |
98dddf717e17c1fa5c92cd18b0df2b7d
|
|
| BLAKE2b-256 |
6850175e980542ed6766178c73a00bffe5826824890ea9738814a148db4eeb87
|
File details
Details for the file legacy_cobol_modernization-1.0.4-py3-none-any.whl.
File metadata
- Download URL: legacy_cobol_modernization-1.0.4-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f0bf6ce34223968273b5fcef0f740f04b8bfa28ae7541692bc7c6af7d90ab7f
|
|
| MD5 |
b704c78faaa3401249b38c11712a0da9
|
|
| BLAKE2b-256 |
d3f6a5a235337cef2fa950baaa92566387a02130744c3f64adcaa02ca045a354
|