-
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.
Merge pull request #54 from LisaPMunich/#49_create-spend-tab_on_plan-…
…page #49 restore original balance after each calculation, create helper se…
- Loading branch information
Showing
11 changed files
with
113 additions
and
117 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
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,38 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class FormattingHelperService { | ||
message: string | null = ''; | ||
icon: string | null = null; | ||
|
||
formatNameInput(event: Event): void { | ||
const input = event.target as HTMLInputElement; | ||
let value = input.value; | ||
value = value.charAt(0).toUpperCase() + value.slice(1).toLowerCase(); | ||
input.value = value; | ||
} | ||
|
||
formatAmountInput(event: Event): void { | ||
const input = event.target as HTMLInputElement; | ||
const value = parseFloat(input.value.replace(',', '.')); | ||
if (!isNaN(value)) { | ||
input.value = this.convertToGermanFormat(value); | ||
} else { | ||
this.icon = '⚠'; | ||
this.message = 'Please enter a valid amount.'; | ||
} | ||
} | ||
|
||
convertToGermanFormat(amount: number): string { | ||
let str = amount.toFixed(2); | ||
str = str.replace('.', ','); | ||
return str; | ||
} | ||
|
||
germanFormatToNumber(amount: string): number { | ||
const numberAmount = amount.replace(',', '.'); | ||
return parseFloat(numberAmount); | ||
} | ||
} |
Oops, something went wrong.