-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TRELLO-2537 : create sample user,companies & reports
- Loading branch information
1 parent
8ff71eb
commit 30d0c6c
Showing
27 changed files
with
690 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package models.report.sampledata | ||
|
||
import models.company.Address | ||
import utils.Country.Espagne | ||
|
||
object AddressGenerator { | ||
|
||
def frenchAddress(): Address = | ||
Address( | ||
number = Some("789"), | ||
street = Some("Rue de la Paix"), | ||
addressSupplement = Some("Appartement 12, Bâtiment C"), | ||
postalCode = Some("75008"), | ||
city = Some("Paris"), | ||
country = None | ||
) | ||
|
||
def domTomAddress(): Address = | ||
Address( | ||
number = Some("12"), | ||
street = Some("Rue du Lagon"), | ||
addressSupplement = Some("Résidence Les Tropiques, Appartement 4B"), | ||
postalCode = Some("97100"), | ||
city = Some("Basse-Terre"), | ||
country = None | ||
) | ||
|
||
def foreignAddress(): Address = | ||
Address( | ||
number = Some("456"), | ||
street = Some("Calle Falsa"), | ||
addressSupplement = Some("Piso 3, Puerta B"), | ||
postalCode = Some("28080"), | ||
city = Some("Madrid"), | ||
country = Some(Espagne) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package models.report.sampledata | ||
|
||
import models.company.Address | ||
import models.company.Company | ||
import utils.SIREN | ||
import utils.SIRET | ||
|
||
import java.util.UUID | ||
import scala.collection.mutable.ListBuffer | ||
import scala.util.Random | ||
|
||
object CompanyGenerator { | ||
|
||
def randomCompany( | ||
siren: SIREN, | ||
name: String, | ||
address: Address, | ||
isHeadOffice: Boolean, | ||
isOpen: Boolean, | ||
isPublic: Boolean | ||
): Company = | ||
Company( | ||
id = UUID.randomUUID(), | ||
siret = SIRET(siren.value + f"${Random.nextInt(100000)}%05d"), | ||
name = name, | ||
address = address, | ||
activityCode = Random.shuffle(List("40.7Z", "12.4A", "62.01Z")).headOption, | ||
isHeadOffice = isHeadOffice, | ||
isOpen = isOpen, | ||
isPublic = isPublic, | ||
brand = Some(s"Marque ${name}"), | ||
commercialName = Some(s"Nom commercial ${name}"), | ||
establishmentCommercialName = Some(s"Nom établissement commercial ${name}") | ||
) | ||
|
||
def createCompany = { | ||
val randomSiren = SIREN((100000000 + Random.nextInt(900000000)).toString) | ||
randomCompany( | ||
siren = randomSiren, | ||
name = s"MAISON MERE ${randomSiren.value}", | ||
address = AddressGenerator.frenchAddress(), | ||
isHeadOffice = true, | ||
isOpen = true, | ||
isPublic = true | ||
) | ||
} | ||
|
||
def createCompanies(subsidiaryCount: Int) = { | ||
|
||
val randomSiren = SIREN((100000000 + Random.nextInt(900000000)).toString) | ||
val headOffice = randomCompany( | ||
siren = randomSiren, | ||
name = s"MAISON MERE ${randomSiren.value}", | ||
address = AddressGenerator.frenchAddress(), | ||
isHeadOffice = true, | ||
isOpen = true, | ||
isPublic = true | ||
) | ||
|
||
val companies = ListBuffer(headOffice) | ||
|
||
for (i <- 1 to subsidiaryCount) { | ||
val c = randomCompany( | ||
siren = randomSiren, | ||
name = s" FILLIALE $randomSiren n$i", | ||
address = AddressGenerator.frenchAddress(), | ||
isHeadOffice = false, | ||
isOpen = true, | ||
isPublic = true | ||
) | ||
companies += c | ||
} | ||
|
||
companies.toList | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.