1+ using System ;
2+ using System . Collections . Generic ;
3+ using Xero . Api . Core . Model ;
4+ using Xero . Api . Core . Model . Status ;
5+ using Xero . Api . Core . Model . Types ;
6+
7+ namespace CoreTests . Integration . BatchPayments
8+ {
9+ public abstract class BatchPaymentsTest : ApiWrapperTest
10+ {
11+ protected BatchPayment Given_a_batch_payment ( decimal invoiceAmount , DateTime date , decimal amount , bool isReconciled = false )
12+ {
13+ var batchPayment = CreateBatchPayment ( invoiceAmount , date , amount , isReconciled ) ;
14+
15+ return Api . BatchPayments . Create ( batchPayment ) ;
16+ }
17+
18+ protected BatchPayment CreateBatchPayment ( decimal invoiceAmount , DateTime date , decimal amount , bool isReconciled = false )
19+ {
20+ var invoice = Given_an_invoice ( invoiceAmount , Account . Code ) ;
21+ var bankCode = BankAccount . Id ;
22+
23+ var payment = new BatchPayment
24+ {
25+ Account = new Account { Id = bankCode } ,
26+ Date = date ,
27+ Payments = new List < BatchPaymentPayment > { new BatchPaymentPayment {
28+ Amount = amount ,
29+ Invoice = new Invoice { Id = invoice . Id } ,
30+ BankAccountNumber = BankAccount . BankAccountNumber ,
31+ } }
32+ } ;
33+
34+ if ( isReconciled )
35+ {
36+ payment . IsReconciled = true ;
37+ }
38+
39+ return payment ;
40+ }
41+
42+ private Invoice Given_an_invoice ( decimal amount = 100m , string accountCode = "100" )
43+ {
44+ return Api . Create ( new Invoice
45+ {
46+ Contact = new Contact { Name = "Richard" } ,
47+ Number = Random . GetRandomString ( 10 ) ,
48+ Type = InvoiceType . AccountsPayable ,
49+ Date = DateTime . UtcNow ,
50+ DueDate = DateTime . UtcNow . AddDays ( 90 ) ,
51+ LineAmountTypes = LineAmountType . Inclusive ,
52+ Status = InvoiceStatus . Authorised ,
53+ LineItems = new List < LineItem >
54+ {
55+ new LineItem
56+ {
57+ AccountCode = accountCode ,
58+ Description = "Good value item" ,
59+ LineAmount = amount
60+ }
61+ }
62+ } ) ;
63+ }
64+
65+ }
66+ }
0 commit comments