Premier commit

This commit is contained in:
2026-09-11 14:55:41 +02:00
commit 8ed04aae89
134 changed files with 36627 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,148 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddContratsAndPaiementStatut : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "statut",
schema: "fin",
table: "paiements",
type: "varchar(20)",
unicode: false,
maxLength: 20,
nullable: false,
defaultValue: "PROGRAMME");
migrationBuilder.AddColumn<bool>(
name: "rapproche",
schema: "fin",
table: "paiements",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "contrats_fournisseurs",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
fournisseur_id = table.Column<int>(type: "int", nullable: false),
reference = table.Column<string>(type: "varchar(50)", unicode: false, maxLength: 50, nullable: true),
objet = table.Column<string>(type: "varchar(255)", unicode: false, maxLength: 255, nullable: false),
date_signature = table.Column<DateOnly>(type: "date", nullable: true),
date_debut = table.Column<DateOnly>(type: "date", nullable: false),
date_fin = table.Column<DateOnly>(type: "date", nullable: false),
montant_total = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
periodicite = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "mensuelle"),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"),
saisie_par_id = table.Column<int>(type: "int", nullable: false),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
date_derniere_maj = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_fournisseurs", x => x.id);
table.ForeignKey(
name: "FK__contrats_fournisseurs__fournisseur",
column: x => x.fournisseur_id,
principalSchema: "ref",
principalTable: "fournisseurs",
principalColumn: "id");
table.ForeignKey(
name: "FK__contrats_fournisseurs__saisie_par",
column: x => x.saisie_par_id,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "contrats_echeances",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
contrat_id = table.Column<int>(type: "int", nullable: false),
date_echeance = table.Column<DateOnly>(type: "date", nullable: false),
montant = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "A_VENIR"),
justificatif_id = table.Column<int>(type: "int", nullable: true),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_echeances", x => x.id);
table.ForeignKey(
name: "FK__contrats_echeances__contrat",
column: x => x.contrat_id,
principalSchema: "achats",
principalTable: "contrats_fournisseurs",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK__contrats_echeances__justificatif",
column: x => x.justificatif_id,
principalSchema: "core",
principalTable: "pieces_jointes",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_ctf_fournisseur",
schema: "achats",
table: "contrats_fournisseurs",
column: "fournisseur_id");
migrationBuilder.CreateIndex(
name: "IX_ctf_saisie_par",
schema: "achats",
table: "contrats_fournisseurs",
column: "saisie_par_id");
migrationBuilder.CreateIndex(
name: "IX_cte_contrat",
schema: "achats",
table: "contrats_echeances",
column: "contrat_id");
migrationBuilder.CreateIndex(
name: "IX_cte_justif",
schema: "achats",
table: "contrats_echeances",
column: "justificatif_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "contrats_echeances",
schema: "achats");
migrationBuilder.DropTable(
name: "contrats_fournisseurs",
schema: "achats");
migrationBuilder.DropColumn(
name: "rapproche",
schema: "fin",
table: "paiements");
migrationBuilder.DropColumn(
name: "statut",
schema: "fin",
table: "paiements");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddCategorieFournisseurLibre : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "categorie_fournisseur_libre",
schema: "achats",
table: "demandes_achat",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "categorie_fournisseur_libre",
schema: "achats",
table: "demandes_achat");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,104 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddSousTraitantsOrganismesContrats : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "st");
migrationBuilder.CreateTable(
name: "organismes",
schema: "st",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
raison_sociale = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
siret = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: true),
email = table.Column<string>(type: "varchar(255)", unicode: false, maxLength: 255, nullable: true),
telephone = table.Column<string>(type: "varchar(30)", unicode: false, maxLength: 30, nullable: true),
adresse = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__organismes", x => x.id);
});
migrationBuilder.CreateTable(
name: "contrats_prestataires",
schema: "st",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
organisme_id = table.Column<int>(type: "int", nullable: false),
reference = table.Column<string>(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false),
objet = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
date_signature = table.Column<DateOnly>(type: "date", nullable: true),
date_debut = table.Column<DateOnly>(type: "date", nullable: false),
date_fin = table.Column<DateOnly>(type: "date", nullable: false),
montant_total = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
statut = table.Column<string>(type: "varchar(20)", unicode: false, maxLength: 20, nullable: false, defaultValue: "ACTIF"),
saisie_par_id = table.Column<int>(type: "int", nullable: false),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK__contrats_prestataires", x => x.id);
table.ForeignKey(
name: "FK__contrats_prestataires__organisme",
column: x => x.organisme_id,
principalSchema: "st",
principalTable: "organismes",
principalColumn: "id");
table.ForeignKey(
name: "FK__contrats_prestataires__saisie_par",
column: x => x.saisie_par_id,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_ctp_organisme",
schema: "st",
table: "contrats_prestataires",
column: "organisme_id");
migrationBuilder.CreateIndex(
name: "IX_ctp_saisie_par",
schema: "st",
table: "contrats_prestataires",
column: "saisie_par_id");
migrationBuilder.CreateIndex(
name: "UQ_ctp_reference",
schema: "st",
table: "contrats_prestataires",
column: "reference",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "contrats_prestataires",
schema: "st");
migrationBuilder.DropTable(
name: "organismes",
schema: "st");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddResponsableToUtilisateurs : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "responsable_id",
schema: "core",
table: "utilisateurs",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_utilisateurs_responsable_id",
schema: "core",
table: "utilisateurs",
column: "responsable_id");
migrationBuilder.AddForeignKey(
name: "FK__utilisateurs__responsable",
schema: "core",
table: "utilisateurs",
column: "responsable_id",
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK__utilisateurs__responsable",
schema: "core",
table: "utilisateurs");
migrationBuilder.DropIndex(
name: "IX_utilisateurs_responsable_id",
schema: "core",
table: "utilisateurs");
migrationBuilder.DropColumn(
name: "responsable_id",
schema: "core",
table: "utilisateurs");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddCommentaireToFactures : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "commentaire",
schema: "fin",
table: "factures",
type: "nvarchar(1000)",
maxLength: 1000,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "commentaire",
schema: "fin",
table: "factures");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddContratIdToFactures : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "contrat_id",
schema: "fin",
table: "factures",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_factures_contrat_id",
schema: "fin",
table: "factures",
column: "contrat_id");
migrationBuilder.AddForeignKey(
name: "FK_factures_contrat",
schema: "fin",
table: "factures",
column: "contrat_id",
principalSchema: "achats",
principalTable: "contrats_fournisseurs",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_factures_contrat",
schema: "fin",
table: "factures");
migrationBuilder.DropIndex(
name: "IX_factures_contrat_id",
schema: "fin",
table: "factures");
migrationBuilder.DropColumn(
name: "contrat_id",
schema: "fin",
table: "factures");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,84 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class AddBudgetsService : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "budgets_service",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
service_id = table.Column<int>(type: "int", nullable: false),
exercice_annee = table.Column<int>(type: "int", nullable: false),
montant_initial = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
montant_revise = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
date_revision = table.Column<DateTime>(type: "datetime", nullable: true),
revise_par = table.Column<int>(type: "int", nullable: true),
commentaire_revision = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
saisie_par_id = table.Column<int>(type: "int", nullable: false),
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
date_derniere_maj = table.Column<DateTime>(type: "datetime", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_budgets_service", x => x.id);
table.ForeignKey(
name: "FK_budgets_service_revise_par",
column: x => x.revise_par,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_budgets_service_saisie_par",
column: x => x.saisie_par_id,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
table.ForeignKey(
name: "FK_budgets_service_service",
column: x => x.service_id,
principalSchema: "ref",
principalTable: "services",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_budgets_service_revise_par",
schema: "achats",
table: "budgets_service",
column: "revise_par");
migrationBuilder.CreateIndex(
name: "IX_budgets_service_saisie_par_id",
schema: "achats",
table: "budgets_service",
column: "saisie_par_id");
migrationBuilder.CreateIndex(
name: "IX_budgets_service_unique",
schema: "achats",
table: "budgets_service",
columns: new[] { "service_id", "exercice_annee" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "budgets_service",
schema: "achats");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,141 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SIFinance.Shared.Migrations
{
/// <inheritdoc />
public partial class SplitBudgetRevisionsHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_budgets_service_revise_par",
schema: "achats",
table: "budgets_service");
migrationBuilder.DropIndex(
name: "IX_budgets_service_revise_par",
schema: "achats",
table: "budgets_service");
migrationBuilder.DropColumn(
name: "commentaire_revision",
schema: "achats",
table: "budgets_service");
migrationBuilder.DropColumn(
name: "date_revision",
schema: "achats",
table: "budgets_service");
migrationBuilder.DropColumn(
name: "montant_revise",
schema: "achats",
table: "budgets_service");
migrationBuilder.DropColumn(
name: "revise_par",
schema: "achats",
table: "budgets_service");
migrationBuilder.CreateTable(
name: "budgets_service_revisions",
schema: "achats",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
budget_service_id = table.Column<int>(type: "int", nullable: false),
montant_revise = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
commentaire = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
revise_par = table.Column<int>(type: "int", nullable: false),
date_revision = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "(getdate())")
},
constraints: table =>
{
table.PrimaryKey("PK_budgets_service_revisions", x => x.id);
table.ForeignKey(
name: "FK_budgets_service_revisions_budget",
column: x => x.budget_service_id,
principalSchema: "achats",
principalTable: "budgets_service",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_budgets_service_revisions_revise_par",
column: x => x.revise_par,
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_budgets_service_revisions_budget_service_id",
schema: "achats",
table: "budgets_service_revisions",
column: "budget_service_id");
migrationBuilder.CreateIndex(
name: "IX_budgets_service_revisions_revise_par",
schema: "achats",
table: "budgets_service_revisions",
column: "revise_par");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "budgets_service_revisions",
schema: "achats");
migrationBuilder.AddColumn<string>(
name: "commentaire_revision",
schema: "achats",
table: "budgets_service",
type: "nvarchar(1000)",
maxLength: 1000,
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "date_revision",
schema: "achats",
table: "budgets_service",
type: "datetime",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "montant_revise",
schema: "achats",
table: "budgets_service",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "revise_par",
schema: "achats",
table: "budgets_service",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_budgets_service_revise_par",
schema: "achats",
table: "budgets_service",
column: "revise_par");
migrationBuilder.AddForeignKey(
name: "FK_budgets_service_revise_par",
schema: "achats",
table: "budgets_service",
column: "revise_par",
principalSchema: "core",
principalTable: "utilisateurs",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
}
}
}
@@ -0,0 +1,18 @@
-- À exécuter une seule fois sur la base SIFinance.
-- Le flag permet de rattacher n'importe quelle catégorie au circuit matériel,
-- sans dépendre de son libellé.
ALTER TABLE ref.types_depense
ADD est_materiel bit NOT NULL
CONSTRAINT DF_types_depense_est_materiel DEFAULT (0);
GO
-- Les nouveaux statuts du workflow dépassent parfois la taille historique de 30.
ALTER TABLE achats.demandes_achat
ALTER COLUMN statut varchar(50) NOT NULL;
GO
-- Catégories à traiter comme du matériel : adapte cette liste à tes règles métier.
UPDATE ref.types_depense
SET est_materiel = 1
WHERE libelle IN ('Fournitures', 'Informatique', 'Mobilier');
GO
File diff suppressed because it is too large Load Diff