-
Notifications
You must be signed in to change notification settings - Fork 194
Order lookup #1354
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
Order lookup #1354
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a61b4be
#1340 add order lookup
ATGE 2734635
update from origin
ATGE c9b3874
#1340 add order lookup doc
ATGE e75b027
Capitalizing State and Items rows names for order detail table in loo…
ATGE afb20da
mentioning slcli order lookup in account orders doc block. #1340
ATGE 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
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
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
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,67 @@ | ||
| """Provides some details related to the order.""" | ||
| # :license: MIT, see LICENSE for more details. | ||
|
|
||
| import click | ||
|
|
||
| from SoftLayer.CLI.account.invoice_detail import get_invoice_table | ||
|
|
||
| from SoftLayer.CLI import environment | ||
| from SoftLayer.CLI import formatting | ||
| from SoftLayer.managers import ordering | ||
| from SoftLayer import utils | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument('identifier') | ||
| @click.option('--details', is_flag=True, default=False, show_default=True, | ||
| help="Shows a very detailed list of charges") | ||
| @environment.pass_env | ||
| def cli(env, identifier, details): | ||
| """Provides some details related to order owner, date order, cost information, initial invoice.""" | ||
|
|
||
| manager = ordering.OrderingManager(env.client) | ||
| order = manager.get_order_detail(identifier) | ||
| order_table = get_order_table(order) | ||
|
|
||
| invoice = order.get('initialInvoice', {}) | ||
| top_items = invoice.get('invoiceTopLevelItems', []) | ||
| invoice_id = invoice.get('id') | ||
| invoice_table = get_invoice_table(invoice_id, top_items, details) | ||
|
|
||
| order_table.add_row(['Initial Invoice', invoice_table]) | ||
|
|
||
| env.fout(order_table) | ||
|
|
||
|
|
||
| def get_order_table(order): | ||
| """Formats a table for billing order""" | ||
|
|
||
| title = "Order {id}".format(id=order.get('id')) | ||
| date_format = '%Y-%m-%d' | ||
| table = formatting.Table(["Key", "Value"], title=title) | ||
| table.align = 'l' | ||
|
|
||
| ordered_by = "IBM" | ||
| user = order.get('userRecord', None) | ||
| if user: | ||
| ordered_by = "{} ({})".format(user.get('displayName'), utils.lookup(user, 'userStatus', 'name')) | ||
| table.add_row(['Ordered By', ordered_by]) | ||
|
|
||
| table.add_row(['Create Date', utils.clean_time(order.get('createDate'), date_format, date_format)]) | ||
| table.add_row(['Modify Date', utils.clean_time(order.get('modifyDate'), date_format, date_format)]) | ||
| table.add_row(['Order Approval Date', utils.clean_time(order.get('orderApprovalDate'), date_format, date_format)]) | ||
| table.add_row(['Status', order.get('status')]) | ||
| table.add_row(['Order Total Amount', "{price:.2f}".format(price=float(order.get('orderTotalAmount', '0')))]) | ||
| table.add_row(['Invoice Total Amount', "{price:.2f}". | ||
| format(price=float(order.get('initialInvoice', {}).get('invoiceTotalAmount', '0')))]) | ||
|
|
||
| items = order.get('items', []) | ||
| item_table = formatting.Table(["Item Description"]) | ||
| item_table.align['description'] = 'l' | ||
|
|
||
| for item in items: | ||
| item_table.add_row([item.get('description')]) | ||
|
|
||
| table.add_row(['Items', item_table]) | ||
|
|
||
| return table | ||
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
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
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
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
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
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
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.