✨ Rule post folders for notary
This commit is contained in:
parent
b64bcc819b
commit
1a7950765f
@ -1,10 +1,22 @@
|
|||||||
import { ECivility, ECustomerStatus, EFolderStatus, EOfficeStatus, Prisma, PrismaClient } from "@prisma/client";
|
import { ECivility, ECustomerStatus, EFolderStatus, EOfficeStatus, Prisma, PrismaClient } from "@prisma/client";
|
||||||
import User, { Address, Contact, Customer, Deed, DeedType, DocumentType, Office, OfficeFolder, OfficeRole, Role, Rule } from "le-coffre-resources/dist/SuperAdmin";
|
import User, {
|
||||||
|
Address,
|
||||||
|
Contact,
|
||||||
|
Customer,
|
||||||
|
Deed,
|
||||||
|
DeedType,
|
||||||
|
DocumentType,
|
||||||
|
Office,
|
||||||
|
OfficeFolder,
|
||||||
|
OfficeRole,
|
||||||
|
Role,
|
||||||
|
Rule,
|
||||||
|
} from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
import "module-alias/register";
|
import "module-alias/register";
|
||||||
|
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
try{
|
try {
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
const randomString = () => {
|
const randomString = () => {
|
||||||
@ -13,14 +25,14 @@ export default async function main() {
|
|||||||
for (let i = 10; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
for (let i = 10; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const idNot1 = "dlefvlef";
|
const idNot1 = "dlefvlef";
|
||||||
const idNot2 = "jelkvelknvlkn";
|
const idNot2 = "jelkvelknvlkn";
|
||||||
const idNot3 = "rleenrenlnr";
|
const idNot3 = "rleenrenlnr";
|
||||||
const idNot4 = "ljfeflecnmd";
|
const idNot4 = "ljfeflecnmd";
|
||||||
const idNot5 = "rflrefrjf";
|
const idNot5 = "rflrefrjf";
|
||||||
const idNot6 = "er3ojfdlfnd";
|
const idNot6 = "er3ojfdlfnd";
|
||||||
|
|
||||||
const addresses: Address[] = [
|
const addresses: Address[] = [
|
||||||
{
|
{
|
||||||
address: "148 Avenue du bac",
|
address: "148 Avenue du bac",
|
||||||
@ -163,7 +175,7 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const contacts: Contact[] = [
|
const contacts: Contact[] = [
|
||||||
{
|
{
|
||||||
address: addresses[0],
|
address: addresses[0],
|
||||||
@ -406,7 +418,7 @@ export default async function main() {
|
|||||||
civility: ECivility.MALE,
|
civility: ECivility.MALE,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const offices: Office[] = [
|
const offices: Office[] = [
|
||||||
{
|
{
|
||||||
idNot: idNot1,
|
idNot: idNot1,
|
||||||
@ -418,7 +430,7 @@ export default async function main() {
|
|||||||
office_status: EOfficeStatus.ACTIVATED,
|
office_status: EOfficeStatus.ACTIVATED,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const customers: Customer[] = [
|
const customers: Customer[] = [
|
||||||
{
|
{
|
||||||
contact: contacts[5],
|
contact: contacts[5],
|
||||||
@ -511,7 +523,7 @@ export default async function main() {
|
|||||||
status: ECustomerStatus.PENDING,
|
status: ECustomerStatus.PENDING,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const rules: Rule[] = [
|
const rules: Rule[] = [
|
||||||
{
|
{
|
||||||
name: "GET users",
|
name: "GET users",
|
||||||
@ -645,6 +657,12 @@ export default async function main() {
|
|||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "POST folders",
|
||||||
|
label: "Création des dossiers",
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "PUT rules",
|
name: "PUT rules",
|
||||||
label: "Modification des droits",
|
label: "Modification des droits",
|
||||||
@ -705,12 +723,6 @@ export default async function main() {
|
|||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "POST folders",
|
|
||||||
label: "Création des dossiers",
|
|
||||||
created_at: new Date(),
|
|
||||||
updated_at: new Date(),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "POST roles",
|
name: "POST roles",
|
||||||
label: "Création des rôles",
|
label: "Création des rôles",
|
||||||
@ -802,7 +814,7 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const roles: Role[] = [
|
const roles: Role[] = [
|
||||||
{
|
{
|
||||||
name: "super-admin",
|
name: "super-admin",
|
||||||
@ -823,7 +835,7 @@ export default async function main() {
|
|||||||
label: "Notaire",
|
label: "Notaire",
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
rules: rules.slice(0, 22),
|
rules: rules.slice(0, 23),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
@ -833,7 +845,7 @@ export default async function main() {
|
|||||||
rules: rules.slice(0, 11),
|
rules: rules.slice(0, 11),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const officeRoles: OfficeRole[] = [
|
const officeRoles: OfficeRole[] = [
|
||||||
{
|
{
|
||||||
name: "Notaire",
|
name: "Notaire",
|
||||||
@ -848,9 +860,9 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
office: offices[0]!,
|
office: offices[0]!,
|
||||||
rules: rules.slice(0, 22),
|
rules: rules.slice(0, 22),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const users: User[] = [
|
const users: User[] = [
|
||||||
{
|
{
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
@ -895,7 +907,7 @@ export default async function main() {
|
|||||||
role: roles[3],
|
role: roles[3],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const deedTypes: DeedType[] = [
|
const deedTypes: DeedType[] = [
|
||||||
{
|
{
|
||||||
name: "Acte de donation",
|
name: "Acte de donation",
|
||||||
@ -930,7 +942,7 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const deeds: Deed[] = [
|
const deeds: Deed[] = [
|
||||||
{
|
{
|
||||||
deed_type: deedTypes[0],
|
deed_type: deedTypes[0],
|
||||||
@ -1038,7 +1050,7 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const documentTypes: DocumentType[] = [
|
const documentTypes: DocumentType[] = [
|
||||||
{
|
{
|
||||||
archived_at: null,
|
archived_at: null,
|
||||||
@ -1055,12 +1067,14 @@ export default async function main() {
|
|||||||
archived_at: null,
|
archived_at: null,
|
||||||
name: "Taxe Foncière",
|
name: "Taxe Foncière",
|
||||||
office: offices[0],
|
office: offices[0],
|
||||||
private_description: "Impôt annuel imposé sur les propriétés foncières et utilisé pour financer les services publics locaux.",
|
private_description:
|
||||||
public_description: "Impôt annuel imposé sur les propriétés foncières et utilisé pour financer les services publics locaux.",
|
"Impôt annuel imposé sur les propriétés foncières et utilisé pour financer les services publics locaux.",
|
||||||
|
public_description:
|
||||||
|
"Impôt annuel imposé sur les propriétés foncières et utilisé pour financer les services publics locaux.",
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
archived_at: null,
|
archived_at: null,
|
||||||
name: "Contrat Mariage",
|
name: "Contrat Mariage",
|
||||||
@ -1096,8 +1110,10 @@ export default async function main() {
|
|||||||
archived_at: null,
|
archived_at: null,
|
||||||
name: "Statuts SCI",
|
name: "Statuts SCI",
|
||||||
office: offices[0],
|
office: offices[0],
|
||||||
private_description: "Document légal qui définit les règles et les dispositions régissant la Société Civile Immobilière (SCI).",
|
private_description:
|
||||||
public_description: "Document légal qui définit les règles et les dispositions régissant la Société Civile Immobilière (SCI).",
|
"Document légal qui définit les règles et les dispositions régissant la Société Civile Immobilière (SCI).",
|
||||||
|
public_description:
|
||||||
|
"Document légal qui définit les règles et les dispositions régissant la Société Civile Immobilière (SCI).",
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
@ -1138,7 +1154,8 @@ export default async function main() {
|
|||||||
office: offices[0],
|
office: offices[0],
|
||||||
private_description:
|
private_description:
|
||||||
"Document juridique qui établit les règles et les droits des copropriétaires d'un immeuble en copropriété.",
|
"Document juridique qui établit les règles et les droits des copropriétaires d'un immeuble en copropriété.",
|
||||||
public_description: "Document juridique qui établit les règles et les droits des copropriétaires d'un immeuble en copropriété.",
|
public_description:
|
||||||
|
"Document juridique qui établit les règles et les droits des copropriétaires d'un immeuble en copropriété.",
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
@ -1188,7 +1205,8 @@ export default async function main() {
|
|||||||
archived_at: null,
|
archived_at: null,
|
||||||
name: "Avis de décès",
|
name: "Avis de décès",
|
||||||
office: offices[0],
|
office: offices[0],
|
||||||
private_description: "Notification officielle délivrée par les autorités compétentes pour informer du décès d'une personne.",
|
private_description:
|
||||||
|
"Notification officielle délivrée par les autorités compétentes pour informer du décès d'une personne.",
|
||||||
public_description: "Notification officielle délivrée par les autorités compétentes pour informer du décès d'une personne.",
|
public_description: "Notification officielle délivrée par les autorités compétentes pour informer du décès d'une personne.",
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
@ -1241,7 +1259,7 @@ export default async function main() {
|
|||||||
updated_at: new Date(),
|
updated_at: new Date(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const officeFolders: OfficeFolder[] = [
|
const officeFolders: OfficeFolder[] = [
|
||||||
{
|
{
|
||||||
folder_number: "0001",
|
folder_number: "0001",
|
||||||
@ -1343,7 +1361,7 @@ export default async function main() {
|
|||||||
archived_description: null,
|
archived_description: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const office of offices) {
|
for (const office of offices) {
|
||||||
const officeCreated = await prisma.offices.create({
|
const officeCreated = await prisma.offices.create({
|
||||||
data: {
|
data: {
|
||||||
@ -1371,7 +1389,7 @@ export default async function main() {
|
|||||||
});
|
});
|
||||||
rule.uid = ruleCreated.uid;
|
rule.uid = ruleCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const role of roles) {
|
for (const role of roles) {
|
||||||
const roleCreated = await prisma.roles.create({
|
const roleCreated = await prisma.roles.create({
|
||||||
data: {
|
data: {
|
||||||
@ -1386,7 +1404,7 @@ export default async function main() {
|
|||||||
});
|
});
|
||||||
role.uid = roleCreated.uid;
|
role.uid = roleCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const officeRole of officeRoles) {
|
for (const officeRole of officeRoles) {
|
||||||
const officeRoleCreated = await prisma.officeRoles.create({
|
const officeRoleCreated = await prisma.officeRoles.create({
|
||||||
data: {
|
data: {
|
||||||
@ -1405,7 +1423,7 @@ export default async function main() {
|
|||||||
});
|
});
|
||||||
officeRole.uid = officeRoleCreated.uid;
|
officeRole.uid = officeRoleCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
const createArgs: Prisma.UsersCreateArgs = {
|
const createArgs: Prisma.UsersCreateArgs = {
|
||||||
data: {
|
data: {
|
||||||
@ -1464,7 +1482,7 @@ export default async function main() {
|
|||||||
const userCreated = await prisma.users.create(createArgs);
|
const userCreated = await prisma.users.create(createArgs);
|
||||||
user.uid = userCreated.uid;
|
user.uid = userCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const customer of customers) {
|
for (const customer of customers) {
|
||||||
const createArgs: Prisma.CustomersCreateArgs = {
|
const createArgs: Prisma.CustomersCreateArgs = {
|
||||||
data: {
|
data: {
|
||||||
@ -1482,7 +1500,7 @@ export default async function main() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (customer.contact?.address) {
|
if (customer.contact?.address) {
|
||||||
createArgs.data.contact!.create!.address = {
|
createArgs.data.contact!.create!.address = {
|
||||||
create: {
|
create: {
|
||||||
@ -1495,7 +1513,7 @@ export default async function main() {
|
|||||||
const customersCreated = await prisma.customers.create(createArgs);
|
const customersCreated = await prisma.customers.create(createArgs);
|
||||||
customer.uid = customersCreated.uid;
|
customer.uid = customersCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const deedType of deedTypes) {
|
for (const deedType of deedTypes) {
|
||||||
const createArgs: Prisma.DeedTypesCreateArgs = {
|
const createArgs: Prisma.DeedTypesCreateArgs = {
|
||||||
data: {
|
data: {
|
||||||
@ -1518,7 +1536,7 @@ export default async function main() {
|
|||||||
const deedTypeCreated = await prisma.deedTypes.create(createArgs);
|
const deedTypeCreated = await prisma.deedTypes.create(createArgs);
|
||||||
deedType.uid = deedTypeCreated.uid;
|
deedType.uid = deedTypeCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const deed of deeds) {
|
for (const deed of deeds) {
|
||||||
const createArgs: Prisma.DeedsCreateArgs = {
|
const createArgs: Prisma.DeedsCreateArgs = {
|
||||||
data: {
|
data: {
|
||||||
@ -1535,7 +1553,7 @@ export default async function main() {
|
|||||||
},
|
},
|
||||||
include: { document_types: true },
|
include: { document_types: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deedTypeWithDocumentTypes.document_types) {
|
if (deedTypeWithDocumentTypes.document_types) {
|
||||||
createArgs.data.document_types = {
|
createArgs.data.document_types = {
|
||||||
connect: deedTypeWithDocumentTypes.document_types.map((documentType) => ({
|
connect: deedTypeWithDocumentTypes.document_types.map((documentType) => ({
|
||||||
@ -1546,7 +1564,7 @@ export default async function main() {
|
|||||||
const deedCreated = await prisma.deeds.create(createArgs);
|
const deedCreated = await prisma.deeds.create(createArgs);
|
||||||
deed.uid = deedCreated.uid;
|
deed.uid = deedCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const documentType of documentTypes) {
|
for (const documentType of documentTypes) {
|
||||||
const documentTypeCreated = await prisma.documentTypes.create({
|
const documentTypeCreated = await prisma.documentTypes.create({
|
||||||
data: {
|
data: {
|
||||||
@ -1562,7 +1580,7 @@ export default async function main() {
|
|||||||
});
|
});
|
||||||
documentType.uid = documentTypeCreated.uid;
|
documentType.uid = documentTypeCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const officeFolder of officeFolders) {
|
for (const officeFolder of officeFolders) {
|
||||||
const officeFolderCreated = await prisma.officeFolders.create({
|
const officeFolderCreated = await prisma.officeFolders.create({
|
||||||
data: {
|
data: {
|
||||||
@ -1589,12 +1607,10 @@ export default async function main() {
|
|||||||
});
|
});
|
||||||
officeFolder.uid = officeFolderCreated.uid;
|
officeFolder.uid = officeFolderCreated.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(">MOCK DATA - Seeding completed!");
|
console.log(">MOCK DATA - Seeding completed!");
|
||||||
}
|
} catch (error) {
|
||||||
catch(error){
|
|
||||||
console.log("Data already seeded, skiping");
|
console.log("Data already seeded, skiping");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
main();
|
main();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user