-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add abacus abo magazin invoice class
- Loading branch information
Showing
6 changed files
with
167 additions
and
108 deletions.
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
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
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
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
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
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,73 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2025, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas. | ||
|
||
require "spec_helper" | ||
|
||
describe Invoices::Abacus::AboMagazinInvoice do | ||
let(:abonnent_alpen) { roles(:abonnent_alpen) } | ||
let(:abonnent) { people(:abonnent) } | ||
|
||
subject { described_class.new(abonnent_alpen) } | ||
|
||
describe "#positions" do | ||
context "for swiss person" do | ||
before do | ||
abonnent.update_column(:country, "CH") | ||
end | ||
|
||
it "creates abo fee position with correct values" do | ||
position = subject.positions.first | ||
expect(subject.positions.count).to eq 1 | ||
expect(position.name).to eq "Abonnement Die Alpen DE 01.01.2026 - 31.12.2026" | ||
expect(position.grouping).to eq "Abonnement Die Alpen DE 01.01.2026 - 31.12.2026" | ||
expect(position.amount).to eq 60 | ||
expect(position.count).to eq 1 | ||
expect(position.article_number).to eq "APG" | ||
end | ||
|
||
it "position uses language of person as locale" do | ||
abonnent.update_column(:language, "it") | ||
expect(subject.positions.first.name).to eq "Abbonamento Die Alpen DE 01.01.2026 - 31.12.2026" | ||
end | ||
end | ||
|
||
context "for person living abroad" do | ||
before do | ||
abonnent.update_column(:country, "BO") | ||
end | ||
|
||
it "has second position for abroad costs" do | ||
position = subject.positions.second | ||
expect(subject.positions.count).to eq 2 | ||
expect(position.name).to eq "Porto Die Alpen DE" | ||
expect(position.amount).to eq 16 | ||
end | ||
end | ||
end | ||
|
||
describe "#total" do | ||
context "for swiss person" do | ||
before do | ||
abonnent.update_column(:country, "CH") | ||
end | ||
|
||
it "total does not include porto cost" do | ||
expect(subject.total).to eq 60 | ||
end | ||
end | ||
|
||
context "for person living abroad" do | ||
before do | ||
abonnent.update_column(:country, "BO") | ||
end | ||
|
||
it "total does include porto cost" do | ||
expect(subject.total).to eq 76 | ||
end | ||
end | ||
end | ||
end |