Skip to content

Instantly share code, notes, and snippets.

@adrian-afergon
Created April 21, 2021 17:05
Show Gist options
  • Save adrian-afergon/f151f406daabe3f3071d7b0725af1d81 to your computer and use it in GitHub Desktop.
Save adrian-afergon/f151f406daabe3f3071d7b0725af1d81 to your computer and use it in GitHub Desktop.
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