-
Notifications
You must be signed in to change notification settings - Fork 798
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
CRM: Add WooSync status to avoid creating invoices and transactions #37276
CRM: Add WooSync status to avoid creating invoices and transactions #37276
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
// Add/update invoice (if enabled) (previously `add_or_update_invoice`) | ||
if ( $settings['wcinv'] == 1 ) { | ||
// Add/update invoice (if enabled) (previously `add_or_update_invoice`), while checking for a 'Do not create' status to avoid creating this invoice if the mapping doesn't allow it | ||
if ( $settings['wcinv'] == 1 && isset( $crm_object_data['invoice'] ) && isset( $crm_object_data['invoice']['status'] ) && $crm_object_data['invoice']['status'] !== WOOSYNC_DO_NOT_CREATE['id'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH is complaining about something here...
// If we ever have more WooSync constants we should create a separate php file. | ||
if ( ! defined( 'WOOSYNC_DO_NOT_CREATE' ) ) { | ||
define( | ||
'WOOSYNC_DO_NOT_CREATE', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this global definition I'd add the JPCRM_
prefix => JPCRM_WOOSYNC_DO_NOT_CREATE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works well for me. I'd add the JPCRM_
prefix to the WOOSYNC_DO_NOT_CREATE
definition => JPCRM_WOOSYNC_DO_NOT_CREATE
Other than that, LGTM!
As a side note, if an invoice is created because the order is different to Draft, if we set the order a Draft, the invoice/transaction doesn't change its status. For me that behavior is OK, once the invoice is created, you cannot go back automatically if the order is set as Draft later. But maybe I'd say that, if the invoice/transaction is already created and the new status should be Draft, we have to switch to that status. |
That is a known problem, we sync only existing transactions, if a transactions gets deleted we don't record that. |
// Add/update invoice (if enabled) (previously `add_or_update_invoice`) | ||
if ( $settings['wcinv'] == 1 ) { | ||
// Add/update invoice (if enabled) (previously `add_or_update_invoice`), while checking for a 'Do not create' status to avoid creating this invoice if the mapping doesn't allow it | ||
if ( $settings['wcinv'] == 1 && isset( $crm_object_data['invoice'] ) && isset( $crm_object_data['invoice']['status'] ) && $crm_object_data['invoice']['status'] !== JPCRM_WOOSYNC_DO_NOT_CREATE['id'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why GH is still complaining here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approved it...
A test is failing
I mean, the user creates an Order in a valid status, let's say completed. JPCRM will generate the invoice as paid, but the user takes that order and changes it to Draft; in JPCRM, the invoice status will not change to Draft, it will leave the invoice as Paid. But it's a side note about this edge case not covered by this PR, not a blocker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes https://github.com/Automattic/zero-bs-crm/issues/3463
Proposed changes:
Other information:
Jetpack product discussion
https://github.com/Automattic/zero-bs-crm/issues/3463
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Initial Setup and Verification of WooSync:
Verify WooSync Functionality:
Status: Sync Completed
.Enable Invoice Generation:
trunk
branch and activate the feature at/wp-admin/admin.php?page=zerobscrm-plugin-settings&tab=woosync
.Create a WooCommerce Order:
Verify Transaction and Invoice Creation:
Testing the New PR Setting:
Switch to the PR Branch:
update/crm/3463-woosync-avoid-creating-invoices-and-transactions-for-woo-draft
.Configure WooCommerce Settings:
/wp-admin/admin.php?page=zerobscrm-plugin-settings&tab=woosync
.Do not Create
.Add Another WooCommerce Order:
Do not Create
.Do not Create
.Documentantion changes
We will need to update our CRM Knowledge Base to reflect this change. It is necessary to update our WooSync page to inform users that we now offer a new setting and explain how it works.
Pinging @StefMattana