Skip to content

Commit

Permalink
Add logic for calculating AZ 301 lines 40 and 41 (#5181)
Browse files Browse the repository at this point in the history
  • Loading branch information
arinchoi03 authored Dec 11, 2024
1 parent 580a866 commit 55afe48
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/lib/efile/az/az301_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def calculate_line_34
end

def calculate_line_40
@lines[:AZ301_LINE_6c]&.value
[line_or_zero(:AZ301_LINE_6c), line_or_zero(:AZ301_LINE_34)].min
end

def calculate_line_41
@lines[:AZ301_LINE_7c]&.value
subtraction = [line_or_zero(:AZ301_LINE_34) - line_or_zero(:AZ301_LINE_40), 0].max
[subtraction, line_or_zero(:AZ301_LINE_7c)].min
end

def calculate_line_60
Expand Down
139 changes: 139 additions & 0 deletions spec/lib/efile/az/az301_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,144 @@
expect(instance.lines[:AZ301_LINE_60].value).to eq(1338)
expect(instance.lines[:AZ301_LINE_62].value).to eq(1338)
end

context "line 40" do
context "with 6c greater than line 34 value" do
before do
allow(instance).to receive(:calculate_line_6c).and_return 1_000
allow(instance).to receive(:calculate_line_34).and_return 500
end

it "line 40 value is equal to line 34 value" do
instance.calculate
expect(instance.lines[:AZ301_LINE_40].value).to eq(500)
end
end

context "with line 6c less than line 34" do
before do
allow(instance).to receive(:calculate_line_6c).and_return 500
allow(instance).to receive(:calculate_line_34).and_return 1000
end

it "line 40 value is equal to line 6c value" do
instance.calculate
expect(instance.lines[:AZ301_LINE_40].value).to eq(500)
end
end

context "with line 6c blank" do
before do
allow(instance).to receive(:calculate_line_6c).and_return nil
allow(instance).to receive(:calculate_line_34).and_return 1000
end

it "line 40 value is equal to zero" do
instance.calculate
expect(instance.lines[:AZ301_LINE_40].value).to eq(0)
end
end

context "with line 34 blank" do
before do
allow(instance).to receive(:calculate_line_6c).and_return 10
allow(instance).to receive(:calculate_line_34).and_return nil
end

it "line 40 value is equal to zero" do
instance.calculate
expect(instance.lines[:AZ301_LINE_40].value).to eq(0)
end
end
end

context "line 41" do
context "line 34 greater than line 40" do
before do
allow(instance).to receive(:calculate_line_34).and_return 120
allow(instance).to receive(:calculate_line_40).and_return 100
end

context "line 7c greater than subtraction" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 30
end

it "returns the subtraction amount" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(20)
end
end

context "line 7c less than subtraction" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 10
end

it "returns the 7c amount" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(10)
end
end
end

context "line 34 less than line 40" do
before do
allow(instance).to receive(:calculate_line_34).and_return 90
allow(instance).to receive(:calculate_line_40).and_return 100
end

context "line 7c greater than subtraction" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 10
end

it "returns 0" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(0)
end
end

context "line 7c equal to subtraction" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 0
end

it "returns 0" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(0)
end
end
end

context "line 34 equal to line 40" do
before do
allow(instance).to receive(:calculate_line_34).and_return 90
allow(instance).to receive(:calculate_line_40).and_return 90
end

context "line 7c greater than subtraction" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 100
end

it "returns 0" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(0)
end
end

context "line 7c equal to subtraction which is 0" do
before do
allow(instance).to receive(:calculate_line_7c).and_return 0
end

it "returns 0" do
instance.calculate
expect(instance.lines[:AZ301_LINE_41].value).to eq(0)
end
end
end
end
end
end

0 comments on commit 55afe48

Please sign in to comment.