Skip to content
Snippets Groups Projects
models.py 4.01 KiB
"""Models for MEO DB tables and views."""
from django.db import models


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)
    cc_type = 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)
    nom_name = models.CharField(db_column="NomName", max_length=60, blank=True, null=True)
    nom_id = 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."""

    id = models.UUIDField(db_column="ID", primary_key=True)
    account_name = models.CharField(db_column="AccountName", max_length=60)
    account_number = models.CharField(db_column="AccountNumber", max_length=8, blank=True, null=True)
    account_cost_centre = models.CharField(db_column="AccountCostCentre", max_length=3, blank=True, null=True)
    account_department = 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."""

    supplier_account_number = models.CharField(db_column="SupplierAccountNumber", max_length=8, primary_key=True)
    supplier_account_name = 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)
    input_nominal_account = 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"