Skip to content
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

queue_manager.py _get_connection function failing #18

Open
mccluret opened this issue Mar 3, 2021 · 10 comments
Open

queue_manager.py _get_connection function failing #18

mccluret opened this issue Mar 3, 2021 · 10 comments

Comments

@mccluret
Copy link

mccluret commented Mar 3, 2021

When BlockingConnection is being called it is basically just timing out.
Is there additional setup that is not documented? I get that there is a link to formal documentation.
So is there more to what I need in order to get this working?

@hassaanalansary
Copy link
Collaborator

I am rusty on how rabbitMQ works, you can use redis which is much easier to use AND reliable
let me know if you want any help setting it up with django_quickbooks
if you want to use RabbitMQ for some reason, please share with us the code snippet and the exception you get.

@mccluret
Copy link
Author

mccluret commented Mar 3, 2021

@hassaanalansary ohh okay, I just noticed that the queue_manager.py in django-quickbooks was using RabbitMQ, this is where I am currently stuck. Will switch to Celery/Redis and try to reimplement QueueManager.

Also, I am new to message queues, etc so if you wouldn't mind helping (and I don't mind paying for your time either if you want to hop on a zoom call) that would be awesome :)

Also, once I learn this project I can contribute several other QB objects like Sales Orders, etc. and help any way I can.

@mccluret
Copy link
Author

mccluret commented Mar 3, 2021

I have Redis and Celery setup/installed in my Django project. I am having a hard time understanding what the publish_message() function now needs to be.

    @shared_task()
    def publish_message(self, msg, queue_name, delete_queue=False):
        return msg

@hassaanalansary
Copy link
Collaborator

Thanks for your enthusiasm, your help is highly appreciated

You don't have to implement redis yourself, @bedilbek has done all the hard work and it is working out of the box.
Copy these to your settings.py and you should be good to go.
check the inline comments

QBWC_SETTINGS = {
    'QUEUE_MANAGER_CLASS': 'django_quickbooks.queue_manager.RedisManager',
    'REDIS_DEFAULT_HOST': 'localhost',
    'REDIS_DEFAULT_PORT': 6379,
    'REDIS_DEFAULT_DB': 0,
    'REDIS_DEFAULT_PASSWORD': None,
}

you can additionally add these to the same dict. It is not related to the issue, but I think it will be useful

Objects that have POS in their name are present only in my fork, as I use this repo for QBPOS not QBFS

    'APP_URL': 'YOUR_URL_ENDPOINT', # i.e. YOUR_DOMAIN/qwc/quickbooks-desktop/
    'APP_SUPPORT': 'YOUR_SUPPORT_URL_ENDPOINT' # i.e. YOUR_DOMAIN/qwc/quickbooks-desktop/support/,
    'APP_ID': '',
    'APP_NAME': 'YOUR_APP_NAME',
    'APP_DESCRIPTION': "YOUR_APP_DESCRIPTION",
    'OWNER_ID': 'GENERATE YOUR UUID',
    'LOCAL_MODEL_CLASSES': {
    # This is a pointing to my Customer Model in my app, replace with your own
        'Invoice': '',
        'Customer': '',
        'CustomerPOS': 'Inventory.models.Customer',  
        'ItemInventoryPOS': 'Inventory.models.Level7',
        'VoucherPOS': 'Inventory.models.OrderVoucher',
        'VendorPOS': 'Inventory.models.QBVendor',
        'SalesReceiptPOS': 'Inventory.models.OrderReceipt',
    },
    # if you want to handle Responses in some custom way you can inherit from the ResponseProcessor and point to it in this tuple
    'RESPONSE_PROCESSORS': (), 
    # same as above but this is for POS (only in my fork)
    'POS_RESPONSE_PROCESSORS': (
        'Inventory.qbd.ItemInventoryResponseProcessor',
        'Inventory.qbd.Level7AddResponseProcessor',
        'django_quickbooks.processors.VoucherQueryResponseProcessor',
        'django_quickbooks.processors.VoucherAddResponseProcessor',
        'django_quickbooks.processors.VendorQueryResponseProcessor',
        'django_quickbooks.processors.VendorAddResponseProcessor',
        'django_quickbooks.processors.CustomerQueryResponseProcessor',
        'django_quickbooks.processors.CustomerModResponseProcessor',
        'django_quickbooks.processors.CustomerAddResponseProcessor',
        'django_quickbooks.processors.SalesReceiptQueryResponseProcessor',
        'Inventory.qbd.SalesReceiptResponseProcessor',
    ),
    'TASKS_PER_REQUEST_LIMIT': 200, #only in my fork

If you are still having difficulties getting it to run we, lets have a talk later today
It would be great to have you as a contributor

@bill-ash
Copy link

bill-ash commented Mar 5, 2021

@hassaanalansary If you're offering I'd love to take you up on a call. I've implemented an API client in R that connects via ODBC that I'd like to port. I have a working django app and am syncing customers using the admin module but am having trouble mapping fields.

@mccluret
Copy link
Author

mccluret commented Mar 6, 2021

@hassaanalansary Ahhh I pip installed and it looks like RedisManager in queue_manager.py isn't there on pypi.
Thank you for the input, will test more today.

If you would be interested in a paid call that would be great, I'll make availability at your convenience. A quick review, some general architectural questions for adding/contributing, creating my own response processor, etc.

Please advise!

PS: I did get it working for adding a customer so thanks a lot for the help. I will be adding sales orders and I think a call would paint a better picture and allow me to contribute meaningfully.

@hassaanalansary
Copy link
Collaborator

@mccluret I am glad you were able to add customers.
@mccluret @bill-ash I'd be happy to talk to you both, we can try tomorrow between 11EST - 1EST send me a meeting invitation on hassaanalansary@yahoo.com .

@mccluret
Copy link
Author

mccluret commented Mar 6, 2021

@hassaanalansary Awesome, just sent you one for 11am tomorrow.

@bill-ash If you want to hop on the same call you can, send me your email and I'll send you the zoom invite.

@mccluret
Copy link
Author

mccluret commented Mar 18, 2021

@hassaanalansary One last confusion I have is how to build the model and to_qbd function for many. Example is I need to add many SalesOrderLines

class SalesOrderLineAdd(models.Model):
    list_id = models.CharField(max_length=255, null=True)
    full_name = models.CharField(max_length=255, null=True)
    rate = models.FloatField(null=True)
    desc = models.CharField(max_length=255, null=True)
    quantity = models.IntegerField(max_length=255, null=True)
    item_ref_list_id = models.CharField(max_length=255, null=True)
    item_ref_full_name = models.CharField(max_length=255, null=True)


class SalesOrder(QBDModelMixin):
    customer_ref_list_id = models.CharField(max_length=255, null=True)
    customer_ref_full_name = models.CharField(max_length=255, null=True)
    template_ref_list_id = models.CharField(max_length=255, null=True)
    template_ref_full_name = models.CharField(max_length=255, null=True)
    sales_order_line_add = models.ForeignKey(SalesOrderLineAdd, on_delete=models.CASCADE)

    def to_qbd_obj(self, **fields):
        from django_quickbooks.objects import SalesOrder as QBSalesOrder
        # map your fields to the qbd_obj fields
        return QBSalesOrder(
            # todo map fields to qbd obj
            SalesOrderLineAdd=(??????)
            CustomerRef=(ListID=qbd_obj.customer_ref_list_id, FullName=qbd_obj.customer_ref_full_name)
        )

    @classmethod
    def from_qbd_obj(cls, qbd_obj):
        # map qbd_obj fields to your model fields
        return cls(
            # todo map fields from
            qbd_object_id=qbd_obj.ListID,
            qbd_object_version=qbd_obj.EditSequence
        )

@hassaanalansary
Copy link
Collaborator

hassaanalansary commented Mar 23, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants