weltlink / django-quickbooks

Django Integration with Quickbooks
Mozilla Public License 2.0
37 stars 13 forks source link

queue_manager.py _get_connection function failing #18

Open mccluret opened 3 years ago

mccluret commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

Sorry your email got buried, i didnt have any time to understand the issue and reply. I will try to answer this tomorrowHowever can you post this on stack overflowSo more people can benefit from this

Sent from Yahoo Mail on Android

On Thu, Mar 18, 2021 at 5:33 PM, Tyler @.***> wrote:

@hassaanalansary One last confusion I have is how to build the model and to_qbd function for many. Example would be how you add many invoice lines. 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
    )

@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
    )```

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub, or unsubscribe.