Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pc 32555 delete uses of VenueReimbursementPointLink and BankInformation #14943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions api/src/pcapi/core/finance/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ class InvoiceFactory(BaseFactory):
class Meta:
model = models.Invoice

reimbursementPoint = factory.SubFactory(offerers_factories.VenueFactory)
amount = 1000
reference = factory.Sequence("{:09}".format)
token = factory.LazyFunction(secrets.token_urlsafe)
Expand All @@ -284,19 +283,7 @@ class Meta:
amount = -1000
batch = factory.SubFactory(CashflowBatchFactory)
status = models.CashflowStatus.ACCEPTED
reimbursementPoint = None

@factory.lazy_attribute
def bankInformation(self) -> models.BankInformation | None:
if self.reimbursementPoint is not None:
return self.reimbursementPoint.bankInformation
return None

@factory.lazy_attribute
def bankAccount(self) -> models.BankAccount | None:
if self.reimbursementPoint is None:
return factory.SubFactory(BankAccountFactory)
return None
bankAccount = factory.SubFactory(BankAccountFactory)


# Factories below are deprecated and should probably NOT BE USED in
Expand Down
42 changes: 0 additions & 42 deletions api/src/pcapi/core/offerers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,27 +501,6 @@ def store_timezone(self) -> None:
else get_postal_code_timezone(self.managingOfferer.postalCode)
)

@property
def bic(self) -> str | None:
return self.bankInformation.bic if self.bankInformation else None

@property
def iban(self) -> str | None:
return self.bankInformation.iban if self.bankInformation else None

@property
def demarchesSimplifieesApplicationId(self) -> int | None:
if not self.bankInformation:
return None

if self.bankInformation.status not in (
finance_models.BankInformationStatus.DRAFT,
finance_models.BankInformationStatus.ACCEPTED,
):
return None

return self.bankInformation.applicationId

@property
def last_collective_dms_application(self) -> educational_models.CollectiveDmsApplication | None:
if self.collectiveDmsApplications:
Expand Down Expand Up @@ -1024,27 +1003,6 @@ def street(self, value: str | None) -> None:
def street(cls): # pylint: disable=no-self-argument
return cls._address

@property
def bic(self) -> str | None:
return self.bankInformation.bic if self.bankInformation else None

@property
def iban(self) -> str | None:
return self.bankInformation.iban if self.bankInformation else None

@property
def demarchesSimplifieesApplicationId(self) -> str | None:
if not self.bankInformation:
return None

if self.bankInformation.status not in (
finance_models.BankInformationStatus.DRAFT,
finance_models.BankInformationStatus.ACCEPTED,
):
return None

return self.bankInformation.applicationId

@hybrid_property
def departementCode(self) -> str:
return postal_code_utils.PostalCode(self.postalCode).get_departement_code()
Expand Down
2 changes: 0 additions & 2 deletions api/src/pcapi/core/offerers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def get_filtered_venues(
.join(models.UserOfferer, models.UserOfferer.offererId == models.Offerer.id)
.options(sqla_orm.joinedload(models.Venue.managingOfferer))
.options(sqla_orm.joinedload(models.Venue.collectiveDomains))
.options(sqla_orm.joinedload(models.Venue.reimbursement_point_links))
.options(sqla_orm.joinedload(models.Venue.bankInformation))
.options(sqla_orm.joinedload(models.Venue.accessibilityProvider))
.options(sqla_orm.joinedload(models.Venue.offererAddress).joinedload(models.OffererAddress.address))
)
Expand Down
3 changes: 1 addition & 2 deletions api/src/pcapi/routes/pro/venues.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def get_venue(venue_id: int) -> venues_serialize.GetVenueResponseModel:
venue = (
models.Venue.query.filter(models.Venue.id == venue_id)
.options(sqla_orm.joinedload(models.Venue.contact))
.options(sqla_orm.joinedload(models.Venue.bankInformation))
.options(sqla_orm.joinedload(models.Venue.managingOfferer).joinedload(models.Offerer.bankInformation))
.options(sqla_orm.joinedload(models.Venue.managingOfferer))
.options(
sqla_orm.selectinload(models.Venue.pricing_point_links).joinedload(
models.VenuePricingPointLink.pricingPoint
Expand Down
4 changes: 0 additions & 4 deletions api/src/pcapi/routes/serialization/offerers_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GetOffererVenueResponseModel(BaseModel, AccessibilityComplianceMixin):
city: str | None
comment: str | None
departementCode: str | None
demarchesSimplifieesApplicationId: int | None
hasCreatedOffer: bool
hasAdageId: bool
isVirtual: bool
Expand Down Expand Up @@ -84,7 +83,6 @@ class GetOffererResponseModel(BaseModel):
apiKey: OffererApiKey
city: str
dateCreated: datetime
demarchesSimplifieesApplicationId: str | None
hasAvailablePricingPoints: bool
hasDigitalVenueAtLeastOneOffer: bool
isValidated: bool
Expand Down Expand Up @@ -116,8 +114,6 @@ def from_orm(cls, row: Row) -> "GetOffererResponseModel":
}
venues = (
offerers_models.Venue.query.filter_by(managingOffererId=offerer.id)
.options(sqla_orm.joinedload(offerers_models.Venue.reimbursement_point_links))
.options(sqla_orm.joinedload(offerers_models.Venue.bankInformation))
.options(sqla_orm.joinedload(offerers_models.Venue.collectiveDmsApplications))
.options(sqla_orm.joinedload(offerers_models.Venue.venueProviders))
.options(sqla_orm.joinedload(offerers_models.Venue.googlePlacesInfo))
Expand Down
2 changes: 0 additions & 2 deletions api/src/pcapi/routes/serialization/venues_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class Config:
class GetVenueManagingOffererResponseModel(BaseModel):
city: str
dateCreated: datetime
demarchesSimplifieesApplicationId: str | None
id: int
isValidated: bool
name: str
Expand Down Expand Up @@ -246,7 +245,6 @@ class GetVenueResponseModel(base.BaseVenueResponse, AccessibilityComplianceMixin
banId: str | None
bookingEmail: str | None
comment: str | None
demarchesSimplifieesApplicationId: str | None
departementCode: str | None
dmsToken: str
managingOfferer: GetVenueManagingOffererResponseModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,13 @@ def create_data_venues(offerers_by_name: dict) -> dict[str, Venue]:

venue_by_name = {}
mock_index = 0

iban_count = 0
iban_prefix = "FR7630001007941234567890185"
bic_prefix, bic_suffix = "QSDFGH8Z", 556
application_id_prefix = "52"

image_venue_counter = 0

for offerer_index, (offerer_name, offerer) in enumerate(offerers_by_name.items()):
geoloc_match = re.match(r"(.*)lat\:(.*) lon\:(.*)", offerer_name)

venue_name = f"{MOCK_NAMES[mock_index % len(MOCK_NAMES)]} DATA"

# create all possible cases:
# offerer with or without iban / venue with or without iban
iban: str | None = None
bic: str | None = None
if offerer.iban:
if iban_count == 0:
iban = iban_prefix
bic = bic_prefix + str(bic_suffix)
iban_count = 1
elif iban_count == 2:
iban_count = 3
else:
if iban_count in (0, 1):
iban = iban_prefix
bic = bic_prefix + str(bic_suffix)
iban_count = 2
elif iban_count == 3:
iban_count = 0

comment = None
siret = f"{offerer.siren}{random.randint(11111,99999)}"

Expand All @@ -94,16 +69,6 @@ def create_data_venues(offerers_by_name: dict) -> dict[str, Venue]:
image_venue_counter += 1

venue_by_name[venue_name] = venue

if iban and venue.siret:
finance_factories.BankInformationFactory(
venue=venue,
bic=bic,
iban=iban,
applicationId=application_id_prefix + str(offerer_index),
)

bic_suffix += 1
mock_index += 1

logger.info("created %d venues DATA", len(venue_by_name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from pcapi.core.educational import factories as educational_factories
from pcapi.core.finance import factories as finance_factories
from pcapi.core.finance import models as finance_models
from pcapi.core.offerers import factories as offerers_factories
from pcapi.core.offerers import models as offerers_models

Expand Down Expand Up @@ -41,7 +40,7 @@ def create_venues(offerer_list: list[offerers_models.Offerer]) -> None:
offerer = next(offerer_iterator)
create_venue(
managingOfferer=offerer,
name=f"reimbursementPoint {offerer.name} 56",
name=f"Partenaire culturel {offerer.name} 56",
reimbursement=True,
adageId="123546",
adageInscriptionDate=datetime.utcnow() - timedelta(days=3),
Expand All @@ -56,7 +55,7 @@ def create_venues(offerer_list: list[offerers_models.Offerer]) -> None:
offerer = next(offerer_iterator)
create_venue(
managingOfferer=offerer,
name=f"reimbursementPoint {offerer.name} 91",
name=f"Partenaire culturel {offerer.name} 91",
adageId="10837",
adageInscriptionDate=datetime.utcnow() - timedelta(days=5),
reimbursement=True,
Expand All @@ -77,22 +76,16 @@ def create_venues(offerer_list: list[offerers_models.Offerer]) -> None:
)
# eac_pending_bank_informations
offerer = next(offerer_iterator)
pending_reimbursement_venue = offerers_factories.VenueFactory(
offerers_factories.VenueFactory(
managingOfferer=offerer,
name=f"reimbursementPoint {offerer.name}",
name=f"Partenaire culturel {offerer.name}",
adageId="789456",
adageInscriptionDate=datetime.utcnow() - timedelta(days=30),
venueEducationalStatusId=next(educational_status_iterator),
collectiveInterventionArea=ALL_INTERVENTION_AREA,
siret="55204695506065",
)
pending_reimbursement_venue.bankInformation = finance_factories.BankInformationFactory(
status=finance_models.BankInformationStatus.DRAFT
)
offerers_factories.VenueReimbursementPointLinkFactory(
venue=pending_reimbursement_venue,
reimbursementPoint=pending_reimbursement_venue,
)

# eac_no_cb
offerer = next(offerer_iterator)
create_venue(
Expand All @@ -108,7 +101,7 @@ def create_venues(offerer_list: list[offerers_models.Offerer]) -> None:
offerer = next(offerer_iterator)
create_venue(
managingOfferer=offerer,
name=f"reimbursementPoint {offerer.name}",
name=f"Partenaire culturel {offerer.name}",
reimbursement=True,
venueEducationalStatusId=next(educational_status_iterator),
collectiveInterventionArea=ALL_INTERVENTION_AREA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def create_industrial_venues(offerers_by_name: dict) -> dict[str, Venue]:
mock_index = 0
mock_accessibility_index = 0

iban_count = 0
iban_prefix = "FR7630001007941234567890185"
bic_prefix, bic_suffix = "QSDFGH8Z", 556
application_id_prefix = "12"

image_venue_counter = 0
Expand All @@ -61,25 +58,6 @@ def create_industrial_venues(offerers_by_name: dict) -> dict[str, Venue]:
venue_name = MOCK_NAMES[mock_index % len(MOCK_NAMES)]
venue_accessibility = ACCESSIBILITY_MOCK[mock_accessibility_index % len(ACCESSIBILITY_MOCK)]

# create all possible cases:
# offerer with or without iban / venue with or without iban
iban = None
bic = None
if offerer.iban:
if iban_count == 0:
iban = iban_prefix
bic = bic_prefix + str(bic_suffix)
iban_count = 1
elif iban_count == 2:
iban_count = 3
else:
if iban_count in (0, 1):
iban = iban_prefix
bic = bic_prefix + str(bic_suffix)
iban_count = 2
elif iban_count == 3:
iban_count = 0

if offerer_index % OFFERERS_WITH_PHYSICAL_VENUE_REMOVE_MODULO == 0:
venue = None
else:
Expand All @@ -91,9 +69,9 @@ def create_industrial_venues(offerers_by_name: dict) -> dict[str, Venue]:
siret = None

bank_account = None
if iban and siret:
if siret:
bank_account = finance_factories.BankAccountFactory(
offerer=offerer, iban=iban, bic=bic, dsApplicationId=application_id_prefix + str(offerer_index)
offerer=offerer, dsApplicationId=application_id_prefix + str(offerer_index)
)

venue = offerers_factories.VenueFactory(
Expand Down Expand Up @@ -138,7 +116,6 @@ def create_industrial_venues(offerers_by_name: dict) -> dict[str, Venue]:
venue_by_name[second_venue_name] = second_venue
mock_accessibility_index += 1

bic_suffix += 1
mock_index += 1

virtual_venue_name = "{} (Offre numérique)"
Expand Down
8 changes: 4 additions & 4 deletions api/src/pcapi/sandboxes/scripts/getters/pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_pro_user_with_financial_data() -> dict:
venue=venue_B,
pricingPoint=venue_B,
)
finance_factories.InvoiceFactory(bankAccount=bank_account_B, reimbursementPoint=venue_B)
finance_factories.InvoiceFactory(bankAccount=bank_account_B)

return {"user": get_pro_user_helper(pro_user)}

Expand All @@ -109,9 +109,9 @@ def create_pro_user_with_financial_data_and_3_venues() -> dict:
venue=venue_E,
pricingPoint=venue_E,
)
finance_factories.InvoiceFactory(bankAccount=bank_account_C, reimbursementPoint=venue_C)
finance_factories.InvoiceFactory(bankAccount=bank_account_C, reimbursementPoint=venue_D)
finance_factories.InvoiceFactory(bankAccount=bank_account_C, reimbursementPoint=venue_E)
finance_factories.InvoiceFactory(bankAccount=bank_account_C)
finance_factories.InvoiceFactory(bankAccount=bank_account_C)
finance_factories.InvoiceFactory(bankAccount=bank_account_C)

return {"user": get_pro_user_helper(pro_user)}

Expand Down
Loading
Loading