CRM: Resolves #3303 - handle invoice status dropdown mismatches#32909
CRM: Resolves #3303 - handle invoice status dropdown mismatches#32909
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 (other than "Required review") appearing at the bottom of this PR are passing or skipped. Crm plugin:
|
| if ( in_array( $order_status, $paid_statuses, true ) ) { | ||
| $status = __( 'Paid', 'zero-bs-crm' ); | ||
| $status = 'Paid'; | ||
| } elseif ( $order_status === 'checkout-draft' ) { | ||
| $status = __( 'Draft', 'zero-bs-crm' ); | ||
| $status = 'Draft'; | ||
| } else { | ||
| $status = __( 'Unpaid', 'zero-bs-crm' ); | ||
| $status = 'Unpaid'; | ||
| } |
There was a problem hiding this comment.
Don't we need to add some kind of migration to be backwards compatible?
There was a problem hiding this comment.
We have this problem throughout the whole codebase.
E.g.:
includes/ZeroBSCRM.DAL3.Helpers.php
// retrieves statuses from object :)
function zeroBSCRM_getInvoicesStatuses(){
// for DAL3+ these are hard typed, probably need to sit in the obj:
return array(
__( 'Draft', 'zero-bs-crm' ),
__( 'Unpaid', 'zero-bs-crm' ),
__( 'Paid', 'zero-bs-crm' ),
__( 'Overdue', 'zero-bs-crm' ),
__( 'Deleted', 'zero-bs-crm' )
);
}
There was a problem hiding this comment.
Don't we need to add some kind of migration to be backwards-compatible?
I mentioned this briefly above; to my knowledge, only WooSync had this bug. A migration gets messy because we have know way of knowing if:
- The user has changed languages since, or
- The value in the database is not something they manually added.
Since there's an easy workaround (Woo resync), I think avoiding a migration is best until we actually move to some real key-based status setup.
There was a problem hiding this comment.
We have this problem throughout the whole codebase.
Indeed, my goal here was primarily to address the specific Woo situation, and to make output more i18n-friendly. But I'll poke around and see if there are other cases we can clean things up.
There was a problem hiding this comment.
Fixed code block that was meant to set an invoice to "Unpaid" if it was "Draft" and emailed to a user: 56380a3
Because 'Draft' !== __( 'Draft', 'zero-bs-crm' ) if the status has translations, the condition was never met previously.
There was a problem hiding this comment.
Fixed invoice bulk action status change which hasn't worked previously on non-English installs: ab85f34
There was a problem hiding this comment.
WooSync status mapping was previously using translated status, but now correctly uses the English status with translated output: 6ebf0c0
|
@gogdzl I've widened the scope of this PR to cover all invoice statuses I could find, and I think they're all properly handled (along with some bug fixes that have existed since who knows when). |
5c2b7b2 to
e7c36dc
Compare
|
Rebased, as this has been sitting some time... |
gogdzl
left a comment
There was a problem hiding this comment.
It works and it is a solid move towards fixing our statuses issues with translation.
Great job!
|
Thanks, @cleacos! I have notes from our call as well and will look into this today to see if it's something we can/should address. |
|
Handled in #33254. |


Resolves Automattic/zero-bs-crm#3303 - handle invoice status dropdown mismatches
Proposed changes:
If the invoice status in the database doesn't match an available status, the edit page dropdown defaults to the first item on the list, making it appear to be selected.
Quotes don't have real statuses, and contact statuses are not translated. This was already solved for transactions (#30644), but we need to the same for invoices.
This PR does the following:
status_labelkey that can be used to output the translated status (e.g. listviews, edit page, client portal, and contact/company profiles).The larger issue involves the fact that we store labels instead of keys in the database (#1497), which hopefully will be addressed at a future date. This PR begins to lay the groundwork for invoice status keys, though the "key" stored in the database is just the English name for the status at this stage.
Note also that this won't fix any existing errant saves in the database. We haven't had any complaints on this to date, but if it comes up after this is released, the easiest fix is to do a full Woo resync.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
In
trunk:Borrador), whereas it just wasn't able to find a match, so the dropdown defaults to the first item.In the
fix/crm/3303-fix_invoice_status_dropdown_mismatchesbranch: