Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: progressive billing amount cents reset when refresh inovice #2946

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/services/invoices/refresh_draft_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def reset_invoice_values
invoice.fees_amount_cents = 0
invoice.sub_total_excluding_taxes_amount_cents = 0
invoice.sub_total_including_taxes_amount_cents = 0
invoice.progressive_billing_credit_amount_cents = 0
invoice.save!
end
end
Expand Down
8 changes: 7 additions & 1 deletion spec/services/invoices/refresh_draft_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
taxes_rate: 30,
fees_amount_cents: 2600,
sub_total_excluding_taxes_amount_cents: 9900090,
sub_total_including_taxes_amount_cents: 9900100
sub_total_including_taxes_amount_cents: 9900100,
progressive_billing_credit_amount_cents: 1239000
)
end

Expand Down Expand Up @@ -165,6 +166,11 @@
.to change { invoice.reload.taxes_rate }.from(30.0).to(15)
end

it 'recalculates progressive billing amount' do
expect { refresh_service.call }
.to change { invoice.reload.progressive_billing_credit_amount_cents }.from(1239000).to(0)
end

context 'when there is a tax_integration set up' do
let(:integration) { create(:anrok_integration, organization:) }
let(:integration_customer) { create(:anrok_customer, integration:, customer:) }
Expand Down
Loading