Skip to content

Commit 2a13982

Browse files
authored
add DRAFTED status (#40)
* add DRAFTED status * pass build
1 parent 23e349f commit 2a13982

File tree

16 files changed

+25
-25
lines changed

16 files changed

+25
-25
lines changed

lib/accountify/invoice.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Invoice
33
extend self
44

55
module Status
6-
DRAFT = 'draft'
6+
DRAFTED = 'drafted'
77
ISSUED = 'issued'
88
PAID = 'paid'
99
VOIDED = 'voided'
@@ -33,7 +33,7 @@ def draft(user_id:, tenant_id:,
3333
tenant_id: tenant_id,
3434
organisation_id: organisation_id,
3535
contact_id: contact_id,
36-
status: Status::DRAFT,
36+
status: Status::DRAFTED,
3737
currency_code: currency_code,
3838
due_date: due_date,
3939
sub_total_amount: line_items.sum do |line_item|
@@ -156,7 +156,7 @@ def update(user_id:, tenant_id:, id:,
156156
organisation_id: organisation.id,
157157
updated_at: current_utc_time,
158158
contact_id: contact.id,
159-
status: Status::DRAFT,
159+
status: Status::DRAFTED,
160160
due_date: due_date,
161161
sub_total_amount: line_items.sum do |line_item|
162162
BigDecimal(line_item[:unit_amount][:amount]) * line_item[:quantity].to_i

lib/accountify/invoice_status_summary.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def generate(tenant_id:, organisation_id:, time: ::Time)
1515
tenant_id: tenant_id,
1616
organisation_id: organisation_id,
1717
generated_at: current_utc_time,
18-
drafted_count: grouped_invoices[Invoice::Status::DRAFT] || 0,
18+
drafted_count: grouped_invoices[Invoice::Status::DRAFTED] || 0,
1919
issued_count: grouped_invoices[Invoice::Status::ISSUED] || 0,
2020
paid_count: grouped_invoices[Invoice::Status::PAID] || 0,
2121
voided_count: grouped_invoices[Invoice::Status::VOIDED] || 0)
@@ -42,7 +42,7 @@ def regenerate(tenant_id:, organisation_id:,
4242

4343
summary.update!(
4444
generated_at: current_utc_time,
45-
drafted_count: grouped_invoices[Invoice::Status::DRAFT] || 0,
45+
drafted_count: grouped_invoices[Invoice::Status::DRAFTED] || 0,
4646
issued_count: grouped_invoices[Invoice::Status::ISSUED] || 0,
4747
paid_count: grouped_invoices[Invoice::Status::PAID] || 0,
4848
voided_count: grouped_invoices[Invoice::Status::VOIDED] || 0)

spec/controllers/accountify/invoice_controller/delete_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Accountify
2424
organisation_id: organisation.id,
2525
contact_id: contact.id,
2626
currency_code: "AUD",
27-
status: Invoice::Status::DRAFT,
27+
status: Invoice::Status::DRAFTED,
2828
due_date: current_date + 30.days,
2929
sub_total_amount: BigDecimal("600.00"),
3030
sub_total_currency_code: "AUD",

spec/controllers/accountify/invoice_controller/find_by_id_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Accountify
2929
organisation_id: organisation.id,
3030
contact_id: contact.id,
3131
currency_code: "AUD",
32-
status: Invoice::Status::DRAFT,
32+
status: Invoice::Status::DRAFTED,
3333
due_date: current_date + 30.days,
3434
sub_total_amount: BigDecimal("600.00"),
3535
sub_total_currency_code: "AUD",
@@ -72,7 +72,7 @@ module Accountify
7272
"amount" => "400.0",
7373
"currency_code" => "AUD" } } ],
7474
"organisation_id" => organisation.id,
75-
"status" => "draft",
75+
"status" => "drafted",
7676
"sub_total" => {
7777
"amount" => "600.0",
7878
"currency_code" => "AUD" },

spec/controllers/accountify/invoice_controller/issue_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Accountify
2424
organisation_id: organisation.id,
2525
contact_id: contact.id,
2626
currency_code: "AUD",
27-
status: Invoice::Status::DRAFT,
27+
status: Invoice::Status::DRAFTED,
2828
due_date: current_date + 30.days,
2929
sub_total_amount: BigDecimal("600.00"),
3030
sub_total_currency_code: "AUD",

spec/controllers/accountify/invoice_controller/update_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Accountify
3232
organisation_id: organisation_1.id,
3333
contact_id: contact_1.id,
3434
currency_code: "AUD",
35-
status: Invoice::Status::DRAFT,
35+
status: Invoice::Status::DRAFTED,
3636
due_date: current_date + 30.days,
3737
sub_total_amount: BigDecimal("600.00"),
3838
sub_total_currency_code: "AUD",

spec/controllers/accountify/invoice_controller/void_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Accountify
2525
organisation_id: organisation.id,
2626
contact_id: contact.id,
2727
currency_code: "AUD",
28-
status: Invoice::Status::DRAFT,
28+
status: Invoice::Status::DRAFTED,
2929
due_date: current_date + 30.days,
3030
sub_total_amount: BigDecimal("600.00"),
3131
sub_total_currency_code: "AUD",

spec/factories/accountify_invoices.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
sub_total_amount { BigDecimal("100.00") }
77
sub_total_currency_code { "AUD" }
88

9-
trait :draft do
10-
status { "draft" }
9+
trait :drafted do
10+
status { "drafted" }
1111
end
1212

1313
trait :approved do

spec/lib/accountify/invoice/delete_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Accountify
2424
contact_id: contact.id,
2525
currency_code: "AUD",
2626
due_date: current_date + 30.days,
27-
status: Invoice::Status::DRAFT,
27+
status: Invoice::Status::DRAFTED,
2828
sub_total_amount: BigDecimal("1800.00"),
2929
sub_total_currency_code: "AUD"
3030
).id

spec/lib/accountify/invoice/draft_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module Accountify
5252
expect(invoice_model).to have_attributes(
5353
organisation_id: organisation.id,
5454
contact_id: contact.id,
55-
status: Invoice::Status::DRAFT,
55+
status: Invoice::Status::DRAFTED,
5656
currency_code: "AUD",
5757
due_date: current_date + 30.days,
5858
line_items: match_array([
@@ -76,7 +76,7 @@ module Accountify
7676
'id' => invoice[:id],
7777
'organisation_id' => organisation.id,
7878
'contact_id' => contact.id,
79-
'status' => Invoice::Status::DRAFT,
79+
'status' => Invoice::Status::DRAFTED,
8080
'currency_code' => "AUD",
8181
'due_date' => (current_date + 30.days ).to_s,
8282
'line_items' => [{

0 commit comments

Comments
 (0)