Incorrect COGS after editing invoices

The issue with the Cost of Goods Sold (COGS) going out of sync in SQL-Ledger is a known problem, especially when editing past invoices. Since SQL-Ledger uses the FIFO (First-In, First-Out) method for inventory costing, modifying historical transactions can disrupt the accuracy of your COGS calculations.

Possible Solutions:

  1. Purchase the COGS Reposting Script:
    • The developers of SQL-Ledger offer a script that recalculates and fixes COGS across all invoices.
    • You can purchase the script directly from their website:
    • After purchasing, you’ll receive instructions on how to run the script to correct your COGS entries.
  2. Manual Reconciliation:
    • If purchasing the script isn’t an option, you can manually adjust the affected transactions.
    • Steps to follow:
      • Identify all invoices that have been edited and have incorrect COGS entries.
      • Adjust the inventory and COGS accounts through general ledger entries.
      • Note: This method can be time-consuming and may introduce errors if not done carefully.
  3. Avoid Editing Past Invoices:
    • To prevent this issue in the future, try to avoid making changes to invoices that have already been posted.
    • If adjustments are necessary, consider creating adjustment entries or credit notes rather than editing the original invoice.
  4. Update SQL-Ledger Version:
    • Ensure you’re using the latest version of SQL-Ledger, as updates may include fixes or improvements to inventory and COGS handling.
    • Always back up your data before performing an upgrade.
  5. Consult the Community:
    • Check the SQL-Ledger forums or user groups for any shared scripts or alternative solutions provided by other users.
    • Sometimes, community members develop their own tools to address common issues.

Important Considerations:

  • Backup Your Data: Before running any scripts or making significant changes, make sure to back up your database to prevent data loss.
  • Test in a Safe Environment: If possible, test any scripts or adjustments in a non-production environment first.
  • Seek Professional Advice: If you’re unsure about the process, consider consulting with an accountant or a professional familiar with SQL-Ledger.

(From SQL-Ledger Forum User Post)