Skip to content

Commit f0c7060

Browse files
committed
Improvements
1 parent abd2ffe commit f0c7060

File tree

4 files changed

+14
-35
lines changed

4 files changed

+14
-35
lines changed

components/sage_accounting/actions/create-contact-payment/create-contact-payment.mjs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import app from "../../sage_accounting.app.mjs";
2+
import { optionalParseFloat } from "../../common/utils.mjs";
23

34
export default {
45
key: "sage_accounting-create-contact-payment",
@@ -113,28 +114,14 @@ export default {
113114
date: this.date,
114115
total_amount: parseFloat(this.totalAmount),
115116
payment_method_id: this.paymentMethodId,
116-
net_amount: this.netAmount
117-
? parseFloat(this.netAmount)
118-
: undefined,
119-
tax_amount: this.taxAmount
120-
? parseFloat(this.taxAmount)
121-
: undefined,
117+
net_amount: optionalParseFloat(this.netAmount),
118+
tax_amount: optionalParseFloat(this.taxAmount),
122119
currency_id: this.currencyId,
123-
exchange_rate: this.exchangeRate
124-
? parseFloat(this.exchangeRate)
125-
: undefined,
126-
base_currency_net_amount: this.baseCurrencyNetAmount
127-
? parseFloat(this.baseCurrencyNetAmount)
128-
: undefined,
129-
base_currency_tax_amount: this.baseCurrencyTaxAmount
130-
? parseFloat(this.baseCurrencyTaxAmount)
131-
: undefined,
132-
base_currency_total_amount: this.baseCurrencyTotalAmount
133-
? parseFloat(this.baseCurrencyTotalAmount)
134-
: undefined,
135-
base_currency_currency_charge: this.baseCurrencyCurrencyCharge
136-
? parseFloat(this.baseCurrencyCurrencyCharge)
137-
: undefined,
120+
exchange_rate: optionalParseFloat(this.exchangeRate),
121+
base_currency_net_amount: optionalParseFloat(this.baseCurrencyNetAmount),
122+
base_currency_tax_amount: optionalParseFloat(this.baseCurrencyTaxAmount),
123+
base_currency_total_amount: optionalParseFloat(this.baseCurrencyTotalAmount),
124+
base_currency_currency_charge: optionalParseFloat(this.baseCurrencyCurrencyCharge),
138125
reference: this.paymentReference,
139126
tax_rate_id: this.taxRateId,
140127
};
@@ -144,7 +131,7 @@ export default {
144131
data,
145132
});
146133

147-
$.export("$summary", `Successfully created contact payment with ID: ${response.id}`);
134+
$.export("$summary", `Successfully created contact payment (ID: ${response.id})`);
148135
return response;
149136
},
150137
};

components/sage_accounting/actions/create-contact/create-contact.mjs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ConfigurationError } from "@pipedream/platform";
21
import app from "../../sage_accounting.app.mjs";
32

43
export default {
@@ -141,13 +140,6 @@ export default {
141140
},
142141
},
143142
async run({ $ }) {
144-
if (!this.name) {
145-
throw new ConfigurationError("Name is required");
146-
}
147-
if (!this.contactTypeIds || this.contactTypeIds.length === 0) {
148-
throw new ConfigurationError("At least one Contact Type ID is required");
149-
}
150-
151143
const response = await this.app.createContact({
152144
$,
153145
data: {

components/sage_accounting/actions/update-contact/update-contact.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ConfigurationError } from "@pipedream/platform";
21
import app from "../../sage_accounting.app.mjs";
32

43
export default {
@@ -149,10 +148,6 @@ export default {
149148
},
150149
},
151150
async run({ $ }) {
152-
if (!this.contactId) {
153-
throw new ConfigurationError("Contact ID is required");
154-
}
155-
156151
const response = await this.app.updateContact({
157152
$,
158153
contactId: this.contactId,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function optionalParseFloat(value) {
2+
return typeof value === "string"
3+
? parseFloat(value)
4+
: value;
5+
}

0 commit comments

Comments
 (0)