-
Notifications
You must be signed in to change notification settings - Fork 13
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
Is there an easy way to create an customer/invoice via this project? #38
Comments
Hello @Ryang20718 you need to create a This is a snippet pulled from my production code # Add something like this to your post_save signal.
QBDTask.objects.update_or_create(
qb_operation=QUICKBOOKS_ENUMS.OPP_MOD,
qb_resource=QUICKBOOKS_ENUMS.RESOURCE_CUSTOMER_POS,
object_id=instance.id,
content_type=ContentType.objects.get_for_model(instance),
realm_id=YOUR_REALM_ID,
) it should call you Something Extra QBWC_SETTINGS = {
"LOCAL_MODEL_CLASSES": {
"CustomerPOS": "Inventory.models.Customer",
"ItemInventoryPOS": "Inventory.models.Sku",
"VoucherPOS": "Inventory.models.OrderVoucher",
},
"RESPONSE_PROCESSORS": (),
"POS_RESPONSE_PROCESSORS": (
"Inventory.qbd.ItemInventoryResponseProcessor",
"Inventory.qbd.SkuAddResponseProcessor", # Custom one I made
"django_quickbooks.processors.VoucherQueryResponseProcessor", # Default one
),
}
notice that `POS_RESPONSE_PROCESSORS` are only in my fork because it supports QBPOS
you can use `RESPONSE_PROCESSORS` for QB Finance let me know if you find this helpful or if you need more help |
@hassaanalansary Really appreciate the help here! If you could provide some pointers on where to place the QBDTask in relationship to a class, I think that would clear up all my confusion! so I would need to create a class in order to leverage the customer/invoice classes i.e if I have this in my models.py
in my views.py, I can instantiate the object
However, based on your snippet above,
|
Instance is supposed to be |
so If I have the following and the following in
Assuming QuickBooks Desktop is Auth'd and connected to QBWC, if I were to invoke the app via |
Yes, however your code doesn't really create the customer in the database |
ah, I see I changed django_quickbooks to use redismanager rather than rabbit mq in the settings and have a redis server running. I think I'm getting closer to reaching the final step of creating a customer programatically ❗ However, parsing the XML response results in an exception when trying to dynamically import... is this expected? full code
stack trace
|
I noticed 2 things You need to add 'Customer' to your LOCAL_MODEL_CLASSES in settings.py |
Added a check when importing
and switching the enums to OP_ADD worked :). Appreciate all the help! Sorry to abuse this issue for an unrelated question; what steps would I need to take to query existing customers already in quickbooks that I haven't added from this django app? (I assume sending an XML to query should be sufficient, but is there an example on how to do so?) |
sorry missed your message: you can do so by add QBDTask for qb_operation=QUICKBOOKS_ENUMS.OPP_QR to the Resource that you want to query |
If you want, can you please open a PR with documentation about the issues that you have faced and how you have fixed them? |
Definitely, I can do that. Hoping to do that once I confirm I have a solid understanding of querying as well 😓 |
here's what I did. I created a customer from quickbooks UI and then wanted to see if I could fetch that object via a query. Query is below. I received an XML response. However, is this right? I assume after reading the xml, I can just convert the xml to the actual object?
What's not clear to me is:
|
when you issue the all responses are handled ResponseProcessor class CustomerQueryResponseProcessor(ResponseProcessor, ResponseProcessorMixin):
resource = QUICKBOOKS_ENUMS.RESOURCE_CUSTOMER
op_type = QUICKBOOKS_ENUMS.OPP_QR
local_model_class = LocalCustomer
obj_class = Customer
def process(self, realm):
cont = super().process(realm)
if not cont:
return False
for customer_ret in list(self._response_body):
customer = self.obj_class.from_lxml(customer_ret)
local_customer = None
if customer.ListID:
local_customer = self.find_by_list_id(customer.ListID)
if not local_customer and customer.Name:
local_customer = self.find_by_name(customer.Name)
if local_customer:
self.update(local_customer, customer)
else:
self.create(customer)
return True
you can inherit from it or define your own if you have more questions you can send me an email, I will be more than happy to get in a meeting with you. |
Hi there! XML/QB noob here, this thread has already been super helpful in programmatic customer creation. Would you mind also posting your solution to creating an invoice? |
I see there's classes such as Customer, Invoice which I presume are created for common use cases.
Say my goal is to programmatically create a customer/invoice, is there a quickstart guide for doing so?
I.e once I'm authed with QB desktop, is there a way to create a customer and send that request to the webconnector to process?
either via raw xml or a model?
If yall could post a short snippet on either this README example https://github.com/weltlink/django-quickbooks#implementation
or provide guidance on how I would add this customer to the QBD Task queue, that would be greatly appreciated!
Trying to understand what the django_quickbooks.services is used for....
The text was updated successfully, but these errors were encountered: