Skip to content

Commit b0685c0

Browse files
Kolawole Michael Aladebrent-hoover
authored andcommitted
Cancel Order (#2022)
* Add presentational aspect for invoice * Add presentational view for invoice * Add state to the invoice view * Detail on invoices captured * Add roll over list capability * Add single invoice render * Add roll down list not quantity based * Add presentational aspect for invoice * Add presentational view for invoice * Add state to the invoice view * Detail on invoices captured * Add roll over list capability * Add single invoice render * Add roll down list not quantity based * Display unique items only * Add quantities to line items * Remove unnecessary parts of the view * Seperate components for roll up lists and line items * Add cancel capability * Clean up UI * Add item functions * Fix Sidebar Context (#1932) * Show Sidebar shipping in checkout * Set actionView after payment checkout step * Hide sidebar on entry to profile page * Remove Inventory subscription that is not in use (#1951) * Get package data by shopId as well as package name (#1949) * Add capture payments capability * Add refunds fields * Seperate concerns in invoice component * Clean up invoice code * Refactorline items * Updated i18n settings panel (#1947) * Updated i18n settings panel - added new package for i18n settings - converted to react - added currency list - added ability to save open state to SettingsCard to user preferences - added ability to pluck fields in form component to enable concise forms * Update currency lists in admin - Only show enabled currencies in dropdown - Do not sure updatedAt field * Added ability to toggle all on or all off for languages and currencies * Removed unused code * Updated colors for card toolbar * fix props to show correct attribute * fixes z-index issue on select container * fix language props * fix prop to show enabled languages only * Avalara Tax Compliance (#1870) * Save company object from Avalara API * Load `appVersion` from package,json at startup. Create global `getAppVersion` * create avaGet function to pass in extra header info. Add getTaxCodes function * Extend plugin to also provide tax codes * Add Test connection option in Avalara admin dashboard * Send taxCode along with cart/orders * Capture full tax detail in "taxes" field * Update Test Credentials to use companyCode API * Add input field for shipping tax code * Add provides: taxCodes API to taxcloud * add itemCode to cart/order payload * use item id as line number. Pass in correct productId * Pass in shipping as additional non-taxable (based on taxcode) item * allow avaPost/avaGet to be used asynchronously * Add setting to turn off tax calculation separately from disabling the module * Add the rest of the fields to the form (except validation countries) * Use correct UID and correct URL for getTaxCode * Add setup for address validation by country * Don't commit documents when commit is turned off. Eliminate unneeded functions * Eliminate async versions of avaGet/avaPost. These should never be called by external module * Add defaults for new configuration settings. Make shippingTaxCode required * Make get/post methods use timeout, do some logging. * Don't do address validation when package is disabled, even when addressvalidation is enabled * Enable addressValidation by default * Enable addressValidation by default * Fix date parameter * Merge. Fix conflicts. * Modify auth arg for test credentials setup * Extend timeout during test credentials call * Limit address validation country options to US and CA * Fix returned object for non-validated addresses * Log Avalara details to custom Avalogger * Set new defaults * Add tax settings to account profile page * Update account find for taxsettings to subscribe * Only log if logging is enabled * Write out Avalara requests to Logs collection via Bunyan logger * Add log retention duration setting * Add jobs to cleanup logs older than configured setting * Add logs subscription that totally doesn't work * Add logs publication * Get logs and pass into Template * Add Log-specific wrapper for Griddle * Show individual log records in detail form * Refine grid and detail results * Populate entity codes and plug into taxCalc * Use new field names confirmed by AvaTax * Add taxSettings to recordOrder * Update entity code field key * removed excess panel wrapper around griddle table * Add translations * Show tax settings only if avalara enabled * Fix import order. * Setup error handling on Avalara methods * Add dimensions/tax code to PDP (#1931) * Edit product's schema file to include product dimensions * Add product dimensions in variant form * Edit product's schema and product admin form to include country of origin * Edit product's schema and product admin form to include tax description * Edit product's schema and product variant form to include origin country (yet to pre-populate from product's origin country) * Edit variant form to include list of tax codes * Refactor listTaxCodes method * Refactor listTaxCodes method to use template state instead of sessions * Refactor listTaxCodes method to use template state instead of sessions - template state now works * Edit taxCodes schema to include more descriptive fields * Include server method to save tax codes to TaxCodes collection * (First attempt) saving taxcodes to database * Successfully fetching taxcodes from database * Add error block in fetching from db method * change value of taxcode being saved in product details * Adding select2 package * Using select2 to display tax codes in nicer looking select box * Correcting import order * Editing required fields in product schema * Using plain select field to display tax codes * Remove tax code label; add select2 call in onRendered function instead of onCreated * Displaying default tax code as selected in select box * Removing unused meteor package; correcting import order * Throwing more descriptive meteor error on insertTaxCodes method * Display simple input box if tax provider is not enabled * Correct the way we test for validation on address2 * Remove extra panel divs * Add account ID to account management screen * Adjust log details for when there is no document type * Rename files to match style guide * Use individual taxSettings form each account * Add check to prevent populating duplicates * Fix reference to accountschema * Fix form update to corresponding accounts * Add unique tax setting by customer to Avalara payload * Fix exception error on geoCoder call * Only pass in regions when it's a "country with regions" * Revert "Only pass in regions when it's a "country with regions"" This reverts commit b809085. * Create a refundReference which is cartId + date * Ignore line items are not marked taxable * Move taxDescription down to the variant level and pass if exists * Move tax settings form into manage sidebar * Fix tax settings saving bug * Renamed files to fit style guide * Don't allow a wide-open Account publication * Remove unnecessary subscription * Don't call API if entity codes is already populated * Simplify logic for returning no results * Don't select a tax rate but a tax code * Rename function * Properly set Avalara countryList defaultValues * Eliminate extra slash * Eliminate all extra slashes * Check to ensure data is returned from API * Also log errors in Avalogger. Correctly filter for taxable items. * Require shopId * linting fixes * Add label to plain select. Rename method * JSDoc linting * Remove unused import * Remove unused import * Linting * Check configuration and throw meaningful errors if not configured properly * Add level to log so we can filter for errors * Tweak HTML and styling in settings panel * Fix i18n and timeout on testCredential * Log error with error log level * Moving select2 under community packages * Adding error checks to taxcodes method * Skip config check when testing credentials * Trigger form validation before testcredentials * Use native methods for assign and each * Handle error on populating Avalara entity codes * Add i18n for custom label * Move i18n entry to appropriate module * Move exemption settings into avalara module * Implement i18n for missing fields in PDP * Fix CircleCI failed tests * Fix CircleCI failed tests * Revert "Fix CircleCI failed tests" This reverts commit 3b238a8. * Revert "Fix CircleCI failed tests" This reverts commit 66f0f78. * Removing empty selector per CR * Use import rather than fs to get package.json * Change per CR * Restructure Class syntax per CR * Put back "Custom Packages" header * Add TODO * Changing default timeout to 3000 ms * Correct error name and make error message more specific * - updated Accounts publication name - Update Accounts.single to UserAccount * Fix: Dashboard panel keeps re-opening during checkout (#1956) * Show sidebar only if shipping is not configured * Refactor: Show sidebar only if shipping is not configured * Fix to show sidebar only if payment is not configured * localize prices in emails (#1957) * add GetShopCurrency helper * update cart currency when user changes currency * update schema to include currency in cart / order * add userCurrency and exchangeRate to carts orders * update email templates to display formatted price * update user emails to use user currency * Use select box of countries rather than text field for "Origin Country" (#1967) * Fix 404 when adding handle and then editing a variant before publishing. * Fixed misspelling in comment * Remove z-index from dropdown as it creates more issues than it solves * Moved ColumnData component to its own file. (#1972) * Prevent hiding of nested tags on mobile (#1971) * Show Sidebar shipping in checkout * Set actionView after payment checkout step * Add presentational aspect for invoice * Add presentational aspect for invoice * Add presentational view for invoice * Add presentational view for invoice * Add state to the invoice view * Add state to the invoice view * Detail on invoices captured * Detail on invoices captured * Add roll over list capability * Add roll over list capability * Add single invoice render * Add single invoice render * Add roll down list not quantity based * Display unique items only * Add quantities to line items * Remove unnecessary parts of the view * Seperate components for roll up lists and line items * Add cancel capability * Clean up UI * Add item functions * Add capture payments capability * Add refunds fields * Seperate concerns in invoice component * Clean up invoice code * Refactorline items * Add data into individual line items * linting and minor error fixes (#1973) * remove extra unneeded check for userId This was causing the Logger error we were seeing * update import order * change way of calling userId * fixed Shops.findOne * updated variable name * removed html error code from meteor error * cart.billing should now be defined to include currency * setting default currency if shop.currency is unavailable * update client to match server * lint fixes * Avalara error handling (#1968) * Taxcloud doesn't really support getTaxCodes yet * Ok, calm down * Taxcloud doesn't really provide taxCodes yet * Log Tax code errors to Logs collection rather than throwing a Meteor.Error * Add missing import * Use name from namespaced provides rather than name * Pulling tax codes from TaxCloud * Configure saving taxcloud taxes to db and displaying them * Move around UI components * Move around UI components * Add total price of line items * Format pricing to have dollar signs * Finalize on tax data * add cancel meteor method for orders * Iterate on design * Review tax display * finish up allowing an admin cancel an order * add cancel order workflow * add test for orders * add test for start and complete cancel order methods * finish up on cancel order * remove swal from shippingInvoice file * solve linting issues * fix linting issues in orders test * fix template issues in shippingInvoice html * create multi-action button * refactor code based on reviews * update shippingInvoice.js * remove unwanted newlines in changed files * fix eslint errors * fix multi-action button * refactor code based on reviews * refactor buttonSelect * fix test * fix indentation issues * fix indentation issues * update code based on review * update code based on reviews * fix cancel order test * fix bugs * add i18nKeyLabel to multi-function button * turn multi-function dropdown item to button * refactor button props fr multi-function button * fix paypal express refund method * add payment provider payment methods * fix payment provider refund issues * complete test for cancel order methods * remove inline style from translation * add error handling for failing refunds * remove unneccessary lines of code * add error handling * fix issue based on reviews * remove shipment panel when order has been canceled * remove newline
1 parent 67c2eb5 commit b0685c0

File tree

59 files changed

+1071
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1071
-80
lines changed

imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ Object.assign(Alerts, {
6868
...titleOrOptions
6969
}).then((isConfirm) => {
7070
if (isConfirm === true && typeof messageOrCallback === "function") {
71-
messageOrCallback(isConfirm);
71+
messageOrCallback(isConfirm, false);
72+
}
73+
}, dismiss => {
74+
if (dismiss === "cancel" || dismiss === "esc" || dismiss === "overlay") {
75+
messageOrCallback(false, dismiss);
7276
}
7377
}).catch(function (err) {
7478
if (err === "cancel" || err === "overlay" || err === "timer") {

imports/plugins/core/orders/client/components/invoice.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,3 @@ class Invoice extends Component {
149149
}
150150

151151
export default Invoice;
152-

imports/plugins/core/orders/client/components/lineItems.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { formatPriceString } from "/client/api";
33
import { Translation } from "/imports/plugins/core/ui/client/components";
44

55
class LineItems extends Component {
6+
67
static propTypes = {
78
displayMedia: PropTypes.func,
89
handleClick: PropTypes.func,

imports/plugins/core/orders/client/components/orderSummary.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ class OrderSummary extends Component {
2525
<div className="roll-up-invoice-list">
2626
<div className="roll-up-content">
2727
<div style={{ marginBottom: 4 }}>
28-
{shipmentStatus().status === "success" ?
29-
<span className="badge badge-success">{shipmentStatus().label}</span> :
30-
<span className="badge badge-info">{shipmentStatus().label}</span>
31-
}
28+
<span className={`badge badge-${shipmentStatus().status}`}>{shipmentStatus().label}</span>
3229
</div>
3330

3431
<div className="order-summary-form-group">

imports/plugins/core/orders/client/components/totalActions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component, PropTypes } from "react";
22
import { formatPriceString } from "/client/api";
33

44
class TotalActions extends Component {
5+
56
static propTypes = {
67
adjustedTotal: PropTypes.number,
78
invoice: PropTypes.object,

imports/plugins/core/orders/client/containers/lineItemsContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class LineItemsContainer extends Component {
1717
this.state = {
1818
isClosed: false
1919
};
20+
2021
this.handleClick = this.handleClick.bind(this);
2122
this.isExpanded = this.isExpanded.bind(this);
2223
this.handleClose = this.handleClose.bind(this);

imports/plugins/core/orders/client/containers/orderSummaryContainer.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ class OrderSummaryContainer extends Component {
5555
}
5656
});
5757

58+
const canceled = _.every(shipment.items, (shipmentItem) => {
59+
for (const fullItem of order.items) {
60+
if (fullItem._id === shipmentItem._id) {
61+
if (fullItem.workflow) {
62+
return fullItem.workflow.status === "coreOrderItemWorkflow/canceled";
63+
}
64+
}
65+
}
66+
});
67+
5868
if (shipped) {
5969
return {
6070
delivered: false,
@@ -64,6 +74,15 @@ class OrderSummaryContainer extends Component {
6474
};
6575
}
6676

77+
if (canceled) {
78+
return {
79+
delivered: false,
80+
shipped: false,
81+
status: "danger",
82+
label: i18next.t("order.canceledLabel")
83+
};
84+
}
85+
6786
return {
6887
delivered: false,
6988
shipped: false,

imports/plugins/core/orders/client/containers/totalActionsContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import TotalActions from "../components/totalActions";
44
import { Loading } from "/imports/plugins/core/ui/client/components";
55

66
class TotalActionsContaner extends Component {
7+
78
static propTypes = {
89
adjustedTotal: PropTypes.number,
910
invoice: PropTypes.object,

imports/plugins/core/orders/client/templates/orders.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ const OrderHelper = {
4242
// Orders that are complete, including all items with complete status
4343
case "completed":
4444
query = {
45-
"workflow.status": "coreOrderWorkflow/completed",
46-
"items.workflow.workflow": {
47-
$in: ["coreOrderItemWorkflow/completed"]
45+
"workflow.status": {
46+
$in: ["coreOrderWorkflow/completed", "coreOrderWorkflow/canceled"]
47+
},
48+
"items.workflow.status": {
49+
$in: ["coreOrderItemWorkflow/completed", "coreOrderItemWorkflow/canceled"]
4850
}
4951
};
5052
break;
@@ -59,7 +61,7 @@ const OrderHelper = {
5961

6062
case "canceled":
6163
query = {
62-
"workflow.status": "canceled"
64+
"workflow.status": "coreOrderWorkflow/canceled"
6365
};
6466
break;
6567

@@ -326,6 +328,16 @@ Template.orderStatusDetail.helpers({
326328
}
327329
});
328330

331+
const canceled = _.every(shipment.items, (shipmentItem) => {
332+
for (const fullItem of self.items) {
333+
if (fullItem._id === shipmentItem._id) {
334+
if (fullItem.workflow) {
335+
return fullItem.workflow.status === "coreOrderItemWorkflow/canceled";
336+
}
337+
}
338+
}
339+
});
340+
329341
if (shipped) {
330342
return {
331343
delivered: false,
@@ -335,6 +347,15 @@ Template.orderStatusDetail.helpers({
335347
};
336348
}
337349

350+
if (canceled) {
351+
return {
352+
delivered: false,
353+
shipped: false,
354+
status: "danger",
355+
label: i18next.t("order.canceledLabel")
356+
};
357+
}
358+
338359
return {
339360
delivered: false,
340361
shipped: false,

imports/plugins/core/orders/client/templates/workflow/shippingInvoice.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,27 @@
3838
</button>
3939
</div>
4040
{{/if}}
41+
{{#if showAfterPaymentCaptured}}
42+
<button
43+
class="btn btn-danger"
44+
type="button"
45+
data-event-action="cancelOrder"
46+
style="margin-bottom: 10px"
47+
data-i18n="order.cancelOrderLabel"
48+
>
49+
Cancel Order
50+
</button>
51+
{{/if}}
52+
<div class="alert alert-danger hidden">Oh! Snap</div>
4153
</div>
4254

4355

4456

45-
<div class="flex">
57+
<div class="flex" style="margin-bottom: 15px;">
4658
{{#if paymentPendingApproval}}
47-
<button class="btn btn-info btn-block" type="submit" data-event-action="approveInvoice" data-i18n="order.approveInvoice">Approve</button>
59+
<div class="btn-block">
60+
{{> React buttonSelectComponent}}
61+
</div>
4862
{{/if}}
4963

5064
{{#if paymentApproved}}

0 commit comments

Comments
 (0)