implement payroll generator v0.9
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,714 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type ApprovalState string
|
||||
|
||||
const (
|
||||
ApprovalStateUNKNOWN ApprovalState = "UNKNOWN"
|
||||
ApprovalStateFREE ApprovalState = "FREE"
|
||||
ApprovalStateREQUIRED ApprovalState = "REQUIRED"
|
||||
ApprovalStateREQUESTED ApprovalState = "REQUESTED"
|
||||
ApprovalStateAPPROVED ApprovalState = "APPROVED"
|
||||
)
|
||||
|
||||
func (e *ApprovalState) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = ApprovalState(s)
|
||||
case string:
|
||||
*e = ApprovalState(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for ApprovalState: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullApprovalState struct {
|
||||
ApprovalState ApprovalState `json:"ApprovalState"`
|
||||
Valid bool `json:"valid"` // Valid is true if ApprovalState is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullApprovalState) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.ApprovalState, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.ApprovalState.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullApprovalState) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.ApprovalState), nil
|
||||
}
|
||||
|
||||
type CostTypeVariant string
|
||||
|
||||
const (
|
||||
CostTypeVariantNACHTZUSCHLAG CostTypeVariant = "NACHTZUSCHLAG"
|
||||
CostTypeVariantWOCHENENDZUSCHLAG CostTypeVariant = "WOCHENENDZUSCHLAG"
|
||||
CostTypeVariantFEIERTAGSZUSCHLAG CostTypeVariant = "FEIERTAGSZUSCHLAG"
|
||||
CostTypeVariantDESINFEKTIONSZUSCHLAG CostTypeVariant = "DESINFEKTIONSZUSCHLAG"
|
||||
CostTypeVariantKILOMETERZUSCHLAG CostTypeVariant = "KILOMETERZUSCHLAG"
|
||||
CostTypeVariantFAHRZEUGZUSCHLAG CostTypeVariant = "FAHRZEUGZUSCHLAG"
|
||||
CostTypeVariantTSWDIFFERENZIERUNG CostTypeVariant = "TSWDIFFERENZIERUNG"
|
||||
CostTypeVariantGRUNDPREIS CostTypeVariant = "GRUNDPREIS"
|
||||
CostTypeVariantGRUNDPREISZEIT CostTypeVariant = "GRUNDPREIS_ZEIT"
|
||||
CostTypeVariantPRIVATVERSICHERUNG CostTypeVariant = "PRIVATVERSICHERUNG"
|
||||
CostTypeVariantTRAGEHILFE CostTypeVariant = "TRAGEHILFE"
|
||||
)
|
||||
|
||||
func (e *CostTypeVariant) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = CostTypeVariant(s)
|
||||
case string:
|
||||
*e = CostTypeVariant(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for CostTypeVariant: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullCostTypeVariant struct {
|
||||
CostTypeVariant CostTypeVariant `json:"CostTypeVariant"`
|
||||
Valid bool `json:"valid"` // Valid is true if CostTypeVariant is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullCostTypeVariant) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.CostTypeVariant, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.CostTypeVariant.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullCostTypeVariant) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.CostTypeVariant), nil
|
||||
}
|
||||
|
||||
type TicketState string
|
||||
|
||||
const (
|
||||
TicketStateCREATED TicketState = "CREATED"
|
||||
TicketStateAPPROVALREQUIRED TicketState = "APPROVAL_REQUIRED"
|
||||
TicketStateREADY TicketState = "READY"
|
||||
TicketStateDONE TicketState = "DONE"
|
||||
TicketStateBILLABLE TicketState = "BILLABLE"
|
||||
TicketStateARCHIVED TicketState = "ARCHIVED"
|
||||
)
|
||||
|
||||
func (e *TicketState) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = TicketState(s)
|
||||
case string:
|
||||
*e = TicketState(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for TicketState: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullTicketState struct {
|
||||
TicketState TicketState `json:"TicketState"`
|
||||
Valid bool `json:"valid"` // Valid is true if TicketState is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullTicketState) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.TicketState, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.TicketState.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullTicketState) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.TicketState), nil
|
||||
}
|
||||
|
||||
type TicketValidationState string
|
||||
|
||||
const (
|
||||
TicketValidationStateCREATED TicketValidationState = "CREATED"
|
||||
TicketValidationStateUSERINTERACTIONREQUIRED TicketValidationState = "USER_INTERACTION_REQUIRED"
|
||||
TicketValidationStateTDUNCERTAIN TicketValidationState = "TD_UNCERTAIN"
|
||||
TicketValidationStateDOCUMENTSMISSING TicketValidationState = "DOCUMENTS_MISSING"
|
||||
TicketValidationStateARCHIVED TicketValidationState = "ARCHIVED"
|
||||
)
|
||||
|
||||
func (e *TicketValidationState) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = TicketValidationState(s)
|
||||
case string:
|
||||
*e = TicketValidationState(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for TicketValidationState: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullTicketValidationState struct {
|
||||
TicketValidationState TicketValidationState `json:"TicketValidationState"`
|
||||
Valid bool `json:"valid"` // Valid is true if TicketValidationState is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullTicketValidationState) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.TicketValidationState, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.TicketValidationState.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullTicketValidationState) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.TicketValidationState), nil
|
||||
}
|
||||
|
||||
type Anomaly struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
GroupKey string `json:"groupKey"`
|
||||
GroupDescription string `json:"groupDescription"`
|
||||
WorkedOnBy string `json:"workedOnBy"`
|
||||
SleepTimer int32 `json:"sleepTimer"`
|
||||
SleepSince *time.Time `json:"sleepSince"`
|
||||
ResolvedAt *time.Time `json:"resolvedAt"`
|
||||
ManuallyResolved bool `json:"manuallyResolved"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
AssociatedEntities []byte `json:"associatedEntities"`
|
||||
}
|
||||
|
||||
type AttendanceRegistration struct {
|
||||
AttendanceRegistrationId int32 `json:"attendanceRegistrationId"`
|
||||
EmployeeId int32 `json:"employeeId"`
|
||||
PersonnelNumber string `json:"personnelNumber"`
|
||||
DateTime time.Time `json:"dateTime"`
|
||||
Event string `json:"event"`
|
||||
}
|
||||
|
||||
type AttendanceRegistrationSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
AttendanceRegistrationId pgtype.Text `json:"attendanceRegistrationId"`
|
||||
EmployeeId pgtype.Text `json:"employeeId"`
|
||||
PersonnelNumber pgtype.Text `json:"personnelNumber"`
|
||||
DateTime pgtype.Text `json:"dateTime"`
|
||||
Event pgtype.Text `json:"event"`
|
||||
}
|
||||
|
||||
type AttendanceRegistrationStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
AttendanceRegistrationId int32 `json:"attendanceRegistrationId"`
|
||||
EmployeeId int32 `json:"employeeId"`
|
||||
DateTime time.Time `json:"dateTime"`
|
||||
Event string `json:"event"`
|
||||
}
|
||||
|
||||
type AvicennaTenant struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
HealthInsuranceNumber string `json:"healthInsuranceNumber"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type AvicennaTenantToTariffGroup struct {
|
||||
A pgtype.UUID `json:"A"`
|
||||
B pgtype.UUID `json:"B"`
|
||||
}
|
||||
|
||||
type CostType struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Description string `json:"description"`
|
||||
Variant CostTypeVariant `json:"variant"`
|
||||
CostAmount int32 `json:"costAmount"`
|
||||
TimeRange pgtype.Text `json:"timeRange"`
|
||||
KmInclusive pgtype.Int4 `json:"kmInclusive"`
|
||||
ExcludeCarNames []string `json:"excludeCarNames"`
|
||||
InfectionType pgtype.Text `json:"infectionType"`
|
||||
TariffId pgtype.UUID `json:"tariffId"`
|
||||
}
|
||||
|
||||
type DyflexisEmployee struct {
|
||||
ID int32 `json:"id"`
|
||||
Firstname string `json:"firstname"`
|
||||
Surname string `json:"surname"`
|
||||
ContractStart time.Time `json:"contractStart"`
|
||||
ContractEnd *time.Time `json:"contractEnd"`
|
||||
ContractHoursWeek float64 `json:"contractHoursWeek"`
|
||||
ContractSalaryHour float64 `json:"contractSalaryHour"`
|
||||
ContractTypeName pgtype.Text `json:"contractTypeName"`
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
}
|
||||
|
||||
type Employee struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Surname string `json:"surname"`
|
||||
PersonnelNumber pgtype.Text `json:"personnelNumber"`
|
||||
Mobile pgtype.Text `json:"mobile"`
|
||||
Qualification pgtype.Text `json:"qualification"`
|
||||
OccuptationalHealthExamination *time.Time `json:"occuptationalHealthExamination"`
|
||||
PersonTransportCertificate *time.Time `json:"personTransportCertificate"`
|
||||
}
|
||||
|
||||
type EmployeeDispoLiveSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
PScheinAblaufDatum pgtype.Text `json:"pScheinAblaufDatum"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
PersId pgtype.Text `json:"persId"`
|
||||
ImportPersId pgtype.Text `json:"importPersId"`
|
||||
Qualifikation pgtype.Text `json:"qualifikation"`
|
||||
}
|
||||
|
||||
type EmployeeDispoLiveStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID string `json:"id"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
PersonnelNumber pgtype.Text `json:"personnelNumber"`
|
||||
Qualification pgtype.Text `json:"qualification"`
|
||||
PersonTransportCertificate *time.Time `json:"personTransportCertificate"`
|
||||
}
|
||||
|
||||
type EmployeeDyflexisSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
Firstname pgtype.Text `json:"firstname"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
ContractID pgtype.Text `json:"contract_id"`
|
||||
ContractStart pgtype.Text `json:"contract_start"`
|
||||
ContractEnd pgtype.Text `json:"contract_end"`
|
||||
ContractHoursWeek pgtype.Text `json:"contract_hours_week"`
|
||||
ContractSalaryHour pgtype.Text `json:"contract_salary_hour"`
|
||||
ContractTypeName pgtype.Text `json:"contract_type_name"`
|
||||
}
|
||||
|
||||
type EmployeeDyflexisStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID int32 `json:"id"`
|
||||
Firstname string `json:"firstname"`
|
||||
Surname string `json:"surname"`
|
||||
ContractStart time.Time `json:"contractStart"`
|
||||
ContractEnd time.Time `json:"contractEnd"`
|
||||
ContractHoursWeek float64 `json:"contractHoursWeek"`
|
||||
ContractSalaryHour float64 `json:"contractSalaryHour"`
|
||||
ContractTypeName pgtype.Text `json:"contractTypeName"`
|
||||
}
|
||||
|
||||
type Patient struct {
|
||||
ID string `json:"id"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Street pgtype.Text `json:"street"`
|
||||
Zip pgtype.Text `json:"zip"`
|
||||
City pgtype.Text `json:"city"`
|
||||
Birthday *time.Time `json:"birthday"`
|
||||
HealthinsuranceId pgtype.Text `json:"healthinsuranceId"`
|
||||
Healthinsurance pgtype.Text `json:"healthinsurance"`
|
||||
CareDegree pgtype.Text `json:"careDegree"`
|
||||
DisabilityMark1 pgtype.Text `json:"disabilityMark1"`
|
||||
DisabilityMark2 pgtype.Text `json:"disabilityMark2"`
|
||||
}
|
||||
|
||||
type PatientSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Street pgtype.Text `json:"street"`
|
||||
Zip pgtype.Text `json:"zip"`
|
||||
City pgtype.Text `json:"city"`
|
||||
Birthday pgtype.Text `json:"birthday"`
|
||||
KkId pgtype.Text `json:"kkId"`
|
||||
Krankenkasse pgtype.Text `json:"krankenkasse"`
|
||||
Pflegestufe pgtype.Text `json:"pflegestufe"`
|
||||
Behinderung1 pgtype.Text `json:"behinderung1"`
|
||||
Behinderung2 pgtype.Text `json:"behinderung2"`
|
||||
}
|
||||
|
||||
type PatientStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Street pgtype.Text `json:"street"`
|
||||
Zip pgtype.Text `json:"zip"`
|
||||
City pgtype.Text `json:"city"`
|
||||
Birthday *time.Time `json:"birthday"`
|
||||
HealthinsuranceId pgtype.Text `json:"healthinsuranceId"`
|
||||
Healthinsurance pgtype.Text `json:"healthinsurance"`
|
||||
CareDegree pgtype.Text `json:"careDegree"`
|
||||
DisabilityMark1 pgtype.Text `json:"disabilityMark1"`
|
||||
DisabilityMark2 pgtype.Text `json:"disabilityMark2"`
|
||||
}
|
||||
|
||||
type PlannedTime struct {
|
||||
ID string `json:"id"`
|
||||
UserId string `json:"userId"`
|
||||
Firstname pgtype.Text `json:"firstname"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Department pgtype.Text `json:"department"`
|
||||
Pause int32 `json:"pause"`
|
||||
Duration int32 `json:"duration"`
|
||||
Note pgtype.Text `json:"note"`
|
||||
}
|
||||
|
||||
type PlannedTimeSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
UserID pgtype.Text `json:"user_id"`
|
||||
Firstname pgtype.Text `json:"firstname"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
DepartmentID pgtype.Text `json:"department_id"`
|
||||
DepartmentName pgtype.Text `json:"department_name"`
|
||||
StartDate pgtype.Text `json:"start_date"`
|
||||
EndDate pgtype.Text `json:"end_date"`
|
||||
Pauze pgtype.Text `json:"pauze"`
|
||||
Duration pgtype.Text `json:"duration"`
|
||||
Deleted pgtype.Text `json:"deleted"`
|
||||
Mark pgtype.Text `json:"mark"`
|
||||
}
|
||||
|
||||
type PlannedTimeStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID int32 `json:"id"`
|
||||
EmployeeId int32 `json:"employeeId"`
|
||||
Firstname pgtype.Text `json:"firstname"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
DepartmentName pgtype.Text `json:"departmentName"`
|
||||
StartDate time.Time `json:"startDate"`
|
||||
EndDate time.Time `json:"endDate"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Mark pgtype.Text `json:"mark"`
|
||||
Duration int32 `json:"duration"`
|
||||
Pause int32 `json:"pause"`
|
||||
}
|
||||
|
||||
type PrismaMigration struct {
|
||||
ID string `json:"id"`
|
||||
Checksum string `json:"checksum"`
|
||||
FinishedAt *time.Time `json:"finished_at"`
|
||||
MigrationName string `json:"migration_name"`
|
||||
Logs pgtype.Text `json:"logs"`
|
||||
RolledBackAt *time.Time `json:"rolled_back_at"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
AppliedStepsCount int32 `json:"applied_steps_count"`
|
||||
}
|
||||
|
||||
type SolutionTarget struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AnomalyId pgtype.Text `json:"anomalyId"`
|
||||
}
|
||||
|
||||
type SolutionTargetStep struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Description string `json:"description"`
|
||||
SolutionTargetId pgtype.UUID `json:"solutionTargetId"`
|
||||
}
|
||||
|
||||
type Tariff struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ValidFrom *time.Time `json:"validFrom"`
|
||||
ValidTo *time.Time `json:"validTo"`
|
||||
TariffGroupId pgtype.UUID `json:"tariffGroupId"`
|
||||
}
|
||||
|
||||
type TariffGroup struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Description string `json:"description"`
|
||||
OrdinanceType string `json:"ordinanceType"`
|
||||
}
|
||||
|
||||
type Ticket struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
CurrentState TicketValidationState `json:"currentState"`
|
||||
Notes []string `json:"notes"`
|
||||
Errors []string `json:"errors"`
|
||||
IsUrgent bool `json:"isUrgent"`
|
||||
Urgency time.Time `json:"urgency"`
|
||||
ApprovalState NullApprovalState `json:"approvalState"`
|
||||
DocumentInfo []byte `json:"documentInfo"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
type TicketStateHistory struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
State TicketValidationState `json:"state"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
TicketId pgtype.UUID `json:"ticketId"`
|
||||
}
|
||||
|
||||
type Tour struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Done bool `json:"done"`
|
||||
Direction string `json:"direction"`
|
||||
CarName pgtype.Text `json:"carName"`
|
||||
OperationId string `json:"operationId"`
|
||||
DriverId pgtype.Text `json:"driverId"`
|
||||
DriverName pgtype.Text `json:"driverName"`
|
||||
CodriverId pgtype.Text `json:"codriverId"`
|
||||
CodriverName pgtype.Text `json:"codriverName"`
|
||||
PatientId pgtype.Text `json:"patientId"`
|
||||
PatientName pgtype.Text `json:"patientName"`
|
||||
PatientSurname pgtype.Text `json:"patientSurname"`
|
||||
PatientStreet pgtype.Text `json:"patientStreet"`
|
||||
PatientZip pgtype.Text `json:"patientZip"`
|
||||
PatientCity pgtype.Text `json:"patientCity"`
|
||||
HealthInsurance pgtype.Text `json:"healthInsurance"`
|
||||
HealthInsuranceNumber pgtype.Text `json:"healthInsuranceNumber"`
|
||||
Type pgtype.Text `json:"type"`
|
||||
Category pgtype.Text `json:"category"`
|
||||
TransportType pgtype.Text `json:"transportType"`
|
||||
OrdinanceType pgtype.Text `json:"ordinanceType"`
|
||||
RangeEndDate *time.Time `json:"rangeEndDate"`
|
||||
StartInstitution pgtype.Text `json:"startInstitution"`
|
||||
StartStreet pgtype.Text `json:"startStreet"`
|
||||
StartZip pgtype.Text `json:"startZip"`
|
||||
StartCity pgtype.Text `json:"startCity"`
|
||||
TargetInstitution pgtype.Text `json:"targetInstitution"`
|
||||
TargetStreet pgtype.Text `json:"targetStreet"`
|
||||
TargetZip pgtype.Text `json:"targetZip"`
|
||||
TargetCity pgtype.Text `json:"targetCity"`
|
||||
StartDate time.Time `json:"startDate"`
|
||||
Check int32 `json:"check"`
|
||||
OccupiedKm pgtype.Float8 `json:"occupiedKm"`
|
||||
TotalKm pgtype.Float8 `json:"totalKm"`
|
||||
StartBegin pgtype.Text `json:"startBegin"`
|
||||
StartEnd pgtype.Text `json:"startEnd"`
|
||||
Target pgtype.Text `json:"target"`
|
||||
TargetBegin pgtype.Text `json:"targetBegin"`
|
||||
Empty pgtype.Text `json:"empty"`
|
||||
HasInfection bool `json:"hasInfection"`
|
||||
InfectionName pgtype.Text `json:"infectionName"`
|
||||
RevenueDispoLive pgtype.Float8 `json:"revenueDispoLive"`
|
||||
BillDate *time.Time `json:"billDate"`
|
||||
BillNumber pgtype.Text `json:"billNumber"`
|
||||
Revenue float64 `json:"revenue"`
|
||||
ConsumptionCosts float64 `json:"consumptionCosts"`
|
||||
RevenueDeviation float64 `json:"revenueDeviation"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt"`
|
||||
TicketId pgtype.UUID `json:"ticketId"`
|
||||
UpdatedAt *time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type TourSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
Check pgtype.Text `json:"check"`
|
||||
CreateTime pgtype.Text `json:"createTime"`
|
||||
EmpfangenVonId pgtype.Text `json:"empfangenVonId"`
|
||||
Endgen pgtype.Text `json:"endgen"`
|
||||
SerienId pgtype.Text `json:"serienId"`
|
||||
SerienKategorName pgtype.Text `json:"serienKategorName"`
|
||||
SerienKategorie pgtype.Text `json:"serienKategorie"`
|
||||
ZadStatus pgtype.Text `json:"zadStatus"`
|
||||
AbrDate pgtype.Text `json:"abrDate"`
|
||||
AbrNum pgtype.Text `json:"abrNum"`
|
||||
AbrTime pgtype.Text `json:"abrTime"`
|
||||
AusrueckZeit pgtype.Text `json:"ausrueckZeit"`
|
||||
StartTime pgtype.Text `json:"startTime"`
|
||||
StartDate pgtype.Text `json:"startDate"`
|
||||
Date pgtype.Text `json:"date"`
|
||||
DateIso pgtype.Text `json:"date_iso"`
|
||||
Dauergenehmigung pgtype.Text `json:"dauergenehmigung"`
|
||||
Direction pgtype.Text `json:"direction"`
|
||||
DistanceValue pgtype.Text `json:"distanceValue"`
|
||||
BesetztKm pgtype.Text `json:"besetztKm"`
|
||||
Gefahren pgtype.Text `json:"gefahren"`
|
||||
GesamtPreis pgtype.Text `json:"gesamtPreis"`
|
||||
Infektion pgtype.Text `json:"infektion"`
|
||||
ItDesc pgtype.Text `json:"itDesc"`
|
||||
ItKrz pgtype.Text `json:"itKrz"`
|
||||
ItName pgtype.Text `json:"itName"`
|
||||
KkId pgtype.Text `json:"kkId"`
|
||||
Krankenkasse pgtype.Text `json:"krankenkasse"`
|
||||
PatId pgtype.Text `json:"patId"`
|
||||
PatName pgtype.Text `json:"patName"`
|
||||
PatSurname pgtype.Text `json:"patSurname"`
|
||||
PatStreet pgtype.Text `json:"patStreet"`
|
||||
PatZip pgtype.Text `json:"patZip"`
|
||||
PatCity pgtype.Text `json:"patCity"`
|
||||
StartInstitution pgtype.Text `json:"startInstitution"`
|
||||
StartStreet pgtype.Text `json:"startStreet"`
|
||||
StartZip pgtype.Text `json:"startZip"`
|
||||
StartCity pgtype.Text `json:"startCity"`
|
||||
TargetInstitution pgtype.Text `json:"targetInstitution"`
|
||||
TargetStreet pgtype.Text `json:"targetStreet"`
|
||||
TargetZip pgtype.Text `json:"targetZip"`
|
||||
TargetCity pgtype.Text `json:"targetCity"`
|
||||
TransportKrz pgtype.Text `json:"transportKrz"`
|
||||
TransportName pgtype.Text `json:"transportName"`
|
||||
Transportart pgtype.Text `json:"transportart"`
|
||||
VerordnungsId pgtype.Text `json:"verordnungsId"`
|
||||
VerordnungsName pgtype.Text `json:"verordnungsName"`
|
||||
Type pgtype.Text `json:"type"`
|
||||
StartBegin pgtype.Text `json:"startBegin"`
|
||||
StartEnd pgtype.Text `json:"startEnd"`
|
||||
Frei pgtype.Text `json:"frei"`
|
||||
Ziel pgtype.Text `json:"ziel"`
|
||||
ZielBegin pgtype.Text `json:"zielBegin"`
|
||||
EndTime pgtype.Text `json:"endTime"`
|
||||
EndDate pgtype.Text `json:"endDate"`
|
||||
EinsatzNummer pgtype.Text `json:"einsatzNummer"`
|
||||
CarName pgtype.Text `json:"carName"`
|
||||
CarNo pgtype.Text `json:"carNo"`
|
||||
BeifahrerName pgtype.Text `json:"beifahrerName"`
|
||||
Beifahrer pgtype.Text `json:"beifahrer"`
|
||||
FahrerName pgtype.Text `json:"fahrerName"`
|
||||
Fahrer pgtype.Text `json:"fahrer"`
|
||||
Color pgtype.Text `json:"color"`
|
||||
LastUpdate pgtype.Text `json:"lastUpdate"`
|
||||
}
|
||||
|
||||
type TourStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
Done pgtype.Bool `json:"done"`
|
||||
Direction pgtype.Text `json:"direction"`
|
||||
CarName pgtype.Text `json:"carName"`
|
||||
OperationId pgtype.Text `json:"operationId"`
|
||||
DriverId pgtype.Text `json:"driverId"`
|
||||
DriverName pgtype.Text `json:"driverName"`
|
||||
CodriverId pgtype.Text `json:"codriverId"`
|
||||
CodriverName pgtype.Text `json:"codriverName"`
|
||||
PatientId pgtype.Text `json:"patientId"`
|
||||
PatientName pgtype.Text `json:"patientName"`
|
||||
PatientSurname pgtype.Text `json:"patientSurname"`
|
||||
PatientStreet pgtype.Text `json:"patientStreet"`
|
||||
PatientZip pgtype.Text `json:"patientZip"`
|
||||
PatientCity pgtype.Text `json:"patientCity"`
|
||||
HealthInsurance pgtype.Text `json:"healthInsurance"`
|
||||
HealthInsuranceNumber pgtype.Text `json:"healthInsuranceNumber"`
|
||||
Type pgtype.Text `json:"type"`
|
||||
Category pgtype.Text `json:"category"`
|
||||
TransportType pgtype.Text `json:"transportType"`
|
||||
OrdinanceType pgtype.Text `json:"ordinanceType"`
|
||||
RangeEndDate *time.Time `json:"rangeEndDate"`
|
||||
StartInstitution pgtype.Text `json:"startInstitution"`
|
||||
StartStreet pgtype.Text `json:"startStreet"`
|
||||
StartZip pgtype.Text `json:"startZip"`
|
||||
StartCity pgtype.Text `json:"startCity"`
|
||||
TargetInstitution pgtype.Text `json:"targetInstitution"`
|
||||
TargetStreet pgtype.Text `json:"targetStreet"`
|
||||
TargetZip pgtype.Text `json:"targetZip"`
|
||||
TargetCity pgtype.Text `json:"targetCity"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
Check int32 `json:"check"`
|
||||
OccupiedKm pgtype.Float8 `json:"occupiedKm"`
|
||||
TotalKm pgtype.Float8 `json:"totalKm"`
|
||||
StartBegin pgtype.Text `json:"startBegin"`
|
||||
StartEnd pgtype.Text `json:"startEnd"`
|
||||
Target pgtype.Text `json:"target"`
|
||||
TargetBegin pgtype.Text `json:"targetBegin"`
|
||||
Empty pgtype.Text `json:"empty"`
|
||||
HasInfection bool `json:"hasInfection"`
|
||||
InfectionName pgtype.Text `json:"infectionName"`
|
||||
RevenueDispoLive pgtype.Float8 `json:"revenueDispoLive"`
|
||||
BillDate *time.Time `json:"billDate"`
|
||||
BillNumber pgtype.Text `json:"billNumber"`
|
||||
Revenue float64 `json:"revenue"`
|
||||
RevenueDeviation float64 `json:"revenueDeviation"`
|
||||
ConsumptionCosts float64 `json:"consumptionCosts"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
UpdatedAt *time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type Trace struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Type string `json:"type"`
|
||||
EntityKey string `json:"entityKey"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
type WorkTime struct {
|
||||
ID string `json:"id"`
|
||||
UserId string `json:"userId"`
|
||||
Firstname string `json:"firstname"`
|
||||
Surname string `json:"surname"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Department pgtype.Text `json:"department"`
|
||||
Pause int32 `json:"pause"`
|
||||
Duration int32 `json:"duration"`
|
||||
}
|
||||
|
||||
type WorkTimeSource struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
InsertedAt time.Time `json:"insertedAt"`
|
||||
JobId string `json:"jobId"`
|
||||
ID pgtype.Text `json:"id"`
|
||||
UserID pgtype.Text `json:"user_id"`
|
||||
Firstname pgtype.Text `json:"firstname"`
|
||||
Surname pgtype.Text `json:"surname"`
|
||||
DepartmentID pgtype.Text `json:"department_id"`
|
||||
DepartmentName pgtype.Text `json:"department_name"`
|
||||
StartDate pgtype.Text `json:"start_date"`
|
||||
EndDate pgtype.Text `json:"end_date"`
|
||||
Pauze pgtype.Text `json:"pauze"`
|
||||
Duration pgtype.Text `json:"duration"`
|
||||
}
|
||||
|
||||
type WorkTimeStaging struct {
|
||||
InternalId pgtype.UUID `json:"internalId"`
|
||||
ID int32 `json:"id"`
|
||||
EmployeeId int32 `json:"employeeId"`
|
||||
Firstname string `json:"firstname"`
|
||||
Surname string `json:"surname"`
|
||||
DepartmentName pgtype.Text `json:"departmentName"`
|
||||
StartDate time.Time `json:"startDate"`
|
||||
EndDate time.Time `json:"endDate"`
|
||||
Duration int32 `json:"duration"`
|
||||
Pause int32 `json:"pause"`
|
||||
}
|
||||
@@ -0,0 +1,490 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: payroll.sql
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const countTourengeldAmountInPeriod = `-- name: CountTourengeldAmountInPeriod :one
|
||||
WITH ToursInPeriod AS (
|
||||
SELECT
|
||||
(("startDate" AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/Berlin')::DATE as day,
|
||||
"operationId",
|
||||
"occupiedKm",
|
||||
CASE
|
||||
WHEN "occupiedKm" <= 30 THEN 1.0
|
||||
ELSE ROUND("occupiedKm" / 30.0)
|
||||
END AS tour_value,
|
||||
CASE
|
||||
WHEN EXTRACT(ISODOW FROM "startDate") = 6 AND "occupiedKm" <= 30 THEN 0.5
|
||||
ELSE 0.0
|
||||
END AS weekend_bonus,
|
||||
"infectionName",
|
||||
CASE
|
||||
WHEN "infectionName" = 'Covid-19' THEN 0.5
|
||||
ELSE 0.0
|
||||
END AS infection_bonus
|
||||
FROM
|
||||
"Tour"
|
||||
WHERE
|
||||
"check" <> 3
|
||||
AND "deletedAt" IS NULL
|
||||
AND (
|
||||
"patientId" IS NULL
|
||||
OR "patientId" NOT IN (
|
||||
'b7424477-a4b2-42f7-b7e7-a4bef24f6979',
|
||||
'3554e1a9-9c07-45e5-b53c-692a77e4fa9a'
|
||||
)
|
||||
)
|
||||
-- ID's for Pause and Feierabend respectively
|
||||
AND (
|
||||
"carName" IS NULL
|
||||
OR "carName" NOT IN (
|
||||
'Storno',
|
||||
'Abgabe',
|
||||
'Löschen'
|
||||
)
|
||||
AND "carName" LIKE '%KTW%'
|
||||
)
|
||||
AND "startDate" >= $1
|
||||
AND "startDate" <= $2
|
||||
AND ("driverId" ILIKE $3 OR "codriverId" ILIKE $3)
|
||||
ORDER BY
|
||||
"day"
|
||||
),
|
||||
DailyCounts AS (
|
||||
SELECT
|
||||
day,
|
||||
SUM(tour_value) + SUM(weekend_bonus) + SUM(infection_bonus) AS tour_amount
|
||||
FROM
|
||||
ToursInPeriod
|
||||
GROUP BY
|
||||
day
|
||||
),
|
||||
HighActivityDays AS (
|
||||
SELECT
|
||||
day,
|
||||
GREATEST(0, tour_amount - 6) AS tourengeld
|
||||
FROM
|
||||
DailyCounts
|
||||
)
|
||||
SELECT
|
||||
SUM(tourengeld)::float as tourengeld
|
||||
FROM
|
||||
HighActivityDays
|
||||
`
|
||||
|
||||
type CountTourengeldAmountInPeriodParams struct {
|
||||
StartDate time.Time `json:"start_date"`
|
||||
EndDate time.Time `json:"end_date"`
|
||||
EmployeeID pgtype.Text `json:"employee_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CountTourengeldAmountInPeriod(ctx context.Context, arg CountTourengeldAmountInPeriodParams) (float64, error) {
|
||||
row := q.db.QueryRow(ctx, countTourengeldAmountInPeriod, arg.StartDate, arg.EndDate, arg.EmployeeID)
|
||||
var tourengeld float64
|
||||
err := row.Scan(&tourengeld)
|
||||
return tourengeld, err
|
||||
}
|
||||
|
||||
const fetchDrivenToursInInterval = `-- name: FetchDrivenToursInInterval :many
|
||||
SELECT id, done, direction, "carName", "operationId", "driverId", "driverName", "codriverId", "codriverName", "patientId", "patientName", "patientSurname", "patientStreet", "patientZip", "patientCity", "healthInsurance", "healthInsuranceNumber", type, category, "transportType", "ordinanceType", "rangeEndDate", "startInstitution", "startStreet", "startZip", "startCity", "targetInstitution", "targetStreet", "targetZip", "targetCity", "startDate", "check", "occupiedKm", "totalKm", "startBegin", "startEnd", target, "targetBegin", empty, "hasInfection", "infectionName", "revenueDispoLive", "billDate", "billNumber", revenue, "consumptionCosts", "revenueDeviation", "createdAt", "deletedAt", "ticketId", "updatedAt" FROM "Tour"
|
||||
WHERE "check" <> 3
|
||||
AND "deletedAt" IS NULL
|
||||
AND (
|
||||
"patientId" IS NULL
|
||||
OR "patientId" NOT IN (
|
||||
'b7424477-a4b2-42f7-b7e7-a4bef24f6979',
|
||||
'3554e1a9-9c07-45e5-b53c-692a77e4fa9a'
|
||||
)
|
||||
)
|
||||
AND (
|
||||
"carName" IS NULL
|
||||
OR "carName" NOT IN (
|
||||
'Storno',
|
||||
'Abgabe',
|
||||
'Löschen'
|
||||
)
|
||||
)
|
||||
AND "startDate" >= $1
|
||||
AND "startDate" <= $2
|
||||
AND ("driverId" = $3 OR "codriverId" = $3)
|
||||
ORDER BY "startDate" DESC
|
||||
`
|
||||
|
||||
type FetchDrivenToursInIntervalParams struct {
|
||||
StartDate time.Time `json:"start_date"`
|
||||
EndDate time.Time `json:"end_date"`
|
||||
EmployeeID pgtype.Text `json:"employee_id"`
|
||||
}
|
||||
|
||||
// ID's for Pause and Feierabend respectively
|
||||
func (q *Queries) FetchDrivenToursInInterval(ctx context.Context, arg FetchDrivenToursInIntervalParams) ([]Tour, error) {
|
||||
rows, err := q.db.Query(ctx, fetchDrivenToursInInterval, arg.StartDate, arg.EndDate, arg.EmployeeID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Tour
|
||||
for rows.Next() {
|
||||
var i Tour
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Done,
|
||||
&i.Direction,
|
||||
&i.CarName,
|
||||
&i.OperationId,
|
||||
&i.DriverId,
|
||||
&i.DriverName,
|
||||
&i.CodriverId,
|
||||
&i.CodriverName,
|
||||
&i.PatientId,
|
||||
&i.PatientName,
|
||||
&i.PatientSurname,
|
||||
&i.PatientStreet,
|
||||
&i.PatientZip,
|
||||
&i.PatientCity,
|
||||
&i.HealthInsurance,
|
||||
&i.HealthInsuranceNumber,
|
||||
&i.Type,
|
||||
&i.Category,
|
||||
&i.TransportType,
|
||||
&i.OrdinanceType,
|
||||
&i.RangeEndDate,
|
||||
&i.StartInstitution,
|
||||
&i.StartStreet,
|
||||
&i.StartZip,
|
||||
&i.StartCity,
|
||||
&i.TargetInstitution,
|
||||
&i.TargetStreet,
|
||||
&i.TargetZip,
|
||||
&i.TargetCity,
|
||||
&i.StartDate,
|
||||
&i.Check,
|
||||
&i.OccupiedKm,
|
||||
&i.TotalKm,
|
||||
&i.StartBegin,
|
||||
&i.StartEnd,
|
||||
&i.Target,
|
||||
&i.TargetBegin,
|
||||
&i.Empty,
|
||||
&i.HasInfection,
|
||||
&i.InfectionName,
|
||||
&i.RevenueDispoLive,
|
||||
&i.BillDate,
|
||||
&i.BillNumber,
|
||||
&i.Revenue,
|
||||
&i.ConsumptionCosts,
|
||||
&i.RevenueDeviation,
|
||||
&i.CreatedAt,
|
||||
&i.DeletedAt,
|
||||
&i.TicketId,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getEmployeeByName = `-- name: GetEmployeeByName :one
|
||||
SELECT
|
||||
dy.id as dyflexis_id,
|
||||
dl.id as dispolive_id,
|
||||
dy."contractSalaryHour"
|
||||
FROM "DyflexisEmployee" as dy
|
||||
INNER JOIN
|
||||
"Employee" as dl ON dy.id::text = dl."personnelNumber"
|
||||
WHERE
|
||||
TRIM(dy.firstname) = $1 AND
|
||||
TRIM(dy.surname) = $2 AND
|
||||
"contractStart" < CURRENT_DATE AND
|
||||
"contractEnd" > (CURRENT_DATE - INTERVAL '2 months')
|
||||
ORDER BY dy."contractEnd" DESC
|
||||
`
|
||||
|
||||
type GetEmployeeByNameParams struct {
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
}
|
||||
|
||||
type GetEmployeeByNameRow struct {
|
||||
DyflexisID int32 `json:"dyflexis_id"`
|
||||
DispoliveID string `json:"dispolive_id"`
|
||||
ContractSalaryHour float64 `json:"contractSalaryHour"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetEmployeeByName(ctx context.Context, arg GetEmployeeByNameParams) (GetEmployeeByNameRow, error) {
|
||||
row := q.db.QueryRow(ctx, getEmployeeByName, arg.Firstname, arg.Lastname)
|
||||
var i GetEmployeeByNameRow
|
||||
err := row.Scan(&i.DyflexisID, &i.DispoliveID, &i.ContractSalaryHour)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getEmployeeDyflexis = `-- name: GetEmployeeDyflexis :one
|
||||
SELECT id, firstname, surname, "contractStart", "contractEnd", "contractHoursWeek", "contractSalaryHour", "contractTypeName", "internalId" FROM "DyflexisEmployee"
|
||||
WHERE
|
||||
id = $1 AND
|
||||
"contractStart" < CURRENT_DATE AND
|
||||
"contractEnd" > (CURRENT_DATE - INTERVAL '2 months')
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetEmployeeDyflexis(ctx context.Context, id int32) (DyflexisEmployee, error) {
|
||||
row := q.db.QueryRow(ctx, getEmployeeDyflexis, id)
|
||||
var i DyflexisEmployee
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Firstname,
|
||||
&i.Surname,
|
||||
&i.ContractStart,
|
||||
&i.ContractEnd,
|
||||
&i.ContractHoursWeek,
|
||||
&i.ContractSalaryHour,
|
||||
&i.ContractTypeName,
|
||||
&i.InternalId,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSicknessSummaryForEmployeeInPeriod = `-- name: GetSicknessSummaryForEmployeeInPeriod :one
|
||||
WITH pt AS (
|
||||
SELECT
|
||||
COUNT(*) as days,
|
||||
COALESCE(sum(duration), 0)::bigint as minutes
|
||||
FROM "PlannedTime"
|
||||
WHERE "userId" = $1 AND "startDate" > $2 AND "startDate" < $3 AND note = 'sick'
|
||||
)
|
||||
SELECT
|
||||
pt.days,
|
||||
(minutes / 60)::float as hours,
|
||||
pt.minutes
|
||||
FROM pt
|
||||
`
|
||||
|
||||
type GetSicknessSummaryForEmployeeInPeriodParams struct {
|
||||
EmployeeID string `json:"employee_id"`
|
||||
StartDate *time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
type GetSicknessSummaryForEmployeeInPeriodRow struct {
|
||||
Days int64 `json:"days"`
|
||||
Hours float64 `json:"hours"`
|
||||
Minutes int64 `json:"minutes"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetSicknessSummaryForEmployeeInPeriod(ctx context.Context, arg GetSicknessSummaryForEmployeeInPeriodParams) (GetSicknessSummaryForEmployeeInPeriodRow, error) {
|
||||
row := q.db.QueryRow(ctx, getSicknessSummaryForEmployeeInPeriod, arg.EmployeeID, arg.StartDate, arg.EndDate)
|
||||
var i GetSicknessSummaryForEmployeeInPeriodRow
|
||||
err := row.Scan(&i.Days, &i.Hours, &i.Minutes)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getWorkSummaryForEmployeeInPeriod = `-- name: GetWorkSummaryForEmployeeInPeriod :one
|
||||
WITH wt AS (
|
||||
SELECT
|
||||
COUNT(*) as days,
|
||||
COALESCE(sum(duration), 0)::bigint as minutes
|
||||
FROM "WorkTime"
|
||||
WHERE "userId" = $1 AND "startDate" > $2 AND "startDate" < $3
|
||||
)
|
||||
SELECT
|
||||
wt.days,
|
||||
(minutes / 60.0)::float as hours,
|
||||
wt.minutes
|
||||
FROM wt
|
||||
`
|
||||
|
||||
type GetWorkSummaryForEmployeeInPeriodParams struct {
|
||||
EmployeeID string `json:"employee_id"`
|
||||
StartDate *time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
type GetWorkSummaryForEmployeeInPeriodRow struct {
|
||||
Days int64 `json:"days"`
|
||||
Hours float64 `json:"hours"`
|
||||
Minutes int64 `json:"minutes"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetWorkSummaryForEmployeeInPeriod(ctx context.Context, arg GetWorkSummaryForEmployeeInPeriodParams) (GetWorkSummaryForEmployeeInPeriodRow, error) {
|
||||
row := q.db.QueryRow(ctx, getWorkSummaryForEmployeeInPeriod, arg.EmployeeID, arg.StartDate, arg.EndDate)
|
||||
var i GetWorkSummaryForEmployeeInPeriodRow
|
||||
err := row.Scan(&i.Days, &i.Hours, &i.Minutes)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listActiveEmployees = `-- name: ListActiveEmployees :many
|
||||
SELECT
|
||||
de.id,
|
||||
de.firstname,
|
||||
de.surname,
|
||||
de."contractStart",
|
||||
de."contractEnd",
|
||||
de."contractHoursWeek",
|
||||
de."contractSalaryHour",
|
||||
de."contractTypeName",
|
||||
e.id as "dlId",
|
||||
e."personTransportCertificate"
|
||||
FROM "DyflexisEmployee" as de
|
||||
INNER JOIN "Employee" as e ON de.id::text = e."personnelNumber"
|
||||
WHERE de."contractStart" < CURRENT_DATE AND de."contractEnd" > (CURRENT_DATE - INTERVAL '2 months')
|
||||
`
|
||||
|
||||
type ListActiveEmployeesRow struct {
|
||||
ID int32 `json:"id"`
|
||||
Firstname string `json:"firstname"`
|
||||
Surname string `json:"surname"`
|
||||
ContractStart time.Time `json:"contractStart"`
|
||||
ContractEnd *time.Time `json:"contractEnd"`
|
||||
ContractHoursWeek float64 `json:"contractHoursWeek"`
|
||||
ContractSalaryHour float64 `json:"contractSalaryHour"`
|
||||
ContractTypeName pgtype.Text `json:"contractTypeName"`
|
||||
DlId string `json:"dlId"`
|
||||
PersonTransportCertificate *time.Time `json:"personTransportCertificate"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListActiveEmployees(ctx context.Context) ([]ListActiveEmployeesRow, error) {
|
||||
rows, err := q.db.Query(ctx, listActiveEmployees)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListActiveEmployeesRow
|
||||
for rows.Next() {
|
||||
var i ListActiveEmployeesRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Firstname,
|
||||
&i.Surname,
|
||||
&i.ContractStart,
|
||||
&i.ContractEnd,
|
||||
&i.ContractHoursWeek,
|
||||
&i.ContractSalaryHour,
|
||||
&i.ContractTypeName,
|
||||
&i.DlId,
|
||||
&i.PersonTransportCertificate,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listPlannedTimesForEmployeeInPeriod = `-- name: ListPlannedTimesForEmployeeInPeriod :many
|
||||
SELECT
|
||||
DISTINCT ON (day)
|
||||
"startDate"::DATE as day,
|
||||
"startDate",
|
||||
"endDate",
|
||||
department,
|
||||
pause,
|
||||
duration
|
||||
FROM "PlannedTime"
|
||||
WHERE
|
||||
"userId" = $1 AND
|
||||
"startDate" > $2 AND
|
||||
"startDate" < $3 AND
|
||||
department <> 'Fortbildung' AND
|
||||
note IS NULL
|
||||
ORDER BY "day"
|
||||
`
|
||||
|
||||
type ListPlannedTimesForEmployeeInPeriodParams struct {
|
||||
EmployeeID string `json:"employee_id"`
|
||||
StartDate *time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
type ListPlannedTimesForEmployeeInPeriodRow struct {
|
||||
Day pgtype.Date `json:"day"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Department pgtype.Text `json:"department"`
|
||||
Pause int32 `json:"pause"`
|
||||
Duration int32 `json:"duration"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListPlannedTimesForEmployeeInPeriod(ctx context.Context, arg ListPlannedTimesForEmployeeInPeriodParams) ([]ListPlannedTimesForEmployeeInPeriodRow, error) {
|
||||
rows, err := q.db.Query(ctx, listPlannedTimesForEmployeeInPeriod, arg.EmployeeID, arg.StartDate, arg.EndDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListPlannedTimesForEmployeeInPeriodRow
|
||||
for rows.Next() {
|
||||
var i ListPlannedTimesForEmployeeInPeriodRow
|
||||
if err := rows.Scan(
|
||||
&i.Day,
|
||||
&i.StartDate,
|
||||
&i.EndDate,
|
||||
&i.Department,
|
||||
&i.Pause,
|
||||
&i.Duration,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listWorkTimesForEmployeeInPeriod = `-- name: ListWorkTimesForEmployeeInPeriod :many
|
||||
SELECT id, "userId", firstname, surname, "startDate", "endDate", department, pause, duration FROM "WorkTime"
|
||||
WHERE "userId" = $1 AND "startDate" > $2 AND "startDate" < $3
|
||||
`
|
||||
|
||||
type ListWorkTimesForEmployeeInPeriodParams struct {
|
||||
EmployeeID string `json:"employee_id"`
|
||||
StartDate *time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListWorkTimesForEmployeeInPeriod(ctx context.Context, arg ListWorkTimesForEmployeeInPeriodParams) ([]WorkTime, error) {
|
||||
rows, err := q.db.Query(ctx, listWorkTimesForEmployeeInPeriod, arg.EmployeeID, arg.StartDate, arg.EndDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []WorkTime
|
||||
for rows.Next() {
|
||||
var i WorkTime
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.UserId,
|
||||
&i.Firstname,
|
||||
&i.Surname,
|
||||
&i.StartDate,
|
||||
&i.EndDate,
|
||||
&i.Department,
|
||||
&i.Pause,
|
||||
&i.Duration,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user