|
|
|
@ -267,69 +267,87 @@ RSpec.describe Validations::Sales::SoftValidations do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when validating extra borrowing" do |
|
|
|
context "when validating extra borrowing" do |
|
|
|
it "returns false if extrabor not present" do |
|
|
|
context "when the log is for 2023" do |
|
|
|
record.mortgage = 50_000 |
|
|
|
let(:record) { build(:sales_log, saledate: Time.zone.local(2023, 12, 1)) } |
|
|
|
record.deposit = 40_000 |
|
|
|
|
|
|
|
record.value = 100_000 |
|
|
|
it "returns false if extrabor not present" do |
|
|
|
record.discount = 11 |
|
|
|
record.mortgage = 50_000 |
|
|
|
expect(record) |
|
|
|
record.deposit = 40_000 |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
record.value = 100_000 |
|
|
|
end |
|
|
|
record.discount = 11 |
|
|
|
|
|
|
|
expect(record) |
|
|
|
|
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns false if mortgage not present" do |
|
|
|
it "returns false if mortgage not present" do |
|
|
|
record.extrabor = 2 |
|
|
|
record.extrabor = 2 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.discount = 11 |
|
|
|
record.discount = 11 |
|
|
|
expect(record) |
|
|
|
expect(record) |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns false if deposit not present" do |
|
|
|
it "returns false if deposit not present" do |
|
|
|
record.extrabor = 2 |
|
|
|
record.extrabor = 2 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.discount = 11 |
|
|
|
record.discount = 11 |
|
|
|
expect(record) |
|
|
|
expect(record) |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns false if value not present" do |
|
|
|
it "returns false if value not present" do |
|
|
|
record.extrabor = 2 |
|
|
|
record.extrabor = 2 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.discount = 11 |
|
|
|
record.discount = 11 |
|
|
|
expect(record) |
|
|
|
expect(record) |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns false if discount not present" do |
|
|
|
it "returns false if discount not present" do |
|
|
|
record.extrabor = 2 |
|
|
|
record.extrabor = 2 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.value = 100_000 |
|
|
|
expect(record) |
|
|
|
expect(record) |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns false if extra borrowing expected and reported" do |
|
|
|
it "returns false if extra borrowing expected and reported" do |
|
|
|
record.extrabor = 1 |
|
|
|
record.extrabor = 1 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.mortgage = 50_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.deposit = 40_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.value = 100_000 |
|
|
|
record.discount = 11 |
|
|
|
record.discount = 11 |
|
|
|
expect(record) |
|
|
|
expect(record) |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns true if extra borrowing expected but not reported" do |
|
|
|
|
|
|
|
record.extrabor = 2 |
|
|
|
|
|
|
|
record.mortgage = 50_000 |
|
|
|
|
|
|
|
record.deposit = 40_000 |
|
|
|
|
|
|
|
record.value = 100_000 |
|
|
|
|
|
|
|
record.discount = 11 |
|
|
|
|
|
|
|
expect(record) |
|
|
|
|
|
|
|
.to be_extra_borrowing_expected_but_not_reported |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns true if extra borrowing expected but not reported" do |
|
|
|
context "when the log is for 2024" do |
|
|
|
record.extrabor = 2 |
|
|
|
let(:record) { build(:sales_log, saledate: Time.zone.local(2024, 12, 1)) } |
|
|
|
record.mortgage = 50_000 |
|
|
|
|
|
|
|
record.deposit = 40_000 |
|
|
|
it "returns false for logs from 2024 onwards" do |
|
|
|
record.value = 100_000 |
|
|
|
record.extrabor = 2 |
|
|
|
record.discount = 11 |
|
|
|
record.mortgage = 50_000 |
|
|
|
expect(record) |
|
|
|
record.deposit = 40_000 |
|
|
|
.to be_extra_borrowing_expected_but_not_reported |
|
|
|
record.value = 100_000 |
|
|
|
|
|
|
|
record.discount = 11 |
|
|
|
|
|
|
|
expect(record) |
|
|
|
|
|
|
|
.not_to be_extra_borrowing_expected_but_not_reported |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|