AuftragDao.ktThe primary data access object for AuftragDO (orders/quotes). Extends BaseDao<AuftragDO> and provides comprehensive CRUD operations, advanced filtering (by status, position type, payment type, user assignment, project, date ranges), validation during insert/modify, email notifications, history loading, and integration with the AuftragsCache. Responsible for the "to be invoiced" logic and multi-level order position filtering.
@Service open class AuftragDao : BaseDao<AuftragDO>(AuftragDO::class.java)
| Dependency | Type | Notes |
|---|---|---|
auftragsCache | AuftragsCache | Not autowired (cyclic dependency); set via @PostConstruct in AuftragsCache |
configurationService | ConfigurationService | Check if mail is configured |
flatHistoryFormatService | FlatHistoryFormatService | History entry retrieval for notifications |
kundeDao | KundeDao | Customer resolution |
projektDao | ProjektDao | Project resolution |
sendMail | SendMail | Email notification delivery |
taskDao | TaskDao | Task resolution for positions |
userDao | UserDao | Contact person resolution |
select(filter, checkAccess) — The core query method, overridden from BaseDao. Builds a complex QueryFilter supporting:
ZU_FAKTURIEREN, queries orders/positions with status ABGESCHLOSSEN or reached payment schedules via a LEFT JOINisIn on project listbetween/ge/le on erfassungsDatum (creation date)AuftragAndRechnungDaoHelperfilterPositionsArten using AuftragsPositionsArtFilterfilterPositionsStatus — matches orders where any non-deleted position has the given statusfilterPositionsPaymentTypes using AuftragsPositionsPaymentTypeFilternummer descendingonInsertOrModify(obj, operationType)Enforces business rules before persisting:
nummer must not be nullstatus must not be null or OPTIONALnummer must be the next sequential number (no gaps)nummer must not conflict with another existing ordervollstaendigFakturiert flag is checked via checkVollstaendigFakturiert()uiStatusAsXmlvalidateDatesInPaymentScheduleWithinPeriodOfPerformanceOfPosition() — ensures all payment schedule dates fall within the position's period of performance (plus 3 months tolerance for the end date)validateAmountsInPaymentScheduleNotGreaterThanNetSumOfPosition() — sum of all payment schedule amounts for a position must not exceed the position's net sumnextNumber — Returns the next available order number (highest existing + 1)getNextNumber(auftrag) — If the order already has an ID, retrieves its original number to preserve it; otherwise assigns the next sequential numberSTART_NUMBER = 1sendNotificationIfRequired(auftrag, operationType, requestUrl)Sends an HTML email notification to the contact person when an order is created/modified/deleted. Uses Groovy template mail/orderChangeNotification.html. Includes up to 10 most recent history entries. Returns false if mail is not configured, no contact person is assigned, or the contact person lacks SELECT access.
addOwnHistoryEntries(obj, context) — Loads and merges history for all positionen (including deleted) and payment schedulesgetHistoryPropertyPrefix(context) — Returns "pos#N" for position history entries and "payment#N" for payment schedule history entriesadditionalHistorySearchDOs — Includes AuftragsPositionDO for full-text history searchgetAuftragsPosition(posString) — Parses format "###.##" (order number.position number) and returns the matching positiongetAuftragsPosition(id) — Finds a position by its database IDyears — Returns array of all years with order activity (min/max of angebotsDatum)buildStatistik(list) — Aggregates statistics for a list of ordersMethods setContactPerson(), setTask(), setKunde(), and setProjekt() resolve related entities by ID using findOrLoad and set them on the order or position.
The ADDITIONAL_SEARCH_FIELDS array extends Hibernate Search to index fields from related entities:
contactPerson.username, contactPerson.firstname, contactPerson.lastname, kunde.name, projekt.name, projekt.kunde.name, positionen.position, positionen.art, positionen.status, positionen.titel, positionen.bemerkung, positionen.nettoSumme
| Constant | Value |
|---|---|
USER_RIGHT_ID | UserRightId.PM_ORDER_BOOK |
START_NUMBER | 1 |
868d6abb7 2025 -> 2026 4550ccc8a MonthlyEmployeeReport: show weekly net and gross hours. Fix select in AuftragDao.positionen.status 63081666f Source file headers: 2024-> 2025. db2599ab8 History in orderbook, incoming/outgoing invoices and projects. 18bf92219 WIP: History entries handling. VisitorBookDao. 9c633d4ce AuftragDao/AuftragFilter: to-be-invoiced and fully-invoiced fixed. ae2c04ee0 Migration stuff in progress... (all tests of all packages: OK). (150+ commits total, spanning migration to Long IDs, Spring refactoring, Hibernate Search updates, etc.)