Skip to content

Commit 9dec00a

Browse files
committed
updates
1 parent b4ab376 commit 9dec00a

File tree

10 files changed

+141
-68
lines changed

10 files changed

+141
-68
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import quickbooks from "../../quickbooks.app.mjs";
3-
import {
3+
import {
44
parseLineItems,
55
buildSalesLineItems,
6+
parseObject,
67
} from "../../common/utils.mjs";
78

89
export default {
@@ -59,13 +60,13 @@ export default {
5960
billAddr: {
6061
type: "object",
6162
label: "Billing Address",
62-
description: "Billing address details",
63+
description: "Billing address details. Example: `{ \"Line1\": \"123 Elm St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
6364
optional: true,
6465
},
6566
shipAddr: {
6667
type: "object",
6768
label: "Shipping Address",
68-
description: "Shipping address details",
69+
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
6970
optional: true,
7071
},
7172
privateNote: {
@@ -167,8 +168,8 @@ export default {
167168
AcceptedBy: this.acceptedBy,
168169
AcceptedDate: this.acceptedDate,
169170
DocNumber: this.docNumber,
170-
BillAddr: this.billAddr,
171-
ShipAddr: this.shipAddr,
171+
BillAddr: parseObject(this.billAddr),
172+
ShipAddr: parseObject(this.shipAddr),
172173
PrivateNote: this.privateNote,
173174
};
174175

@@ -196,9 +197,9 @@ export default {
196197
});
197198

198199
if (response) {
199-
$.export("summary", `Successfully created estimate with ID ${response.Estimate.Id}`);
200+
$.export("$summary", `Successfully created estimate with ID ${response.Estimate.Id}`);
200201
}
201202

202203
return response;
203204
},
204-
};
205+
};

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import quickbooks from "../../quickbooks.app.mjs";
3-
import {
3+
import {
44
parseLineItems,
55
buildPurchaseLineItems,
6+
parseObject,
67
} from "../../common/utils.mjs";
78

89
export default {
@@ -13,6 +14,15 @@ export default {
1314
type: "action",
1415
props: {
1516
quickbooks,
17+
accountId: {
18+
propDefinition: [
19+
quickbooks,
20+
"accountIds",
21+
],
22+
type: "string",
23+
label: "Account ID",
24+
description: "The ID of the account to use for the purchase order",
25+
},
1626
vendorRefValue: {
1727
propDefinition: [
1828
quickbooks,
@@ -40,7 +50,7 @@ export default {
4050
shipAddr: {
4151
type: "object",
4252
label: "Shipping Address",
43-
description: "Shipping address details",
53+
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
4454
optional: true,
4555
},
4656
memo: {
@@ -81,8 +91,14 @@ export default {
8191
type: "string",
8292
label: `Line ${i} - Detail Type`,
8393
options: [
84-
{ label: "Item Based Expense", value: "ItemBasedExpenseLineDetail" },
85-
{ label: "Account Based Expense", value: "AccountBasedExpenseLineDetail" }
94+
{
95+
label: "Item Based Expense",
96+
value: "ItemBasedExpenseLineDetail",
97+
},
98+
{
99+
label: "Account Based Expense",
100+
value: "AccountBasedExpenseLineDetail",
101+
},
86102
],
87103
default: "ItemBasedExpenseLineDetail",
88104
};
@@ -106,6 +122,10 @@ export default {
106122
type: "string",
107123
label: `Line ${i} - Amount`,
108124
};
125+
props[`quantity_${i}`] = {
126+
type: "string",
127+
label: `Line ${i} - Quantity`,
128+
};
109129
}
110130
return props;
111131
},
@@ -144,8 +164,11 @@ export default {
144164
},
145165
DueDate: this.dueDate,
146166
DocNumber: this.docNumber,
147-
ShipAddr: this.shipAddr,
167+
ShipAddr: parseObject(this.shipAddr),
148168
Memo: this.memo,
169+
APAccountRef: {
170+
value: this.accountId,
171+
},
149172
};
150173

151174
if (this.currencyRefValue) {
@@ -160,9 +183,9 @@ export default {
160183
});
161184

162185
if (response) {
163-
$.export("summary", `Successfully created purchase order with ID ${response.PurchaseOrder.Id}`);
186+
$.export("$summary", `Successfully created purchase order with ID ${response.PurchaseOrder.Id}`);
164187
}
165188

166189
return response;
167190
},
168-
};
191+
};

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,25 @@ export default {
1818
type: "string",
1919
label: "Email Address",
2020
description: "Email address to send the estimate to (optional - if not provided, uses the customer's email address)",
21-
optional: true,
2221
},
2322
},
2423
async run({ $ }) {
25-
const data = {};
26-
24+
const params = {};
25+
2726
if (this.email) {
28-
data.email = this.email;
27+
params.sendTo = this.email;
2928
}
3029

3130
const response = await this.quickbooks.sendEstimate({
3231
$,
3332
estimateId: this.estimateId,
34-
data,
33+
params,
3534
});
3635

3736
if (response) {
38-
$.export("summary", `Successfully sent estimate with ID ${this.estimateId}`);
37+
$.export("$summary", `Successfully sent estimate with ID ${this.estimateId}`);
3938
}
4039

4140
return response;
4241
},
43-
};
42+
};

components/quickbooks/actions/send-invoice/send-invoice.mjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,26 @@ export default {
1717
email: {
1818
type: "string",
1919
label: "Email Address",
20-
description: "Email address to send the invoice to (optional - if not provided, uses the customer's email address)",
21-
optional: true,
20+
description: "Email address to send the invoice to",
2221
},
2322
},
2423
async run({ $ }) {
25-
const data = {};
26-
24+
const params = {};
25+
2726
if (this.email) {
28-
data.email = this.email;
27+
params.sendTo = this.email;
2928
}
3029

3130
const response = await this.quickbooks.sendInvoice({
3231
$,
3332
invoiceId: this.invoiceId,
34-
data,
33+
params,
3534
});
3635

3736
if (response) {
38-
$.export("summary", `Successfully sent invoice with ID ${this.invoiceId}`);
37+
$.export("$summary", `Successfully sent invoice with ID ${this.invoiceId}`);
3938
}
4039

4140
return response;
4241
},
43-
};
42+
};

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import quickbooks from "../../quickbooks.app.mjs";
3-
import {
3+
import {
44
parseLineItems,
55
buildSalesLineItems,
6+
parseObject,
67
} from "../../common/utils.mjs";
78

89
export default {
@@ -24,7 +25,6 @@ export default {
2425
quickbooks,
2526
"customer",
2627
],
27-
optional: true,
2828
},
2929
billEmail: {
3030
type: "string",
@@ -66,13 +66,13 @@ export default {
6666
billAddr: {
6767
type: "object",
6868
label: "Billing Address",
69-
description: "Billing address details",
69+
description: "Billing address details. Example: `{ \"Line1\": \"123 Elm St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
7070
optional: true,
7171
},
7272
shipAddr: {
7373
type: "object",
7474
label: "Shipping Address",
75-
description: "Shipping address details",
75+
description: "Shipping address details. Example: `{ \"Line1\": \"456 Oak St.\", \"City\": \"Springfield\", \"CountrySubDivisionCode\": \"IL\", \"PostalCode\": \"62701\" }`",
7676
optional: true,
7777
},
7878
privateNote: {
@@ -151,13 +151,18 @@ export default {
151151
},
152152
// Helper function to conditionally add properties
153153
addIfDefined(target, source, mappings) {
154-
Object.entries(mappings).forEach(([sourceKey, targetConfig]) => {
154+
Object.entries(mappings).forEach(([
155+
sourceKey,
156+
targetConfig,
157+
]) => {
155158
const value = source[sourceKey];
156159
if (value !== undefined && value !== null) {
157160
if (typeof targetConfig === "string") {
158161
target[targetConfig] = value;
159162
} else if (typeof targetConfig === "object") {
160-
target[targetConfig.key] = targetConfig.transform ? targetConfig.transform(value) : value;
163+
target[targetConfig.key] = targetConfig.transform
164+
? targetConfig.transform(value)
165+
: value;
161166
}
162167
}
163168
});
@@ -173,6 +178,8 @@ export default {
173178
const data = {
174179
Id: this.estimateId,
175180
SyncToken: estimate.SyncToken,
181+
BillAddr: parseObject(this.billAddr),
182+
ShipAddr: parseObject(this.shipAddr),
176183
};
177184

178185
// Only update fields that are provided
@@ -196,14 +203,12 @@ export default {
196203
data.Line = lines;
197204
}
198205

199-
// Add simple field mappings
206+
// Add simple field mapping
200207
this.addIfDefined(data, this, {
201208
expirationDate: "ExpirationDate",
202209
acceptedBy: "AcceptedBy",
203210
acceptedDate: "AcceptedDate",
204211
docNumber: "DocNumber",
205-
billAddr: "BillAddr",
206-
shipAddr: "ShipAddr",
207212
privateNote: "PrivateNote",
208213
});
209214

@@ -231,11 +236,11 @@ export default {
231236
});
232237

233238
if (response?.Estimate?.Id) {
234-
$.export("summary", `Successfully updated estimate with ID ${response.Estimate.Id}`);
239+
$.export("$summary", `Successfully updated estimate with ID ${response.Estimate.Id}`);
235240
} else {
236241
throw new ConfigurationError("Failed to update estimate: Invalid response from QuickBooks API");
237242
}
238243

239244
return response;
240245
},
241-
};
246+
};

0 commit comments

Comments
 (0)