File tree Expand file tree Collapse file tree 4 files changed +50
-27
lines changed Expand file tree Collapse file tree 4 files changed +50
-27
lines changed Original file line number Diff line number Diff line change 6
6
use PhpTwinfield \Enums \LineType ;
7
7
use PhpTwinfield \Transactions \TransactionLine ;
8
8
use PhpTwinfield \Transactions \TransactionLineFields \CommentField ;
9
+ use PhpTwinfield \Transactions \TransactionLineFields \FreeCharField ;
9
10
use PhpTwinfield \Transactions \TransactionLineFields \ThreeDimFields ;
10
11
use PhpTwinfield \Transactions \TransactionLineFields \ValueFields ;
11
12
use PhpTwinfield \Transactions \TransactionLineFields \VatTurnoverFields ;
16
17
* @todo $vatBaseValue Only if line type is detail. VAT amount in base currency.
17
18
* @todo $vatRepValue Only if line type is detail. VAT amount in reporting currency.
18
19
* @todo $destOffice Office code. Used for inter company transactions.
19
- * @todo $freeChar Free character field. Meaning differs per transaction type.
20
20
* @todo $comment Comment set on the transaction line.
21
21
* @todo $matches Contains matching information. Read-only attribute.
22
22
*
@@ -28,6 +28,7 @@ abstract class BaseTransactionLine implements TransactionLine
28
28
use ThreeDimFields;
29
29
use VatTurnoverFields;
30
30
use CommentField;
31
+ use FreeCharField;
31
32
32
33
public const MATCHSTATUS_AVAILABLE = 'available ' ;
33
34
public const MATCHSTATUS_MATCHED = 'matched ' ;
Original file line number Diff line number Diff line change 9
9
use PhpTwinfield \Transactions \TransactionFields \DueDateField ;
10
10
use PhpTwinfield \Transactions \TransactionFields \InvoiceNumberField ;
11
11
use PhpTwinfield \Transactions \TransactionFields \PaymentReferenceField ;
12
+ use PhpTwinfield \Transactions \TransactionLineFields \FreeCharField ;
12
13
use PhpTwinfield \Transactions \TransactionLineFields \PerformanceFields ;
13
14
use PhpTwinfield \Transactions \TransactionLineFields \VatTotalFields ;
14
15
use PhpTwinfield \Util ;
@@ -147,6 +148,15 @@ public function addTransaction(BaseTransaction $transaction)
147
148
}
148
149
}
149
150
151
+ if (Util::objectUses (FreeCharField::class, $ transactionLine )) {
152
+ /** @var FreeCharField $transactionLine */
153
+ $ freeChar = $ transactionLine ->getFreeChar ();
154
+ if (!empty ($ freeChar )) {
155
+ $ freeCharElement = $ this ->createNodeWithTextContent ('freechar ' , $ freeChar );
156
+ $ lineElement ->appendChild ($ freeCharElement );
157
+ }
158
+ }
159
+
150
160
if (Util::objectUses (VatTotalFields::class, $ transactionLine )) {
151
161
/** @var VatTotalFields $transactionLine */
152
162
$ vatTotal = $ transactionLine ->getVatTotal ();
Original file line number Diff line number Diff line change 10
10
use PhpTwinfield \Transactions \TransactionFields \InvoiceNumberField ;
11
11
use PhpTwinfield \Transactions \TransactionLine ;
12
12
use PhpTwinfield \Transactions \TransactionLineFields \CommentField ;
13
+ use PhpTwinfield \Transactions \TransactionLineFields \FreeCharField ;
13
14
use PhpTwinfield \Transactions \TransactionLineFields \ThreeDimFields ;
14
15
use PhpTwinfield \Transactions \TransactionLineFields \ValueFields ;
15
16
use Webmozart \Assert \Assert ;
@@ -19,6 +20,7 @@ abstract class Base implements TransactionLine
19
20
use ValueFields;
20
21
use ThreeDimFields;
21
22
use CommentField;
23
+ use FreeCharField;
22
24
23
25
/**
24
26
* Note that the field is not in the documentation but it is in all the examples.
@@ -48,13 +50,6 @@ abstract class Base implements TransactionLine
48
50
*/
49
51
private $ destOffice ;
50
52
51
- /**
52
- * Free character field. (1 char)
53
- *
54
- * @var string
55
- */
56
- private $ freeChar ;
57
-
58
53
/**
59
54
* @var BankTransaction
60
55
*/
@@ -136,24 +131,6 @@ public function setDestOffice(Office $destOffice)
136
131
return $ this ;
137
132
}
138
133
139
- /**
140
- * @return string
141
- */
142
- public function getFreeChar (): ?string
143
- {
144
- return $ this ->freeChar ;
145
- }
146
-
147
- /**
148
- * @param string $freeChar
149
- * @return $this
150
- */
151
- public function setFreeChar (string $ freeChar )
152
- {
153
- $ this ->freeChar = $ freeChar ;
154
- return $ this ;
155
- }
156
-
157
134
public function getId (): ?int
158
135
{
159
136
return $ this ->id ;
@@ -185,4 +162,4 @@ protected function isIncomingTransactionType(): bool
185
162
{
186
163
return true ;
187
164
}
188
- }
165
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace PhpTwinfield \Transactions \TransactionLineFields ;
4
+
5
+ use Webmozart \Assert \Assert ;
6
+
7
+ trait FreeCharField
8
+ {
9
+ /**
10
+ * If line type is total and filled with N the sales invoice is excluded from direct debit runs done in Twinfield.
11
+ *
12
+ * @var string|null
13
+ */
14
+ private $ freeChar ;
15
+
16
+ /**
17
+ * @return string|null
18
+ */
19
+ public function getFreeChar (): ?string
20
+ {
21
+ return $ this ->freeChar ;
22
+ }
23
+
24
+ /**
25
+ * @param string|null $freeChar
26
+ * @return $this
27
+ */
28
+ public function setFreeChar (?string $ freeChar ): self
29
+ {
30
+ Assert::length ($ freeChar , 1 );
31
+ $ this ->freeChar = $ freeChar ;
32
+
33
+ return $ this ;
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments