Skip to content

Commit cf16225

Browse files
committed
update address props
1 parent b3f86da commit cf16225

File tree

5 files changed

+433
-46
lines changed

5 files changed

+433
-46
lines changed

components/quickbooks/actions/create-estimate/create-estimate.mjs

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import quickbooks from "../../quickbooks.app.mjs";
33
import {
44
parseLineItems,
55
buildSalesLineItems,
6-
parseObject,
76
} from "../../common/utils.mjs";
87

98
export default {
@@ -57,17 +56,77 @@ export default {
5756
description: "Reference number for the transaction",
5857
optional: true,
5958
},
60-
billAddr: {
61-
type: "object",
62-
label: "Billing Address",
63-
description: "Billing address details. Example: `{ \"Line1\": \"123 Elm St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
64-
optional: true,
59+
billingStreetAddress: {
60+
propDefinition: [
61+
quickbooks,
62+
"billingStreetAddress",
63+
],
6564
},
66-
shipAddr: {
67-
type: "object",
68-
label: "Shipping Address",
69-
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
70-
optional: true,
65+
billingCity: {
66+
propDefinition: [
67+
quickbooks,
68+
"billingCity",
69+
],
70+
},
71+
billingState: {
72+
propDefinition: [
73+
quickbooks,
74+
"billingState",
75+
],
76+
},
77+
billingZip: {
78+
propDefinition: [
79+
quickbooks,
80+
"billingZip",
81+
],
82+
},
83+
billingLatitude: {
84+
propDefinition: [
85+
quickbooks,
86+
"billingLatitude",
87+
],
88+
},
89+
billingLongitude: {
90+
propDefinition: [
91+
quickbooks,
92+
"billingLongitude",
93+
],
94+
},
95+
shippingStreetAddress: {
96+
propDefinition: [
97+
quickbooks,
98+
"shippingStreetAddress",
99+
],
100+
},
101+
shippingCity: {
102+
propDefinition: [
103+
quickbooks,
104+
"shippingCity",
105+
],
106+
},
107+
shippingState: {
108+
propDefinition: [
109+
quickbooks,
110+
"shippingState",
111+
],
112+
},
113+
shippingZip: {
114+
propDefinition: [
115+
quickbooks,
116+
"shippingZip",
117+
],
118+
},
119+
shippingLatitude: {
120+
propDefinition: [
121+
quickbooks,
122+
"shippingLatitude",
123+
],
124+
},
125+
shippingLongitude: {
126+
propDefinition: [
127+
quickbooks,
128+
"shippingLongitude",
129+
],
71130
},
72131
privateNote: {
73132
type: "string",
@@ -158,6 +217,19 @@ export default {
158217
}
159218
});
160219

220+
const hasBillingAddress = this.billingStreetAddress
221+
|| this.billingCity
222+
|| this.billingState
223+
|| this.billingZip
224+
|| this.billingLatitude
225+
|| this.billingLongitude;
226+
const hasShippingAddress = this.shippingStreetAddress
227+
|| this.shippingCity
228+
|| this.shippingState
229+
|| this.shippingZip
230+
|| this.shippingLatitude
231+
|| this.shippingLongitude;
232+
161233
const params = {};
162234
const data = {
163235
Line: lines,
@@ -168,8 +240,26 @@ export default {
168240
AcceptedBy: this.acceptedBy,
169241
AcceptedDate: this.acceptedDate,
170242
DocNumber: this.docNumber,
171-
BillAddr: parseObject(this.billAddr),
172-
ShipAddr: parseObject(this.shipAddr),
243+
BillAddr: hasBillingAddress
244+
? {
245+
Line1: this.billingStreetAddress,
246+
City: this.billingCity,
247+
CountrySubDivisionCode: this.billingState,
248+
PostalCode: this.billingZip,
249+
Lat: this.billingLatitude,
250+
Long: this.billingLongitude,
251+
}
252+
: undefined,
253+
ShipAddr: hasShippingAddress
254+
? {
255+
Line1: this.shippingStreetAddress,
256+
City: this.shippingCity,
257+
CountrySubDivisionCode: this.shippingState,
258+
PostalCode: this.shippingZip,
259+
Lat: this.shippingLatitude,
260+
Long: this.shippingLongitude,
261+
}
262+
: undefined,
173263
PrivateNote: this.privateNote,
174264
};
175265

components/quickbooks/actions/create-purchase-order/create-purchase-order.mjs

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import quickbooks from "../../quickbooks.app.mjs";
33
import {
44
parseLineItems,
55
buildPurchaseLineItems,
6-
parseObject,
76
} from "../../common/utils.mjs";
87

98
export default {
@@ -47,11 +46,41 @@ export default {
4746
description: "Reference number for the transaction",
4847
optional: true,
4948
},
50-
shipAddr: {
51-
type: "object",
52-
label: "Shipping Address",
53-
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
54-
optional: true,
49+
shippingStreetAddress: {
50+
propDefinition: [
51+
quickbooks,
52+
"shippingStreetAddress",
53+
],
54+
},
55+
shippingCity: {
56+
propDefinition: [
57+
quickbooks,
58+
"shippingCity",
59+
],
60+
},
61+
shippingState: {
62+
propDefinition: [
63+
quickbooks,
64+
"shippingState",
65+
],
66+
},
67+
shippingZip: {
68+
propDefinition: [
69+
quickbooks,
70+
"shippingZip",
71+
],
72+
},
73+
shippingLatitude: {
74+
propDefinition: [
75+
quickbooks,
76+
"shippingLatitude",
77+
],
78+
},
79+
shippingLongitude: {
80+
propDefinition: [
81+
quickbooks,
82+
"shippingLongitude",
83+
],
5584
},
5685
memo: {
5786
type: "string",
@@ -157,14 +186,30 @@ export default {
157186
}
158187
});
159188

189+
const hasShippingAddress = this.shippingStreetAddress
190+
|| this.shippingCity
191+
|| this.shippingState
192+
|| this.shippingZip
193+
|| this.shippingLatitude
194+
|| this.shippingLongitude;
195+
160196
const data = {
161197
Line: lines,
162198
VendorRef: {
163199
value: this.vendorRefValue,
164200
},
165201
DueDate: this.dueDate,
166202
DocNumber: this.docNumber,
167-
ShipAddr: parseObject(this.shipAddr),
203+
ShipAddr: hasShippingAddress
204+
? {
205+
Line1: this.shippingStreetAddress,
206+
City: this.shippingCity,
207+
CountrySubDivisionCode: this.shippingState,
208+
PostalCode: this.shippingZip,
209+
Lat: this.shippingLatitude,
210+
Long: this.shippingLongitude,
211+
}
212+
: undefined,
168213
Memo: this.memo,
169214
APAccountRef: {
170215
value: this.accountId,

components/quickbooks/actions/update-estimate/update-estimate.mjs

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import quickbooks from "../../quickbooks.app.mjs";
33
import {
44
parseLineItems,
55
buildSalesLineItems,
6-
parseObject,
76
} from "../../common/utils.mjs";
87

98
export default {
@@ -63,17 +62,77 @@ export default {
6362
description: "Reference number for the transaction",
6463
optional: true,
6564
},
66-
billAddr: {
67-
type: "object",
68-
label: "Billing Address",
69-
description: "Billing address details. Example: `{ \"Line1\": \"123 Elm St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
70-
optional: true,
65+
billingStreetAddress: {
66+
propDefinition: [
67+
quickbooks,
68+
"billingStreetAddress",
69+
],
7170
},
72-
shipAddr: {
73-
type: "object",
74-
label: "Shipping Address",
75-
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
76-
optional: true,
71+
billingCity: {
72+
propDefinition: [
73+
quickbooks,
74+
"billingCity",
75+
],
76+
},
77+
billingState: {
78+
propDefinition: [
79+
quickbooks,
80+
"billingState",
81+
],
82+
},
83+
billingZip: {
84+
propDefinition: [
85+
quickbooks,
86+
"billingZip",
87+
],
88+
},
89+
billingLatitude: {
90+
propDefinition: [
91+
quickbooks,
92+
"billingLatitude",
93+
],
94+
},
95+
billingLongitude: {
96+
propDefinition: [
97+
quickbooks,
98+
"billingLongitude",
99+
],
100+
},
101+
shippingStreetAddress: {
102+
propDefinition: [
103+
quickbooks,
104+
"shippingStreetAddress",
105+
],
106+
},
107+
shippingCity: {
108+
propDefinition: [
109+
quickbooks,
110+
"shippingCity",
111+
],
112+
},
113+
shippingState: {
114+
propDefinition: [
115+
quickbooks,
116+
"shippingState",
117+
],
118+
},
119+
shippingZip: {
120+
propDefinition: [
121+
quickbooks,
122+
"shippingZip",
123+
],
124+
},
125+
shippingLatitude: {
126+
propDefinition: [
127+
quickbooks,
128+
"shippingLatitude",
129+
],
130+
},
131+
shippingLongitude: {
132+
propDefinition: [
133+
quickbooks,
134+
"shippingLongitude",
135+
],
77136
},
78137
privateNote: {
79138
type: "string",
@@ -175,11 +234,42 @@ export default {
175234
estimateId: this.estimateId,
176235
});
177236

237+
const hasBillingAddress = this.billingStreetAddress
238+
|| this.billingCity
239+
|| this.billingState
240+
|| this.billingZip
241+
|| this.billingLatitude
242+
|| this.billingLongitude;
243+
const hasShippingAddress = this.shippingStreetAddress
244+
|| this.shippingCity
245+
|| this.shippingState
246+
|| this.shippingZip
247+
|| this.shippingLatitude
248+
|| this.shippingLongitude;
249+
178250
const data = {
179251
Id: this.estimateId,
180252
SyncToken: estimate.SyncToken,
181-
BillAddr: parseObject(this.billAddr),
182-
ShipAddr: parseObject(this.shipAddr),
253+
BillAddr: hasBillingAddress
254+
? {
255+
Line1: this.billingStreetAddress,
256+
City: this.billingCity,
257+
CountrySubDivisionCode: this.billingState,
258+
PostalCode: this.billingZip,
259+
Lat: this.billingLatitude,
260+
Long: this.billingLongitude,
261+
}
262+
: undefined,
263+
ShipAddr: hasShippingAddress
264+
? {
265+
Line1: this.shippingStreetAddress,
266+
City: this.shippingCity,
267+
CountrySubDivisionCode: this.shippingState,
268+
PostalCode: this.shippingZip,
269+
Lat: this.shippingLatitude,
270+
Long: this.shippingLongitude,
271+
}
272+
: undefined,
183273
};
184274

185275
// Only update fields that are provided

0 commit comments

Comments
 (0)