Skip to content

Implement customer overdue orders query feature#10

Draft
Copilot wants to merge 4 commits intofeatures/#1-show-overdue-ordersfrom
copilot/show-overdue-orders
Draft

Implement customer overdue orders query feature#10
Copilot wants to merge 4 commits intofeatures/#1-show-overdue-ordersfrom
copilot/show-overdue-orders

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 17, 2026

Adds ability to list customers with overdue orders (DueDate < Today AND Status ∉ {Shipped, Cancelled}), ordered by oldest overdue date ascending.

Changes

  • Contract: ICustomerService.GetCustomersWithOverdueOrders() returns CustomerWithOverdueOrdersData[] with customer name, overdue count, and oldest due date
  • Service: Single LINQ query performs filtering, aggregation (Count(), Min()), and sorting at database level
  • Console: New menu option "Show customers with overdue orders"
  • Tests: 12 unit tests covering edge cases, status/date filtering, aggregation, and sorting logic using FakeRepository

Implementation

public CustomerWithOverdueOrdersData[] GetCustomersWithOverdueOrders()
{
    var today = DateTime.Today;
    var closedStatuses = new[] { SalesOrderHeaderStatusValues.Shipped, SalesOrderHeaderStatusValues.Cancelled };

    return repository.GetEntities<Customer>()
        .Where(c => c.SalesOrderHeaders.Any(o => 
            o.DueDate < today && 
            !closedStatuses.Contains(o.Status)))
        .Select(c => new CustomerWithOverdueOrdersData
        {
            CustomerName = c.CompanyName ?? $"{c.FirstName} {c.LastName}",
            OverdueOrdersCount = c.SalesOrderHeaders
                .Where(o => o.DueDate < today && !closedStatuses.Contains(o.Status))
                .Count(),
            OldestDueDate = c.SalesOrderHeaders
                .Where(o => o.DueDate < today && !closedStatuses.Contains(o.Status))
                .Min(o => o.DueDate)
        })
        .OrderBy(x => x.OldestDueDate)
        .ToArray();
}

Customer name resolution: CompanyName if present, otherwise FirstName + LastName.

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement: Show customer with overdue orders</issue_title>
<issue_description>Implement feature #1 using high-level design from docs/workitems/1-design.md and detailed design from docs/workitems/1-detailed-design.md</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: coder
Implementation agent that converts detailed design specifications into working C# code following Clean Architecture principles and strict dependency rules


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 17, 2026 08:53
Co-authored-by: florinc <443676+florinc@users.noreply.github.com>
Co-authored-by: florinc <443676+florinc@users.noreply.github.com>
Co-authored-by: florinc <443676+florinc@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement feature to show customers with overdue orders Implement customer overdue orders query feature Feb 17, 2026
Copilot AI requested a review from florinc February 17, 2026 09:01
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.

2 participants