-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: delete invoice errors for sequential number generation when fi…
…nishing invoice generation (#3092) ## Context We have invoices that are generated, so they have invoice_number, but the invoice_error storing details of not generated number still exists ## Description Added migration to delete invoice_errors that are not needed anymore; Added methods to delete invoice_errors when invoice is successfully generated
- Loading branch information
1 parent
2f9d1a9
commit 88b480b
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
db/migrate/20250122112050_delete_sequence_generation_invoice_error_for_generated_invoices.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class DeleteSequenceGenerationInvoiceErrorForGeneratedInvoices < ActiveRecord::Migration[7.1] | ||
GENERATED_INVOICE_STATUSES = [1, 6].freeze | ||
|
||
def change | ||
InvoiceError.joins("LEFT JOIN invoices ON invoices.id = invoice_errors.id") | ||
.where("invoice_errors.backtrace LIKE ?", "%generate_organization_sequential_id%") | ||
.where(invoices: {status: GENERATED_INVOICE_STATUSES}).find_each do |ie| | ||
ie.delete | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters