Skip to content

Commit

Permalink
feat(Ad): Add price per square meter for real estates ads
Browse files Browse the repository at this point in the history
Fixes #385
  • Loading branch information
bamdadfr committed Mar 26, 2024
1 parent 13293e1 commit 50ef827
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/ad/ad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ export class Ad {
return this.props?.price?.[0].toString() || '?';
}

private getPricePerSquareMeter() {
const price = this.props.price[0];
const square = this.props.attributes.find((attr) => attr.key === 'square');
const squarePrice = Number(square.value);
const pricePerSquareMeter = price / squarePrice;
return pricePerSquareMeter.toFixed(0);
}

private getName() {
return `${this.props.location.zipcode} - ${this.props.list_id} - ${this.props.subject} - ${this.getPrice()} euros`;
}
Expand Down Expand Up @@ -164,6 +172,10 @@ export class Ad {
}
}

private get isRealEstateSale(): boolean {
return this.props.category_name === 'Ventes immobilières';
}

private printAttributes(): void {
// Title
this.pdf.printText({
Expand All @@ -183,6 +195,13 @@ export class Ad {
});
}
});

if (this.isRealEstateSale) {
this.pdf.printText({
text: `Prix au m² : ${this.getPricePerSquareMeter()} €/m²`,
size: FONT_SIZES.small,
});
}
}

private buildDescription(): void {
Expand Down

0 comments on commit 50ef827

Please sign in to comment.