/
InvoiceUpdate.ts
112 lines (92 loc) · 3.92 KB
/
InvoiceUpdate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* @module Intacct/SDK/Functions/AccountsReceivable
*/
/**
* Copyright 2022 Sage Intacct, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "LICENSE" file accompanying this file. This file is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import IaXmlWriter from "../../Xml/IaXmlWriter";
import AbstractInvoice from "./AbstractInvoice";
export default class InvoiceUpdate extends AbstractInvoice {
public writeXml(xml: IaXmlWriter): void {
xml.writeStartElement("function");
xml.writeAttribute("controlid", this.controlId, true);
xml.writeStartElement("update_invoice");
if (this.externalId != null) {
xml.writeAttribute("key", this.externalId);
xml.writeAttribute("externalkey", "true");
} else {
xml.writeAttribute("key", this.recordNo);
}
xml.writeElement("customerid", this.customerId);
if (this.transactionDate != null) {
xml.writeStartElement("datecreated");
xml.writeDateSplitElements(this.transactionDate);
xml.writeEndElement(); // datecreated
}
if (this.glPostingDate) {
xml.writeStartElement("dateposted");
xml.writeDateSplitElements(this.glPostingDate);
xml.writeEndElement(); // dateposted
}
if (this.dueDate) {
xml.writeStartElement("datedue");
xml.writeDateSplitElements(this.dueDate);
xml.writeEndElement(); // datedue
xml.writeElement("termname", this.paymentTerm);
} else if (this.paymentTerm != null) {
xml.writeElement("termname", this.paymentTerm);
}
xml.writeElement("action", this.action);
xml.writeElement("invoiceno", this.invoiceNumber);
xml.writeElement("ponumber", this.referenceNumber);
xml.writeElement("description", this.description);
if (this.billToContactName != null) {
xml.writeStartElement("payto");
xml.writeElement("contactname", this.billToContactName);
xml.writeEndElement(); // payto
}
if (this.shipToContactName != null) {
xml.writeStartElement("returnto");
xml.writeElement("contactname", this.shipToContactName);
xml.writeEndElement(); // returnto
}
this.writeXmlMultiCurrencySection(xml);
xml.writeElement("supdocid", this.attachmentsId);
xml.writeCustomFieldsExplicit(this.customFields);
if (this.lines != null && this.lines.length > 0) {
xml.writeStartElement("updateinvoiceitems");
for (const line of this.lines) {
line.writeXml(xml);
}
xml.writeEndElement(); // updateinvoiceitems
}
xml.writeEndElement(); // update_invoice
xml.writeEndElement(); // function
}
protected writeXmlMultiCurrencySection(xml: IaXmlWriter): void {
xml.writeElement("currency", this.transactionCurrency);
if (this.exchangeRateDate != null) {
xml.writeStartElement("exchratedate");
xml.writeDateSplitElements(this.exchangeRateDate);
xml.writeEndElement(); // exchratedate
}
if (this.exchangeRateType != null) {
xml.writeElement("exchratetype", this.exchangeRateType);
} else if (this.exchangeRateValue != null) {
xml.writeElement("exchrate", this.exchangeRateValue);
} else if ((this.baseCurrency != null) || (this.transactionCurrency != null)) {
xml.writeElement("exchratetype", this.exchangeRateType);
}
}
}