Bugzilla – Attachment 74745 Details for
Bug 19166
Add the ability to add adjustments to an invoice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19166: Unit tests for GetBudgetSpent and GetBudget ordered
Bug-19166-Unit-tests-for-GetBudgetSpent-and-GetBud.patch (text/plain), 5.33 KB, created by
Biblibre Sandboxes
on 2018-04-23 15:53:50 UTC
(
hide
)
Description:
Bug 19166: Unit tests for GetBudgetSpent and GetBudget ordered
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2018-04-23 15:53:50 UTC
Size:
5.33 KB
patch
obsolete
>From 1f4f12ed8cace81a5bec3a19f6446e65eddd9b13 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 4 Oct 2017 13:22:21 +0000 >Subject: [PATCH] Bug 19166: Unit tests for GetBudgetSpent and GetBudget > ordered >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >To test: >1. prove -v t/db_dependent/Budgets.t >2. Should return green > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > t/db_dependent/Budgets.t | 118 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 116 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 21f2d59..7395ed3 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,6 +1,6 @@ > #!/usr/bin/perl > use Modern::Perl; >-use Test::More tests => 144; >+use Test::More tests => 145; > > BEGIN { > use_ok('C4::Budgets') >@@ -472,7 +472,7 @@ ModReceiveOrder({ > } ); > > is ( GetBudgetSpent( $fund ), 6, "total shipping cost is 6"); >-is ( GetBudgetOrdered( $fund ), '20.000000', "total ordered price is 20"); >+is ( GetBudgetOrdered( $fund ), '26', "total ordered price is 20"); > > > # CloneBudgetPeriod >@@ -798,6 +798,120 @@ is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting cat > > # /Test GetBudgetAuthCats > >+subtest 'GetBudgetSpent and GetBudgetOrdered' => sub { >+ plan tests => 10; >+ >+ my $budget = $builder->build({ >+ source => 'Aqbudget', >+ value => { >+ budget_amount => 1000, >+ } >+ }); >+ my $invoice = $builder->build({ >+ source => 'Aqinvoice', >+ value => { >+ closedate => undef, >+ } >+ }); >+ >+ my $spent = GetBudgetSpent( $budget->{budget_id} ); >+ my $ordered = GetBudgetOrdered( $budget->{budget_id} ); >+ >+ is( $spent, 0, "New budget, no orders/invoices, should be nothing spent"); >+ is( $ordered, 0, "New budget, no orders/invoices, should be nothing ordered"); >+ >+ my $inv_adj_1 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 0, >+ budget_id => $budget->{budget_id}, >+ } >+ }); >+ >+ $spent = GetBudgetSpent( $budget->{budget_id} ); >+ $ordered = GetBudgetOrdered( $budget->{budget_id} ); >+ is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); >+ is( $ordered, 0, "After adding invoice adjustment on open invoice not encumbered, should be nothing ordered"); >+ >+ my $inv_adj_2 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 1, >+ budget_id => $budget->{budget_id}, >+ } >+ }); >+ >+ $spent = GetBudgetSpent( $budget->{budget_id} ); >+ $ordered = GetBudgetOrdered( $budget->{budget_id} ); >+ is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); >+ is( $ordered, 3, "After adding invoice adjustment on open invoice encumbered, should be 3 ordered"); >+ >+ my $invoice_2 = $builder->build({ >+ source => 'Aqinvoice', >+ value => { >+ closedate => '2017-07-01', >+ } >+ }); >+ my $inv_adj_3 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice_2->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 0, >+ budget_id => $budget->{budget_id}, >+ } >+ }); >+ my $inv_adj_4 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice_2->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 1, >+ budget_id => $budget->{budget_id}, >+ } >+ }); >+ >+ $spent = GetBudgetSpent( $budget->{budget_id} ); >+ $ordered = GetBudgetOrdered( $budget->{budget_id} ); >+ is( $spent, 6, "After adding invoice adjustment on closed invoice, should be 6 spent, encumber has no affect once closed"); >+ is( $ordered, 3, "After adding invoice adjustment on closed invoice, should still be 3 ordered"); >+ >+ my $budget_2 = $builder->build({ >+ source => 'Aqbudget', >+ value => { >+ budget_amount => 1000, >+ } >+ }); >+ my $inv_adj_5 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 1, >+ budget_id => $budget_2->{budget_id}, >+ } >+ }); >+ my $inv_adj_6 = $builder->build({ >+ source => 'InvoiceAdjustment', >+ value => { >+ invoiceid => $invoice_2->{invoiceid}, >+ adjustment => 3, >+ encumber_open => 1, >+ budget_id => $budget_2->{budget_id}, >+ } >+ }); >+ >+ $spent = GetBudgetSpent( $budget->{budget_id} ); >+ $ordered = GetBudgetOrdered( $budget->{budget_id} ); >+ is( $spent, 6, "After adding invoice adjustment on a different budget should be 6 spent/budget unaffected"); >+ is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); >+ >+}; >+ > sub _get_dependencies { > my ($budget_hierarchy) = @_; > my $graph; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19166
:
66475
|
66476
|
67599
|
67600
|
67601
|
67602
|
67890
|
70413
|
70414
|
70415
|
70416
|
72702
|
72703
|
72704
|
72705
|
72744
|
72978
|
73481
|
73482
|
73483
|
73484
|
73485
|
73486
|
73487
|
74742
|
74743
|
74744
|
74745
|
74746
|
74747
|
74748
|
74843
|
74893
|
74894
|
74895
|
74896
|
74897
|
74898
|
74899
|
74900
|
75014
|
75043
|
76994
|
76995
|
76996
|
76997
|
76998
|
76999
|
77000
|
77001
|
77002
|
77003
|
77004
|
77104
|
77105
|
77106
|
77107
|
77108
|
77109
|
77110
|
77111
|
77112
|
77113
|
77114
|
77115
|
77116
|
77117
|
77118
|
77119
|
77120
|
77121
|
77122
|
77123
|
77124
|
77125
|
77126
|
77127
|
77128
|
77129
|
77130
|
77131
|
77132
|
77133
|
77134
|
77329