Skip to content

Commit

Permalink
Accounting (#230)
Browse files Browse the repository at this point in the history
* wip

* w

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
nilspenzel authored Mar 5, 2025
1 parent f68447c commit 952169c
Show file tree
Hide file tree
Showing 35 changed files with 1,550 additions and 12 deletions.
12 changes: 6 additions & 6 deletions data/company.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
INSERT INTO "company" ("lat", "lng", "name", "address", "zone") VALUES
(51.493713, 14.625855, 'Taxi Weißwasser', 'Werner-Seelenbinder-Straße 70A, 02943 Weißwasser/Oberlausitz', 2),
(51.532974, 14.660599, 'Taxi Gablenz', 'Schulstraße 21, 02953 Gablenz', 2),
(51.38096, 14.666578, 'Taxi Reichwalde', 'Robert-Koch-Straße 45, 02943 Boxberg/Oberlausitz', 3),
(51.30576, 14.782109, 'Taxi Moholz', 'Postweg 10, 02906 Niesky', 3),
(51.302185, 14.834551, 'Taxi Niesky', 'Trebuser Str. 4, 02906 Niesky', 3),
(51.321884, 14.944467, 'Taxi Rothenburg', 'Zur Wasserscheide 37, 02929 Rothenburg/Oberlausitz', 3),
(51.166775, 14.934901, 'Taxi Schöpstal', 'Ebersbacher Str. 43, 02829 Schöpstal', 4),
(51.129536, 14.941331, 'Taxi Görlitz', 'Plantagenweg 3, 02827 Görlitz', 4);
(51.38096, 14.666578, 'Taxi Reichwalde', 'Robert-Koch-Straße 45, 02943 Boxberg/Oberlausitz', 1),
(51.30576, 14.782109, 'Taxi Moholz', 'Postweg 10, 02906 Niesky', 1),
(51.302185, 14.834551, 'Taxi Niesky', 'Trebuser Str. 4, 02906 Niesky', 1),
(51.321884, 14.944467, 'Taxi Rothenburg', 'Zur Wasserscheide 37, 02929 Rothenburg/Oberlausitz', 1),
(51.166775, 14.934901, 'Taxi Schöpstal', 'Ebersbacher Str. 43, 02829 Schöpstal', 3),
(51.129536, 14.941331, 'Taxi Görlitz', 'Plantagenweg 3, 02827 Görlitz', 3);
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ services:
source: data-volume
target: /var/lib/postgresql/data

adminer:
image: adminer
restart: always
ports:
- 6501:8080

motis-import:
image: ghcr.io/motis-project/motis:2.0
volumes:
Expand Down
5 changes: 4 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export default ts.config(

languageOptions: {
parserOptions: {
parser: ts.parser
parser: ts.parser,
svelteFeatures: {
experimentalGenerics: true
}
}
},

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,22 @@
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
"@tailwindcss/typography": "^0.5.16",
"@types/file-saver": "^2.0.7",
"@types/geojson": "^7946.0.16",
"@types/html-to-text": "^9.0.4",
"@types/json-schema": "^7.0.15",
"@types/mapbox__polyline": "^1.0.5",
"@types/papaparse": "^5.3.15",
"@types/pg": "^8.11.11",
"@types/uuid": "^10.0.0",
"file-saver": "^2.0.5",
"geojson": "^0.5.0",
"html-to-text": "^9.0.5",
"jsonschema": "^1.5.0",
"kysely": "^0.27.5",
"kysely-ctl": "^0.11.0",
"maplibre-gl": "^5.0.1",
"papaparse": "^5.5.2",
"pg": "^8.13.1",
"svelte-qrcode": "^1.0.1",
"uuid": "^11.0.5"
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,21 @@ export const PASSENGER_TIME_COST_FACTOR = 0;
export const BUFFER_TIME = 0;
export const EARLIEST_SHIFT_START = 6 * HOUR;
export const LATEST_SHIFT_END = 21 * HOUR;
export const FIXED_PRICE = 300;
export const CAP = 3500;
export const OVER_CAP_FACTOR = 0.25;
export const MONTHS = [
'Janurar',
'Februar',
'März',
'April',
'Mai',
'Juni',
'Juli',
'August',
'September',
'Oktober',
'November',
'Dezember'
];
export const QUARTERS = ['Quartal 1', 'Quartal 2', 'Quartal 3', 'Quartal 4'];
1 change: 1 addition & 0 deletions src/lib/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const translations: Translations = {
availability: 'Verfügbarkeit',
company: 'Unternehmen',
completedTours: 'Fahrten',
accounting: 'Abrechnung',
employees: 'Mitarbeiter',
companies: 'Unternehmen'
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const translations: Translations = {
availability: 'Availability',
company: 'Company',
completedTours: 'Tours',
accounting: 'Accounting',
employees: 'Employees',
companies: 'Companies'
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type Translations = {
availability: string;
company: string;
completedTours: string;
accounting: string;
employees: string;
companies: string;
};
Expand Down
28 changes: 28 additions & 0 deletions src/lib/server/db/getTours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,31 @@ export const getTours = async (
export type Tours = Awaited<ReturnType<typeof getTours>>;
export type Tour = Tours[0];
export type TourEvent = Tour['events'][0];

export const getToursWithRequests = async () => {
return await db
.selectFrom('tour')
.innerJoin('vehicle', 'vehicle.id', 'tour.vehicle')
.innerJoin('company', 'company.id', 'vehicle.company')
.select((eb) => [
'tour.fare as fare',
'tour.departure as startTime',
'tour.arrival as endTime',
'tour.cancelled',
'company.name as companyName',
'company.id as companyId',
'vehicle.id as vehicleId',
jsonArrayFrom(
eb
.selectFrom('request')
.whereRef('tour.id', '=', 'request.tour')
.select(['request.luggage', 'request.passengers', 'request.ticketChecked'])
).as('requests')
])
.where('tour.fare', 'is not', null)
.execute();
};

export type ToursWithRequests = Awaited<ReturnType<typeof getToursWithRequests>>;
export type TourWithRequests = ToursWithRequests[0];
export type TourRequest = TourWithRequests['requests'][0];
30 changes: 30 additions & 0 deletions src/lib/shadcn/range-calendar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Root from "./range-calendar.svelte";
import Cell from "./range-calendar-cell.svelte";
import Day from "./range-calendar-day.svelte";
import Grid from "./range-calendar-grid.svelte";
import Header from "./range-calendar-header.svelte";
import Months from "./range-calendar-months.svelte";
import GridRow from "./range-calendar-grid-row.svelte";
import Heading from "./range-calendar-heading.svelte";
import GridBody from "./range-calendar-grid-body.svelte";
import GridHead from "./range-calendar-grid-head.svelte";
import HeadCell from "./range-calendar-head-cell.svelte";
import NextButton from "./range-calendar-next-button.svelte";
import PrevButton from "./range-calendar-prev-button.svelte";

export {
Day,
Cell,
Grid,
Header,
Months,
GridRow,
Heading,
GridBody,
GridHead,
HeadCell,
NextButton,
PrevButton,
//
Root as RangeCalendar,
};
19 changes: 19 additions & 0 deletions src/lib/shadcn/range-calendar/range-calendar-cell.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/shadcn/utils.js";
let {
ref = $bindable(null),
class: className,
...restProps
}: RangeCalendarPrimitive.CellProps = $props();
</script>

<RangeCalendarPrimitive.Cell
bind:ref
class={cn(
"[&:has([data-selected])]:bg-accent [&:has([data-selected][data-outside-month])]:bg-accent/50 relative p-0 text-center text-sm focus-within:relative focus-within:z-20 first:[&:has([data-selected])]:rounded-l-md last:[&:has([data-selected])]:rounded-r-md [&:has([data-selected][data-selection-end])]:rounded-r-md [&:has([data-selected][data-selection-start])]:rounded-l-md",
className
)}
{...restProps}
/>
35 changes: 35 additions & 0 deletions src/lib/shadcn/range-calendar/range-calendar-day.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { buttonVariants } from "$lib/shadcn/button/index.js";
import { cn } from "$lib/shadcn/utils.js";
let {
ref = $bindable(null),
class: className,
...restProps
}: RangeCalendarPrimitive.DayProps = $props();
export { className as class };
</script>

<RangeCalendarPrimitive.Day
bind:ref
class={cn(
buttonVariants({ variant: "ghost" }),
"size-8 p-0 font-normal data-[selected]:opacity-100",
// Today
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground",
// Selection Start
"data-[selection-start]:bg-primary data-[selection-start]:text-primary-foreground data-[selection-start]:hover:bg-primary data-[selection-start]:hover:text-primary-foreground data-[selection-start]:focus:bg-primary data-[selection-start]:focus:text-primary-foreground",
// Selection End
"data-[selection-end]:bg-primary data-[selection-end]:text-primary-foreground data-[selection-end]:hover:bg-primary data-[selection-end]:hover:text-primary-foreground data-[selection-end]:focus:bg-primary data-[selection-end]:focus:text-primary-foreground",
// Outside months
"data-[outside-month]:text-muted-foreground [&[data-outside-month][data-selected]]:bg-accent/50 [&[data-outside-month][data-selected]]:text-muted-foreground data-[outside-month]:pointer-events-none data-[outside-month]:opacity-50 [&[data-outside-month][data-selected]]:opacity-30",
// Disabled
"data-[disabled]:text-muted-foreground data-[disabled]:opacity-50",
// Unavailable
"data-[unavailable]:text-destructive-foreground data-[unavailable]:line-through",
className
)}
{...restProps}
/>
12 changes: 12 additions & 0 deletions src/lib/shadcn/range-calendar/range-calendar-grid-body.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/shadcn/utils.js";
let {
ref = $bindable(null),
class: className,
...restProps
}: RangeCalendarPrimitive.GridBodyProps = $props();
</script>

<RangeCalendarPrimitive.GridBody bind:ref class={cn(className)} {...restProps} />
12 changes: 12 additions & 0 deletions src/lib/shadcn/range-calendar/range-calendar-grid-head.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/shadcn/utils.js";
let {
ref = $bindable(null),
class: className,
...restProps
}: RangeCalendarPrimitive.GridHeadProps = $props();
</script>

<RangeCalendarPrimitive.GridHead bind:ref class={cn(className)} {...restProps} />
12 changes: 12 additions & 0 deletions src/lib/shadcn/range-calendar/range-calendar-grid-row.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
import { cn } from "$lib/shadcn/utils.js";
let {
ref = $bindable(null),
class: className,
...restProps
}: RangeCalendarPrimitive.GridRowProps = $props();
</script>

<RangeCalendarPrimitive.GridRow bind:ref class={cn("flex", className)} {...restProps} />
Loading

0 comments on commit 952169c

Please sign in to comment.