-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Unleashed - new components #18739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Unleashed - new components #18739
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import unleashedSoftware from "../../unleashed_software.app.mjs"; | ||
|
||
export default { | ||
key: "unleashed_software-create-purchase-order", | ||
name: "Create Purchase Order", | ||
description: "Create a purchase order. [See the documentation](https://apidocs.unleashedsoftware.com/Purchases)", | ||
version: "0.0.1", | ||
type: "action", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: false, | ||
}, | ||
props: { | ||
unleashedSoftware, | ||
orderStatus: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"purchaseOrderStatus", | ||
], | ||
}, | ||
supplierId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"supplierId", | ||
], | ||
}, | ||
taxCode: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"taxCode", | ||
], | ||
}, | ||
warehouseId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"warehouseId", | ||
], | ||
optional: true, | ||
}, | ||
exchangeRate: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"exchangeRate", | ||
], | ||
optional: true, | ||
}, | ||
comments: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"comments", | ||
], | ||
}, | ||
numLineItems: { | ||
type: "integer", | ||
label: "Number of Line Items", | ||
description: "The number of line items to enter", | ||
reloadProps: true, | ||
}, | ||
}, | ||
async additionalProps() { | ||
const props = {}; | ||
if (!this.numLineItems) { | ||
return props; | ||
} | ||
for (let i = 1; i <= this.numLineItems; i++) { | ||
props[`line_${i}_productId`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Product ID`, | ||
options: async ({ page }) => { | ||
const { Items: products } = await this.unleashedSoftware.listProducts({ | ||
page: page + 1, | ||
}); | ||
return products?.map(({ | ||
Guid: value, ProductDescription: label, | ||
}) => ({ | ||
value, | ||
label, | ||
})) || []; | ||
}, | ||
}; | ||
props[`line_${i}_quantity`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Quantity`, | ||
}; | ||
props[`line_${i}_unitPrice`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Unit Price`, | ||
}; | ||
} | ||
return props; | ||
}, | ||
async run({ $ }) { | ||
const lineItems = []; | ||
let subtotal = 0, taxTotal = 0; | ||
const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ | ||
$, | ||
taxCode: this.taxCode, | ||
}); | ||
|
||
for (let i = 1; i <= this.numLineItems; i++) { | ||
const lineTotal = +this[`line_${i}_unitPrice`] * +this[`line_${i}_quantity`]; | ||
const lineTax = lineTotal * (taxRate / 100); | ||
lineItems.push({ | ||
Product: { | ||
Guid: this[`line_${i}_productId`], | ||
}, | ||
OrderQuantity: +this[`line_${i}_quantity`], | ||
UnitPrice: +this[`line_${i}_unitPrice`], | ||
LineTotal: lineTotal, | ||
LineTax: lineTax, | ||
LineNumber: i, | ||
}); | ||
subtotal += lineTotal; | ||
taxTotal += lineTax; | ||
} | ||
const response = await this.unleashedSoftware.createPurchaseOrder({ | ||
$, | ||
data: { | ||
Supplier: { | ||
Guid: this.supplierId, | ||
}, | ||
ExchangeRate: +this.exchangeRate, | ||
OrderStatus: this.orderStatus, | ||
Warehouse: { | ||
Guid: this.warehouseId, | ||
}, | ||
Comments: this.comments, | ||
Subtotal: subtotal, | ||
Tax: { | ||
TaxCode: this.taxCode, | ||
}, | ||
TaxRate: taxRate, | ||
TaxTotal: taxTotal, | ||
Total: subtotal + taxTotal, | ||
PurchaseOrderLines: lineItems, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully created purchase order"); | ||
return response; | ||
}, | ||
}; |
141 changes: 141 additions & 0 deletions
141
components/unleashed_software/actions/create-sales-order/create-sales-order.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import unleashedSoftware from "../../unleashed_software.app.mjs"; | ||
|
||
export default { | ||
key: "unleashed_software-create-sales-order", | ||
name: "Create Sales Order", | ||
description: "Creates a new sales order. [See the documentation](https://apidocs.unleashedsoftware.com/SalesOrders)", | ||
version: "0.0.1", | ||
type: "action", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: false, | ||
}, | ||
props: { | ||
unleashedSoftware, | ||
customerId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"customerId", | ||
], | ||
}, | ||
exchangeRate: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"exchangeRate", | ||
], | ||
}, | ||
orderStatus: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"salesOrderStatus", | ||
], | ||
}, | ||
warehouseId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"warehouseId", | ||
], | ||
}, | ||
taxCode: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"taxCode", | ||
], | ||
}, | ||
comments: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"comments", | ||
], | ||
}, | ||
numLineItems: { | ||
type: "integer", | ||
label: "Number of Line Items", | ||
description: "The number of line items to enter", | ||
reloadProps: true, | ||
}, | ||
}, | ||
async additionalProps() { | ||
const props = {}; | ||
if (!this.numLineItems) { | ||
return props; | ||
} | ||
for (let i = 1; i <= this.numLineItems; i++) { | ||
props[`line_${i}_productId`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Product ID`, | ||
options: async ({ page }) => { | ||
const { Items: products } = await this.unleashedSoftware.listProducts({ | ||
page: page + 1, | ||
}); | ||
return products?.map(({ | ||
Guid: value, ProductDescription: label, | ||
}) => ({ | ||
value, | ||
label, | ||
})) || []; | ||
}, | ||
}; | ||
props[`line_${i}_quantity`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Quantity`, | ||
}; | ||
props[`line_${i}_unitPrice`] = { | ||
type: "string", | ||
label: `Line Item ${i} - Unit Price`, | ||
}; | ||
} | ||
return props; | ||
}, | ||
async run({ $ }) { | ||
const lineItems = []; | ||
let subtotal = 0, taxTotal = 0; | ||
const taxRate = await this.unleashedSoftware.getTaxRateFromCode({ | ||
$, | ||
taxCode: this.taxCode, | ||
}); | ||
|
||
for (let i = 1; i <= this.numLineItems; i++) { | ||
const lineTotal = +this[`line_${i}_unitPrice`] * +this[`line_${i}_quantity`]; | ||
const lineTax = lineTotal * (taxRate / 100); | ||
lineItems.push({ | ||
Product: { | ||
Guid: this[`line_${i}_productId`], | ||
}, | ||
OrderQuantity: +this[`line_${i}_quantity`], | ||
UnitPrice: +this[`line_${i}_unitPrice`], | ||
LineTotal: lineTotal, | ||
LineTax: lineTax, | ||
LineNumber: i, | ||
}); | ||
subtotal += lineTotal; | ||
taxTotal += lineTax; | ||
} | ||
const response = await this.unleashedSoftware.createSalesOrder({ | ||
$, | ||
data: { | ||
Customer: { | ||
Guid: this.customerId, | ||
}, | ||
ExchangeRate: +this.exchangeRate, | ||
OrderStatus: this.orderStatus, | ||
Warehouse: { | ||
Guid: this.warehouseId, | ||
}, | ||
Comments: this.comments, | ||
Subtotal: subtotal, | ||
Tax: { | ||
TaxCode: this.taxCode, | ||
}, | ||
TaxRate: taxRate, | ||
TaxTotal: taxTotal, | ||
Total: subtotal + taxTotal, | ||
SalesOrderLines: lineItems, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully created sales order"); | ||
return response; | ||
}, | ||
}; |
72 changes: 72 additions & 0 deletions
72
components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import unleashedSoftware from "../../unleashed_software.app.mjs"; | ||
|
||
export default { | ||
key: "unleashed_software-create-stock-adjustment", | ||
name: "Create Stock Adjustment", | ||
description: "Create a stock adjustment. [See the documentation](https://apidocs.unleashedsoftware.com/StockAdjustments)", | ||
version: "0.0.1", | ||
type: "action", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: false, | ||
}, | ||
props: { | ||
unleashedSoftware, | ||
adjustmentReason: { | ||
type: "string", | ||
label: "Adjustment Reason", | ||
description: "The reason for the stock adjustment", | ||
options: [ | ||
"End of Season", | ||
"Samples", | ||
"Stolen", | ||
], | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
warehouseId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"warehouseId", | ||
], | ||
}, | ||
productId: { | ||
propDefinition: [ | ||
unleashedSoftware, | ||
"productId", | ||
], | ||
}, | ||
newQuantity: { | ||
type: "string", | ||
label: "New Quantity", | ||
description: "The new quantity of the product", | ||
}, | ||
newActualValue: { | ||
type: "string", | ||
label: "New Actual Value", | ||
description: "The new actual value of the product", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.unleashedSoftware.createStockAdjustment({ | ||
$, | ||
data: { | ||
AdjustmentReason: this.adjustmentReason, | ||
Warehouse: { | ||
Guid: this.warehouseId, | ||
}, | ||
StockAdjustmentLines: [ | ||
{ | ||
Product: { | ||
Guid: this.productId, | ||
}, | ||
NewQuantity: +this.newQuantity, | ||
NewActualValue: +this.newActualValue, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully created stock adjustment"); | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.