diff --git a/requirements.txt b/requirements.txt index 791ff6078582a2142929c798f615301afd50f385..09b5752550ec978f47d3412df6a9397f0895dda1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ mypy tox sphinx sphinx-autodoc-typehints +mssql-django diff --git a/sage_validation/file_validator/models.py b/sage_validation/file_validator/models.py index 5fd99e9ade91d0858b759177ff8c997fea2ef30a..0bc48ec3eb16cc8dad934cb145068fb76e8935ab 100644 --- a/sage_validation/file_validator/models.py +++ b/sage_validation/file_validator/models.py @@ -1 +1,141 @@ -"""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" diff --git a/sage_validation/settings.py b/sage_validation/settings.py index 5bf2163c0aa92aedb85e121d78796016554b88d2..9d508100b933598577dc26f8450229d7f1e13bcf 100644 --- a/sage_validation/settings.py +++ b/sage_validation/settings.py @@ -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