Skip to content

feat: add work assignment doctype with member hour tracking (LAN-885)#294

Open
MarcCon wants to merge 42 commits into
version-15-hotfixfrom
lan-885
Open

feat: add work assignment doctype with member hour tracking (LAN-885)#294
MarcCon wants to merge 42 commits into
version-15-hotfixfrom
lan-885

Conversation

@MarcCon

@MarcCon MarcCon commented Jan 12, 2026

Copy link
Copy Markdown
Collaborator

This PR enables tracking of work hours for members through work assignments.

Features:

  • Work Assignment DocType
  • Work Hours Report
  • button to create work assignments directly from a member record

Open Questions:
Do we need a hourly account for a member? It is not necessary for the report.

@MarcCon MarcCon requested a review from barredterra January 12, 2026 08:45
MarcCon and others added 3 commits January 16, 2026 09:23
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

@barredterra barredterra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start!

I think in the requirements I read that each Organization should be able to specify a number of working hours per year and we need to track the members´ actual working hours against that. And, ideally, also allow carrying over excess working hours to the next year.

Let's also add the Work Assignment to the connections in the LANDA Member form.

Comment thread landa/organization_management/doctype/work_assignment/work_assignment.js Outdated
Comment thread landa/organization_management/doctype/work_assignment/work_assignment.json Outdated
Comment thread landa/organization_management/report/work_hours/work_hours.py
@MarcCon

MarcCon commented Jan 26, 2026

Copy link
Copy Markdown
Collaborator Author

Good start!

I think in the requirements I read that each Organization should be able to specify a number of working hours per year and we need to track the members´ actual working hours against that. And, ideally, also allow carrying over excess working hours to the next year.

Let's also add the Work Assignment to the connections in the LANDA Member form.

My idea would be to add a DocType "Organization Work Hours" with a child table to show members of the organization with their hours from the Work Assignment DocType and validate them against the target hours.

@MarcCon MarcCon requested a review from barredterra January 26, 2026 09:39
@barredterra

Copy link
Copy Markdown
Member

See my alternative proposal in LAN-885

@barredterra barredterra assigned barredterra and unassigned MarcCon Feb 11, 2026

@barredterra barredterra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich habe in "Work Ledger Balance" die Spaltenbreiten angepasst und die Logik so angepasst, dass Work Ledger Entries ohne Work Assignment in der "Expected"-Spalte landen, und solche mit Work Assignment in der "Hours Worked"-Spalte (statt unter/über Null). Dadurch wird eine Verringerung der Expected Hours via Organization nicht mehr als geleistete Arbeit angezeigt.


Weitere nötige Arbeiten:

  • Work Assignment:

    • Connections mit Link auf Work Ledger Entry hinzufügen
    • DocType ist submittable, aber niemand hat Submit-Rechte (auch Cancel, Amend, usw)
  • Bericht "Arbeitsstunden"

    • Für Zeilen ohne Work Assignment sollten wir eine hilfreiche Beschreibung ausgeben, z.B. "Anpassung der erwarteten Arbeitszeit".
    • Spalte "Gesamtstunden" umbenennen zu "Stundensaldo"
  • Berichte zu Workspace "Vereinsverwaltung" hinzufügen

  • Als normaler Nutzer (Rolle "Mitgliederverwaltung Verein") durchtesten

  • TypeError beheben:

       File "/home/runner/frappe-bench/apps/landa/landa/organization_management/doctype/organization/organization.py", line 105, in on_update
         create_expected_hours_adjustment_entries(self.name, old - new)
                                                             ~~~~^~~~~
     TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
    

@MarcCon

MarcCon commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author
  • DocType ist submittable, aber niemand hat Submit-Rechte (auch Cancel, Amend, usw)

@barredterra Was ist der Sinn dahinter, es muss doch submitted werden können um die Work Ledger Entrys zu erstellen?

@barredterra

Copy link
Copy Markdown
Member

@MarcCon exactly, die Rechte haben gefehlt, sodass niemand buchen kann. Das müsste noch gefixt werden.

@MarcCon

MarcCon commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

Ah habs falsch verstanden, alles klar.

@MarcCon

MarcCon commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

Die offenen Issues sind erledigt, ich teste es noch als normaler Nutzer durch.

Edit:
Als Nutzer mit der Rolle "LANDA Local Organization Management" kann ich ein Work Assignment nur für den Verein des Nutzers erstellen. Ebenso sehe ich nur Work Assignments und Work Ledger Entries dieses Vereines.

In beiden Reports kann ich in den Filtern auch nur den eigenen Verein auswählen und ansehen.

@MarcCon MarcCon requested a review from barredterra April 9, 2026 17:58
@barredterra barredterra assigned barredterra and unassigned MarcCon Apr 21, 2026
Comment thread landa/organization_management/doctype/work_assignment/test_work_assignment.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should date and organization be fetched from Work Assignment as well? Seems odd if the user can edit these in the ledger entry.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when Work Ledger Entry is created manually and a work assignment is selected, the date and organization field should be read only and fetched from the Work Assignment, correct? And if no Work Assignment is selected, both fields can be edited.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a Ledger Entry is created from a Work Assignment all fields should be read only. Only Manual entries without a linked Work Assignment should remain editable? But should we even allow manual Ledger Entrys without a Work Assignment?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good. I think manual entries could be used for any necessary individual corrections., i.e. all special cases we didn't think about.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what should happen when someone manually creates a Ledger Entry AND selects an existing Work Assignment. In that case the Ledger Entry is not created from a Work Assignment but is connected to one. Should it be editable afterwards or treated like an Entry automatically created from a Work Assignment (not editable)?

Comment thread landa/organization_management/report/work_hours/work_hours.json
@barredterra barredterra assigned MarcCon and unassigned barredterra Apr 27, 2026
@MarcCon

MarcCon commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

The submission path is correct, but the cancellation path silently leaves orphaned Work Ledger Entries for all but the first member on multi-member assignments, corrupting every affected member's hours balance permanently.

Cancellation of any Work Assignment with more than one member will leave orphaned ledger entries that inflate balances going forward. This is a data-integrity defect on a core operation of the new feature. The reporting and scheduler logic are sound, but the flawed delete call needs to be fixed before the feature is used in production.

landa/organization_management/doctype/work_assignment/work_assignment.py (cancellation logic) and landa/organization_management/doctype/work_assignment_member/work_assignment_member.json + .py (manual-edit indicators)

Sequence Diagram

sequenceDiagram
    participant U as User
    participant WA as WorkAssignment
    participant WLE as WorkLedgerEntry
    participant Org as Organization
    participant Sched as Scheduler (Jan 1)
    participant WH as Work Hours Report
    participant WLB as Work Ledger Balance Report

    U->>WA: Submit
    loop per member in members[]
        WA->>WLE: "insert (hours_change = member.duration)"
    end

    U->>WA: Cancel
    WA->>WLE: delete_work_ledger_entry() ⚠ dict arg — only deletes 1 entry

    Sched->>WLE: create_yearly_negative_entries() per member

    U->>Org: Save (changed expected_work_hours_per_year)
    Org->>WLE: create_expected_hours_adjustment_entries() per member

    U->>WH: Run
    WH->>WLE: query (filtered by year/org/member/water_body)
    WLE-->>WH: entries + linked WorkAssignment data

    U->>WLB: Run
    WLB->>WLE: query (all entries up to year_end)
    WLB-->>U: per-member balance summary
Loading

Fix All in Cursor

Reviews (1): Last reviewed commit: "feat: add doctype shortcuts to workspace" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants