---
id: change/bcapps/10345
type: change
title: '#10345 [Main][ALL-E]Issues with Service Contract Invoicing and Retrospective Billing--when the second unposted Service Invoice is deleted the values on the Service Contract are no longer reset--The "Invoiced to Date" field does not resetInitial commit'
summary: Fixed an issue where the Invoiced to Date field on service contracts failed to reset when a second unposted service invoice was deleted, by improving the logic to count only non-reversed ledger entries.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - table service header
  - table service ledger entry
system: service
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:06:25.129Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: fbefb234ba5255eb20bdf7ee5e0cdbb1be658d53
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/10345
    title: 'microsoft/BCApps#10345: [Main][ALL-E]Issues with Service Contract Invoicing and Retrospective Billing--when the second unposted Service Invoice is deleted the values on the Service Contract are no longer reset--The "Invoiced to Date" field does not resetInitial commit'
    date: "2026-09-03"
    commit: fbefb234ba5255eb20bdf7ee5e0cdbb1be658d53
    t: null
    quote: Change CalcContractLineInvoicedToDate to count only real, non-reversed invoicing.
links:
  learn: []
  objects:
    - object/table/5900
    - object/table/5907
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 10345
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/10345
kind: pr
base_branch: main
major: "30"
merged_at: "2026-09-03T04:32:43Z"
author: sanjmaurya
author_type: User
community_contribution: false
labels:
  - "Team: SCM"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 3
  additions: 135
  deletions: 11
  al: 2
apps:
  - Base Application
objects_touched:
  - key: table/5900
    page: table/5900
    type: table
    id: 5900
    name: Service Header
    app: Base Application
    status: modified
  - key: table/5907
    page: table/5907
    type: table
    id: 5907
    name: Service Ledger Entry
    app: Base Application
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 647165
systems:
  - service
quote: Change CalcContractLineInvoicedToDate to count only real, non-reversed invoicing.
joined_against:
  major: "30"
  commit: ecbc028c25dbe83b61313bc566e6c1d41184bb1c
---

# #10345 [Main][ALL-E]Issues with Service Contract Invoicing and Retrospective Billing--when the second unposted Service Invoice is deleted the values on the Service Contract are no longer reset--The "Invoiced to Date" field does not resetInitial commit

> Fixed an issue where the Invoiced to Date field on service contracts failed to reset when a second unposted service invoice was deleted, by improving the logic to count only non-reversed ledger entries.

[Pull request](https://github.com/microsoft/BCApps/pull/10345) · merged into `main` (BC30) on 2026-09-03 by sanjmaurya · 3 files (+135 -11), 2 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Deleting a second unposted service invoice now resets Invoiced to Date on the contract lines
- Reversed ledger entry pairs left by earlier deleted invoices are now ignored
- Invoiced to Date resets to a blank date (0D) on each invoice deletion
- Only original Sale entries that have no reversing entry count as invoiced
- A correct new service invoice can be created again after the deletions
- Behaviour changes for users or extensions.

## AL objects touched

- [Table 5900 "Service Header"](../../objects/table/5900.md), Base Application: modified
- [Table 5907 "Service Ledger Entry"](../../objects/table/5907.md), Base Application: modified

## Context

- Work items: AB#647165
- Labels: Team: SCM
- Systems: service
- From the description: "Change CalcContractLineInvoicedToDate to count only real, non-reversed invoicing."

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
