Skip to content
Snippets Groups Projects
Commit 56cb5df1 authored by Neda Moeini's avatar Neda Moeini
Browse files

Add Sage SQL Server DB as Read-Only Database and Create Django Models

parent 1a675a95
No related branches found
No related tags found
No related merge requests found
......@@ -4,3 +4,4 @@ mypy
tox
sphinx
sphinx-autodoc-typehints
mssql-django
"""Models for the file_validator app."""
"""Models for MEO DB tables and views."""
from django.db import models
class PlAccountCodes(models.Model):
"""Represents profit and loss (PL) account codes.
This model maps the PL account names to their respective codes.
"""
objects = None
pl_account_name = models.TextField(db_column="PL_Account_Name")
pl_account_code = models.CharField(db_column="PL_Account_Code", primary_key=True, max_length=50)
class Meta:
"""Metaclass for the PlAccountCodes model."""
managed = False
db_table = "PL_Account_Codes"
class Meocostcentres(models.Model):
"""Represents cost centres.
This model contains data related to cost centres,
including their names, types, and unique IDs.
"""
cc = models.CharField(db_column="CC", max_length=3)
cc_name = models.CharField(db_column="CC_Name", max_length=50, blank=True, null=True)
cctype = models.CharField(db_column="CCType", max_length=8)
id = models.IntegerField(db_column="ID", primary_key=True)
class Meta:
"""Metaclass for the Meocostcentres model."""
managed = False
db_table = "meoCostCentres"
class Meonominal(models.Model):
"""View for MEO nominal codes."""
nom = models.CharField(db_column="Nom", max_length=5)
nomname = models.CharField(db_column="NomName", max_length=60, blank=True, null=True)
nomid = models.IntegerField(db_column="NomID")
class Meta:
"""Metaclass for the Meonominal model."""
managed = False
db_table = "meoNominal"
class Meovalidsageaccounts(models.Model):
"""View for MEO valid Sage accounts."""
accountname = models.CharField(db_column="AccountName", max_length=60)
accountnumber = models.CharField(db_column="AccountNumber", max_length=8, blank=True, null=True)
accountcostcentre = models.CharField(db_column="AccountCostCentre", max_length=3, blank=True, null=True)
accountdepartment = models.CharField(db_column="AccountDepartment", max_length=3, blank=True, null=True)
class Meta:
"""Metaclass for the Meovalidsageaccounts model."""
managed = False
db_table = "meoValidSageAccounts"
class Meovalidsuppliers(models.Model):
"""View for MEO valid suppliers."""
supplieraccountnumber = models.CharField(db_column="SupplierAccountNumber", max_length=8)
supplieraccountname = models.CharField(db_column="SupplierAccountName", max_length=60)
class Meta:
"""Metaclass for the Meovalidsuppliers model."""
managed = False
db_table = "meoValidSuppliers"
class Meovalidvat(models.Model):
"""View for MEO valid VAT codes."""
tax_code = models.SmallIntegerField(db_column="Tax code")
tax_code_label = models.CharField(db_column="tax code label", max_length=60)
rate = models.DecimalField(db_column="Rate", max_digits=18, decimal_places=2)
inputnominalaccount = models.CharField(db_column="InputNominalAccount", max_length=8, blank=True, null=True)
class Meta:
"""Metaclass for the Meovalidvat model."""
managed = False
db_table = "meoValidVAT"
class VwPlAcctCodes(models.Model):
"""View for profit and loss account codes."""
pl_account_name = models.TextField(db_column="PL_Account_Name")
pl_account_code = models.CharField(db_column="PL_Account_Code", max_length=50)
class Meta:
"""Metaclass for the VwPlAcctCodes model."""
managed = False
db_table = "vw_PL_Acct_Codes"
class VwXxData(models.Model):
"""provides a read-only view of XX data entries.
The entries are typically used for categorizing costs and activities.
"""
description = models.CharField(db_column="Description", max_length=50)
xx_value = models.CharField(db_column="xx_Value", max_length=50)
project = models.SmallIntegerField(db_column="Project")
overhead = models.IntegerField(db_column="Overhead")
class Meta:
"""Meta class for the VwXxData model."""
managed = False
db_table = "vw_xx-data"
class XxData(models.Model):
"""Model for XX data entries."""
description = models.CharField(db_column="Description", max_length=50)
xx_value = models.CharField(db_column="xx_Value", primary_key=True, max_length=50)
project = models.SmallIntegerField(db_column="Project")
overhead = models.IntegerField(db_column="Overhead")
class Meta:
"""Metaclass for the XxData model."""
managed = False
db_table = "xx-data"
......@@ -78,7 +78,19 @@ DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
},
"meo": {
'ENGINE': 'mssql',
'NAME': os.getenv("MSSQL_DB_NAME", ""),
'USER': os.getenv("MSSQL_DB_USER", ""),
'PASSWORD': os.getenv("MSSQL_DB_PASSWORD", ""),
'HOST': os.getenv("MSSQL_DB_HOST", "localhost"),
'PORT': os.getenv("MSSQL_DB_PORT", ""),
'OPTIONS': {
'driver': 'ODBC Driver 18 for SQL Server',
},
},
}
# Password validation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment