This is a Django application intended to manage financial process and also share revenue between partners.
We have two ways to run the project, using docker or using poetry.
You will need to have docker and docker-compose installed in your machine.
make run-docker
OR
This guide is to setup project using poetry
with Python version 3.11.4 for the project.
optional: you can use docker files to get instances of database and application.
poetry
(version 1.5.1) with Python 3.11.4One dependency of poetry is pyenv
.
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev git
pyenv
(Same for Linux and Mac)git clone https://github.com/pyenv/pyenv.git ~/.pyenv
if [ -n "$ZSH_VERSION" ]; then
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.zshrc
else
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
fi
poetry
Linuxcurl -sSL https://install.python-poetry.org | python3 -
poetry
MacOSbrew install poetry
Navigate to the folder project and execute:
pyenv install 3.11.4
pyenv local 3.11.4
poetry env use 3.11.4
poetry env use -- $HOME/.pyenv/versions/3.11.4/bin/python
# Activate the virtual environment
poetry shell
To start the application outside docker, execute the next command inside a virtual environment. This will start all the dependencies services on each docker container and the application directly on the host using the development server:
make run
To start the app and its dependencies on docker, on development mode, run:
make run-docker
You have to install the app package dependencies and run the migrations.
make install-packages migrate
To check if everything is ok and running using the production mode of the docker images, we have a
wait to run the application on production mode.
This will use the docker target production
of the docker application image.
DOCKER_TARGET=production make run-docker
This project uses the Django Rest Framework using a token approach for authentication.
The important API are:
You can view the API documentation on:
To generate a token for local development you should use one of this two commands:
This will create a token for admin
user.
make create-token
python manage.py createsuperuser --noinput --username <username> --email <email>
python manage.py drf_create_token <username>
In Headers of request you need to declare a key 'Authorization' with the value 'Token generated_token'
Here is a example:
headers = { "Authorization": "Token generated_token" }
# TODO: Automate this installation after validation of method and structure
Error:
org.freedesktop.DBus.Error.UnknownMethod] ('No such interface “org.freedesktop.DBus.Properties
Solution:
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
python manage.py retry_failed_transactions
This command triggers the export of all the transactions splitted based on the given parameters.
python manage.py export_split_revenue {start_date} {end_date} --product_id={product_id} --organization_code={organization_code}
python manage.py export_split_revenue 2023-12-01 2024-01-01
This command triggers the export of all the transactions splitted based on the given parameters per organization.
To add more than one email as bcc, just open a string and add the emails.
python manage.py export_split_revenue_per_organizations {start_date} {end_date} --send_email={send_email} --bcc="{bcc1 bcc2}"
python manage.py export_split_revenue_per_organizations 2023-12-01 2024-01-01 --send_email=true --bcc="bcc1@email.com bcc2@email.com"
To create missing SageX3TransactionInformation
objects that for a bug hasn't been created.
from apps.billing.models import SageX3TransactionInformation, Transaction
transactions = Transaction.objects.all()
for t in transactions:
SageX3TransactionInformation.objects.get_or_create(transaction=t)