Created
April 21, 2021 17:05
-
-
Save adrian-afergon/f151f406daabe3f3071d7b0725af1d81 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { inject, injectable } from 'tsyringe' | |
type CustomerId = string | |
interface TimePeriod { | |
start: Date, | |
end: Date | |
} | |
type Amount = number | |
enum Seniority { | |
Senior = 'Sennior', | |
Medior = 'Medior', | |
Junior = 'Junior' | |
} | |
interface Entry { | |
hours: Date, | |
seniotrity: Seniority | |
} | |
interface Timesheets { | |
getEntriesForPeriod: (custommerId: CustomerId, timePeriod: TimePeriod) => Entry[] | |
} | |
interface Personel { | |
seniority: Seniority, | |
rate: Amount | |
} | |
interface Contract { | |
start: Date, | |
end: Date, | |
personel: Personel[], | |
fixedFeePercentage: Amount | |
} | |
interface Contracts { | |
getContractsByPeriod: (custommerId: CustomerId, timePeriod: TimePeriod) => Contract[] | |
} | |
@injectable() | |
export class InvoicingService { | |
constructor (@inject('Contracts') private contracts: Contracts, | |
@inject('Timesheets') private timesheets:Timesheets) { } | |
calculateInvoiceTotal (customerId: CustomerId, timePeriod: TimePeriod): Amount { | |
const contracts = this.contracts.getContractsByPeriod(customerId, timePeriod) | |
const entries = this.timesheets.getEntriesForPeriod(customerId, timePeriod) | |
throw new Error('Method not implemented') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment