From 5e91986bd2fa34fcecbb9be7d604f29005b0af97 Mon Sep 17 00:00:00 2001
From: Neda Moeini <neda.moeini@geant.org>
Date: Fri, 28 Feb 2025 14:41:50 +0100
Subject: [PATCH] Update the sphinx docs.

---
 docs/source/conf.py                  |  6 ++-
 docs/source/file_validator/forms.rst |  8 ++++
 docs/source/file_validator/index.rst | 10 +++++
 docs/source/file_validator/views.rst |  8 ++++
 docs/source/index.rst                | 12 ++----
 docs/source/validations.rst          | 63 ++++++++++++++++++++++++++++
 requirements.txt                     |  1 +
 7 files changed, 99 insertions(+), 9 deletions(-)
 create mode 100644 docs/source/file_validator/forms.rst
 create mode 100644 docs/source/file_validator/index.rst
 create mode 100644 docs/source/file_validator/views.rst
 create mode 100644 docs/source/validations.rst

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 5cb62b0..a7b6713 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -12,8 +12,12 @@
 #
 import os
 import sys
-sys.path.insert(0, os.path.abspath('../sage-validation'))
+import django
 
+sys.path.insert(0, os.path.abspath("../../"))
+sys.path.insert(0, os.path.abspath("../../sage_validation/"))
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sage_validation.settings")
+django.setup()
 
 # -- Project information -----------------------------------------------------
 
diff --git a/docs/source/file_validator/forms.rst b/docs/source/file_validator/forms.rst
new file mode 100644
index 0000000..9ec6c70
--- /dev/null
+++ b/docs/source/file_validator/forms.rst
@@ -0,0 +1,8 @@
+==========================================
+Sage Validation - File Validator Forms
+==========================================
+
+.. automodule:: file_validator.forms
+   :members:
+   :undoc-members:
+   :show-inheritance:
\ No newline at end of file
diff --git a/docs/source/file_validator/index.rst b/docs/source/file_validator/index.rst
new file mode 100644
index 0000000..c984a6a
--- /dev/null
+++ b/docs/source/file_validator/index.rst
@@ -0,0 +1,10 @@
+==========================================
+File Validator Module
+==========================================
+
+.. toctree::
+   :maxdepth: 2
+   :caption: Components:
+
+   views
+   forms
\ No newline at end of file
diff --git a/docs/source/file_validator/views.rst b/docs/source/file_validator/views.rst
new file mode 100644
index 0000000..548bc76
--- /dev/null
+++ b/docs/source/file_validator/views.rst
@@ -0,0 +1,8 @@
+==========================================
+Sage Validation - File Validator Views
+==========================================
+
+.. automodule:: file_validator.views
+   :members:
+   :undoc-members:
+   :show-inheritance:
\ No newline at end of file
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 2af1b6c..cc6b075 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -10,11 +10,7 @@ Welcome to Sage Validation's documentation!
    :maxdepth: 2
    :caption: Contents:
 
-
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
+    validations
+    file_validator/index
+    file_validator/views
+    file_validator/forms
\ No newline at end of file
diff --git a/docs/source/validations.rst b/docs/source/validations.rst
new file mode 100644
index 0000000..13bcc92
--- /dev/null
+++ b/docs/source/validations.rst
@@ -0,0 +1,63 @@
+====================================
+CSV Upload Validation Rules
+====================================
+
+The following table describes the validation rules applied when uploading a CSV file.
+
+.. list-table::
+   :header-rows: 1
+   :widths: 20 20 40 20
+
+   * - **Type**
+     - **Field**
+     - **Logic**
+     - **Comments**
+
+   * - Structural
+     - *(All Fields)*
+     - Ensure that all required field names are present.
+     - -
+   * - Update
+     - `...NominalAccountNumber` (*n)
+     - If value starts with `xx-`, map `NominalCostCentre` using `dbo.meoCostCentres` and retrieve `NominalAccountNumber` from `dbo.vw_xx-data`.
+     - Ensure the correct nominal code is assigned.
+
+   * - Checks
+     - AccountNumber
+     - Validate against `dbo.meoValidSuppliers`.
+     - Ensure the account exists in the valid suppliers list.
+
+   * - Checks
+     - Source
+     - Should always be `80`.
+     - Reject rows where `Source != 80`.
+
+   * - Checks
+     - SYSTraderTranType
+     - Should always be `4`.
+     - Reject rows where `SYSTraderTranType != 4`.
+
+   * - Update
+     - TransactionDate
+     - Set to today’s date (`dd/mm/yyyy`).
+     - Ensure all rows have a consistent transaction date.
+
+   * - Checks
+     - `...NominalAccountNumber` (*n)
+     - Validate against `[Nom]` in `dbo.meoNominal`.
+     - Ensure all nominal account numbers exist.
+
+   * - Checks
+     - `...NominalCostCentre` (*n)
+     - Validate against `dbo.meoCostCentres`.
+     - Ensure cost centres exist.
+
+   * - Checks
+     - Combination of `...NominalAccountNumber`, `...NominalCostCentre`, and `...NominalDepartment`
+     - Validate against `dbo.meoValidSageAccounts`.
+     - The combination of the three fields must be valid.
+
+   * - Checks
+     - `...TaxRate`
+     - Validate against `[Tax code]` in `dbo.meoValidVAT`.
+     - Ensure valid tax rates.
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index a1b9380..dbfb9a1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,7 @@ mypy
 tox
 sphinx
 sphinx-autodoc-typehints
+sphinx-autodoc
 mssql-django
 pytest
 pytest-django
-- 
GitLab