Comments

trigdog created an issue. See original summary.

trigdog’s picture

Status: Active » Needs review
StatusFileSize
new3.28 KB
heddn’s picture

Thanks for all your hard work here. Just a few questions.

  1. +++ b/src/Form/QuickbooksAdminForm.php
    @@ -98,6 +98,19 @@ class QuickbooksAdminForm extends ConfigFormBase {
    +        '#maxlength' => 64,
    

    Is 64 chars the limit in QB?

  2. +++ b/src/SoapBundle/Services/SoapService.php
    @@ -566,6 +566,21 @@ class SoapService implements SoapServiceInterface {
    +          $discountName = !empty($this->config->get('adjustments')['discount_service']) ? $this->config->get('adjustments')['discount_service'] : 'Discount';
    +          $line->setItemName($discountName);
    

    Can we not take the name/label from the adjustment to use for the description in QB? Why do we need to have a single discount for all line items? Please teach me what I don't know about quickbooks. Which I don't know that much :)

heddn’s picture

Status: Needs review » Needs work

And I'd like to see some tests added for adjustments. We have them already for shipping. So adding adjustments shouldn't be that hard. Settings to NW for that reason.

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new11.51 KB

Updated patch.

Status: Needs review » Needs work

The last submitted patch, 5: commerce_quickbooks_enterprise-discounts-2939636-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

trigdog’s picture

Status: Needs work » Needs review

Hmm, those strings that failed are the same.

Status: Needs review » Needs work

The last submitted patch, 5: commerce_quickbooks_enterprise-discounts-2939636-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new11.5 KB

Status: Needs review » Needs work

The last submitted patch, 9: commerce_quickbooks_enterprise-discounts-2939636-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

trigdog’s picture

Not sure, where this is failing...doesn't fail locally.

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new11.51 KB

Lets try this again.

heddn’s picture

Status: Needs review » Needs work
  1. +++ b/src/SoapBundle/Services/SoapService.php
    @@ -566,6 +566,25 @@ class SoapService implements SoapServiceInterface {
    +        $discountName = !empty($this->config->get('adjustments')['discount_service']) ? $this->config->get('adjustments')['discount_service'] : 'Discount';
    

    No need for this empty check. Either we bite the bullet and write a hook_update, or we just assume that the get will always return a value. With the number of adopters of the module (few) I'd suggest we forego a hook update. Since we are still in alpha, that is acceptable. Folks will just need to reinstall.

  2. +++ b/src/SoapBundle/Services/SoapService.php
    @@ -566,6 +566,25 @@ class SoapService implements SoapServiceInterface {
    +        $line->setAmount(number_format($item->getQuantity() * $adjustment->getAmount()->getNumber(), 2, '.', ''));
    

    We need to load the currency repository and see what fractal numbers are available for use. Not all currencies has 2 decimal points. See #2928178: Prices are not migrated correctly (deletes two digits)

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new11.55 KB

Thanks for the review. Been tied up but here is an updated patch. Sorry, I never noticed comment #3.

#3-1.

Is 64 chars the limit in QB?

No, I think item names are actually limited to 31 characters but I was actually think about writing a patch that split parent ref and item ref from a string if that is enabled in the admin config so lets just remove this restiction for now.

#3-2.

Why do we need to have a single discount for all line items?

We don't but it would be hard to map discounts to different discount items in QB on the fly. I had this required that way because if this is empty or doesn't match a current item in Quickbooks the import will fail. Maybe better to set the field as required? This would also be necessary for shipping as well. If the name for the shipping doesn't match an item in Quickbooks the import will fail.

#13-1. - Answered in #3-2

#13-2. Update in patch. Let me know if you would like me to do it differently.

Status: Needs review » Needs work

The last submitted patch, 14: commerce_qb_webconnect-discounts-2939636-14.patch, failed testing. View results

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new11.54 KB

Fixed coding standards problems.

heddn’s picture

StatusFileSize
new4.64 KB

Here's an interdiff.

heddn’s picture

  • +++ b/src/Form/QuickbooksAdminForm.php
    @@ -99,16 +99,15 @@
    +      '#required' => TRUE,
    

    I don't think we can mark this required. If it isn't provided, it will simply be empty string.

    </li>
    <li>+++ b/src/SoapBundle/Services/SoapService.php
    @@ -567,17 +567,19 @@
    +        $line->setAmount(number_format($item->getQuantity() * $adjustment->getAmount()->getNumber(), $currency->getFractionDigits()));
    

    There's Drupal\commerce_price\Calculator and NumberFormatterFactory that can do all this for you. For the number formatter, I think $formatter->format() is what you want to use.

heddn’s picture

Status: Needs review » Needs work
trigdog’s picture

I don't think we can mark this required. If it isn't provided, it will simply be empty string.

The only problem is, if left as an empty string, and the XML has an empty value for <ItemRef><fullName></fullName></ItemRef> the order will fail export with:

<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<InvoiceAddRs statusCode="3140" statusSeverity="Error" statusMessage="There is an invalid reference to QuickBooks Item &quot;&quot; in the Invoice line. " />
</QBXMLMsgsRs>
</QBXML>

If I do not set <ItemRef><fullName></fullName></ItemRef> if the string is empty so it is not included at all, then I get:

<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<InvoiceAddRs statusCode="3180" statusSeverity="Error" statusMessage="There was an error when saving a Invoice.  QuickBooks error message: You have no items or one or more of your amounts is not associated with an item. Please enter an item." />
</QBXMLMsgsRs>
</QBXML>

The same goes for shipping name.

There's Drupal\commerce_price\Calculator and NumberFormatterFactory that can do all this for you.

Great, I didn't know that. I will take a look and update patch.

trigdog’s picture

StatusFileSize
new162.91 KB

So I tried to do this directly in QuickBooks (leave a line item name empty) and it will not let you save the invoice with the same error. Line item names have to match an existing item in QuickBooks. See screenshot.

trigdog’s picture

Status: Needs work » Needs review
StatusFileSize
new12.02 KB

Lets just make this simpler and use the adjustedUnitPrice for order items. Removed #required for now and we can discuss that in a different issue.

heddn’s picture

I'm actually OK with marking something required if it is required. But it sounds like it is only optionally required, if discounts are provided. It looks like the states API let's us do that. See https://api.drupal.org/api/drupal/core!includes!common.inc/function/drup....

But let's do things iteratively.
Shall we set the limit to 31 per #3 and #14?

If we want to open up the follow-up for the required thing and put an TODO with the issue link, then I'm ok. But for the char limit, maybe we should address that here. Or open it up and do the same thing and add a TODO.

heddn’s picture

Status: Needs review » Needs work
heddn’s picture

Status: Needs work » Reviewed & tested by the community

I'm reversing direction here. We can fix more things later on. Let's get this merged.

  • heddn committed ea2b4dd on 8.x-2.x authored by trigdog
    Issue #2939636 by trigdog, heddn: Add Discount (promotion) as line item
    
heddn’s picture

Status: Reviewed & tested by the community » Fixed
trigdog’s picture

Sorry for the delay on this. I can work on this issue this afternoon.

The 31 char limit is for the full name of the item but the actual Quickbooks identifier uses the full name + the parent name (like you did on the product and product variation export). So if someone had a discount item they wanted to link that was under a parent (Discount Items:General Discount) they could go over the 31 character limit. Parent names do not have a limit.

In the case above we would have to handle splitting the parent name from the item name but that would be easy enough. Again this applies to the shipping name also.

I will open a new issue on this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.