-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sales receipts are invoices paid for on the spot.
- Loading branch information
Showing
53 changed files
with
1,118 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "../../../../spec_helper" | ||
|
||
describe Bill::Api::DirectSalesReceipts::Create do | ||
it "creates sales receipt" do | ||
user = UserFactory.create | ||
|
||
response = ApiClient.exec( | ||
Api::DirectSalesReceipts::Create, | ||
invoice: { | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
}, | ||
line_items: [{ | ||
description: "Item 1", | ||
quantity: 2, | ||
price_mu: 0.12 | ||
}] | ||
) | ||
|
||
response.should send_json(200, message: "action.invoice.create.success") | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
InvoiceQuery.new.is_paid.any?.should be_true | ||
|
||
TransactionQuery.new | ||
.user_id(user.id) | ||
.type(:receipt) | ||
.is_finalized | ||
.none? | ||
.should(be_false) | ||
end | ||
end |
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,29 @@ | ||
require "../../../../spec_helper" | ||
|
||
describe Bill::Api::DirectSalesReceipts::Update do | ||
it "updates sales receipt" do | ||
user = UserFactory.create | ||
|
||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
.description("New invoice") | ||
.status(:draft) | ||
|
||
InvoiceItemFactory.create &.invoice_id(invoice.id) | ||
|
||
response = ApiClient.exec( | ||
Api::DirectSalesReceipts::Update.with(invoice_id: invoice.id), | ||
invoice: {status: :open} | ||
) | ||
|
||
response.should send_json(200, message: "action.invoice.update.success") | ||
|
||
invoice.reload.status.paid?.should be_true | ||
|
||
TransactionQuery.new | ||
.user_id(user.id) | ||
.type(:receipt) | ||
.is_finalized | ||
.none? | ||
.should(be_false) | ||
end | ||
end |
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,28 @@ | ||
require "../../../../spec_helper" | ||
|
||
describe Bill::Api::SalesReceipts::Create do | ||
it "creates sales receipt" do | ||
response = ApiClient.exec( | ||
Api::SalesReceipts::Create, | ||
invoice: { | ||
user_id: UserFactory.create.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
}, | ||
line_items: [{ | ||
description: "Item 1", | ||
quantity: 2, | ||
price_mu: 0.12 | ||
}] | ||
) | ||
|
||
response.should send_json(200, message: "action.invoice.create.success") | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
InvoiceQuery.new.is_paid.any?.should be_true | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
ReceiptQuery.new.is_finalized.any?.should be_true | ||
end | ||
end |
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,27 @@ | ||
require "../../../../spec_helper" | ||
|
||
describe Bill::Api::SalesReceipts::Update do | ||
it "updates sales receipt" do | ||
user = UserFactory.create | ||
|
||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
.description("New invoice") | ||
.status(:draft) | ||
|
||
InvoiceItemFactory.create &.invoice_id(invoice.id) | ||
|
||
ReceiptQuery.new.none?.should be_true | ||
|
||
response = ApiClient.exec( | ||
Api::SalesReceipts::Update.with(invoice_id: invoice.id), | ||
invoice: {status: :open} | ||
) | ||
|
||
response.should send_json(200, message: "action.invoice.update.success") | ||
|
||
invoice.reload.status.paid?.should be_true | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
ReceiptQuery.new.is_finalized.any?.should be_true | ||
end | ||
end |
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,34 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::DirectSalesReceipts::Create do | ||
it "creates direct sales receipt" do | ||
user = UserFactory.create | ||
|
||
response = ApiClient.exec( | ||
DirectSalesReceipts::Create, | ||
invoice: { | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
}, | ||
line_items: [{ | ||
description: "Item 1", | ||
quantity: 2, | ||
price_mu: 0.12 | ||
}] | ||
) | ||
|
||
response.status.should eq(HTTP::Status::FOUND) | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
InvoiceQuery.new.is_paid.any?.should be_true | ||
|
||
TransactionQuery.new | ||
.user_id(user.id) | ||
.type(:receipt) | ||
.is_finalized | ||
.none? | ||
.should(be_false) | ||
end | ||
end |
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,14 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::DirectSalesReceipts::Edit do | ||
it "renders edit page" do | ||
user = UserFactory.create | ||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
|
||
response = ApiClient.exec(DirectSalesReceipts::Edit.with( | ||
invoice_id: invoice.id | ||
)) | ||
|
||
response.body.should eq("DirectSalesReceipts::EditPage") | ||
end | ||
end |
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,9 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::DirectSalesReceipts::New do | ||
it "renders new page" do | ||
response = ApiClient.exec(DirectSalesReceipts::New) | ||
|
||
response.body.should eq("DirectSalesReceipts::NewPage") | ||
end | ||
end |
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,29 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::DirectSalesReceipts::Update do | ||
it "updates direct sales receipt" do | ||
user = UserFactory.create | ||
|
||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
.description("New invoice") | ||
.status(:draft) | ||
|
||
InvoiceItemFactory.create &.invoice_id(invoice.id) | ||
|
||
response = ApiClient.exec( | ||
DirectSalesReceipts::Update.with(invoice_id: invoice.id), | ||
invoice: {status: :open} | ||
) | ||
|
||
response.status.should eq(HTTP::Status::FOUND) | ||
|
||
invoice.reload.status.paid?.should be_true | ||
|
||
TransactionQuery.new | ||
.user_id(user.id) | ||
.type(:receipt) | ||
.is_finalized | ||
.none? | ||
.should(be_false) | ||
end | ||
end |
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,28 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::SalesReceipts::Create do | ||
it "creates sales receipt" do | ||
response = ApiClient.exec( | ||
SalesReceipts::Create, | ||
invoice: { | ||
user_id: UserFactory.create.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
}, | ||
line_items: [{ | ||
description: "Item 1", | ||
quantity: 2, | ||
price_mu: 0.12 | ||
}] | ||
) | ||
|
||
response.status.should eq(HTTP::Status::FOUND) | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
InvoiceQuery.new.is_paid.any?.should be_true | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
ReceiptQuery.new.is_finalized.any?.should be_true | ||
end | ||
end |
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,12 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::SalesReceipts::Edit do | ||
it "renders edit page" do | ||
user = UserFactory.create | ||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
|
||
response = ApiClient.exec(SalesReceipts::Edit.with(invoice_id: invoice.id)) | ||
|
||
response.body.should eq("SalesReceipts::EditPage") | ||
end | ||
end |
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,9 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::SalesReceipts::New do | ||
it "renders new page" do | ||
response = ApiClient.exec(SalesReceipts::New) | ||
|
||
response.body.should eq("SalesReceipts::NewPage") | ||
end | ||
end |
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,27 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::SalesReceipts::Update do | ||
it "updates sales receipt" do | ||
user = UserFactory.create | ||
|
||
invoice = InvoiceFactory.create &.user_id(user.id) | ||
.description("New invoice") | ||
.status(:draft) | ||
|
||
InvoiceItemFactory.create &.invoice_id(invoice.id) | ||
|
||
ReceiptQuery.new.none?.should be_true | ||
|
||
response = ApiClient.exec( | ||
SalesReceipts::Update.with(invoice_id: invoice.id), | ||
invoice: {status: :open} | ||
) | ||
|
||
response.status.should eq(HTTP::Status::FOUND) | ||
|
||
invoice.reload.status.paid?.should be_true | ||
|
||
# ameba:disable Performance/AnyInsteadOfEmpty | ||
ReceiptQuery.new.is_finalized.any?.should be_true | ||
end | ||
end |
Oops, something went wrong.