mirror of
https://github.com/bcomsugi/dasaproject.git
synced 2026-01-10 16:52:38 +07:00
Dasaproject
This commit is contained in:
parent
5854568f28
commit
3ca1b27b22
@ -7,6 +7,7 @@ import pandas as pd
|
||||
from datetime import date
|
||||
import timeit
|
||||
import os
|
||||
import pythoncom
|
||||
|
||||
class SalesOrderQuery:
|
||||
def __init__(self, **kwargs) -> None:
|
||||
@ -215,7 +216,7 @@ class SalesOrderQuery:
|
||||
# enumfodnc= win32com.client.Dispatch('QBXMLRP2.RequestProcessor')
|
||||
# print(enumfodnc)
|
||||
# print(enumfodnc.qbFileOpenDoNotCare)
|
||||
sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")
|
||||
sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor", pythoncom.CoInitialize())
|
||||
sessionManager.OpenConnection('', 'DASA2')
|
||||
# ticket = sessionManager.BeginSession("z:\\DBW Bogor.qbw", 2)
|
||||
|
||||
|
||||
@ -13,37 +13,57 @@ from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.contrib import messages
|
||||
import os
|
||||
import pandas as pd
|
||||
from django.conf import settings
|
||||
|
||||
def get_SalesOrderQuery(customer_name):
|
||||
try:
|
||||
print("try")
|
||||
from SO_to_Inv.readSO import SalesOrderQuery
|
||||
|
||||
except:
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
print("except")
|
||||
print(sys.path)
|
||||
from SO_to_Inv.readSO import SalesOrderQuery
|
||||
|
||||
# print(os.getcwd())
|
||||
# parentdir = os.path.dirname(os.getcwd())
|
||||
# print(parentdir)
|
||||
|
||||
|
||||
basedir = settings.BASE_DIR
|
||||
parentdir = os.path.dirname(basedir)
|
||||
ini=SalesOrderQuery(FullName= customer_name, IncludeRetElement = ['TxnID', 'TimeCreated', 'TimeModified','TxnNumber', 'CustomerRef', 'TxnDate', 'RefNumber', 'IsManuallyClosed', 'IsFullyInvoiced','TotalAmount'], cwd=parentdir)
|
||||
return ini
|
||||
return None
|
||||
|
||||
def show_customer(request):
|
||||
pass
|
||||
|
||||
thispath = os.getcwd()
|
||||
print(thispath)
|
||||
parent = os.path.dirname(thispath)
|
||||
print(parent)
|
||||
# thispath = os.getcwd()
|
||||
# print(thispath)
|
||||
basedir = settings.BASE_DIR
|
||||
parent = os.path.dirname(basedir)
|
||||
print(f'parent dir= {parent}')
|
||||
print(f"Base_DIR: {settings.BASE_DIR}")
|
||||
customers_file = os.path.join(parent, "ItemInventory", "CustomerList.xlsx")
|
||||
df = pd.read_excel(customers_file, usecols=["FullName"])
|
||||
|
||||
context={"customers": df.values.tolist()}
|
||||
if request.method =="POST":
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
from SO_to_Inv.readSO import SalesOrderQuery
|
||||
print(os.getcwd())
|
||||
parentdir = os.path.dirname(os.getcwd())
|
||||
print(parentdir)
|
||||
|
||||
|
||||
customer_name = request.POST.get("customerreffullname")
|
||||
print(f'customer_name: {customer_name}')
|
||||
context['objects'] = ['abc', 'def', 'ghi', 'jkl']
|
||||
context['objects'] = [['abc', 'def', 'ghi', 'jkl']]
|
||||
context['objects'] = []
|
||||
|
||||
if customer_name:
|
||||
ini=SalesOrderQuery(FullName= customer_name, IncludeRetElement = ['TxnID', 'TimeCreated', 'TimeModified','TxnNumber', 'CustomerRef', 'TxnDate', 'RefNumber', 'IsManuallyClosed', 'IsFullyInvoiced','TotalAmount'], cwd=parentdir)
|
||||
ini = get_SalesOrderQuery(customer_name)
|
||||
if ini:
|
||||
print("after ini")
|
||||
# qbxml = ini.create_QBXML()
|
||||
# print(qbxml)
|
||||
response_string = ini.connect_to_quickbooks(ini.create_QBXML())
|
||||
qbxml = ini.create_QBXML()
|
||||
print(qbxml)
|
||||
response_string = ini.connect_to_quickbooks(qbxml)
|
||||
print(response_string)
|
||||
open_sales_orders = ini.get_open_so()
|
||||
print(f'open sales orders:{open_sales_orders}')
|
||||
@ -71,9 +91,18 @@ def show_inv(request):
|
||||
print(request.POST)
|
||||
if ('so_field' in request.POST) and ('customer_fullname' in request.POST):
|
||||
# print(request.POST.getlist('so_field'))
|
||||
multivals = request.POST.getlist('so_field')
|
||||
open_sales_orders = request.POST.getlist('so_field')
|
||||
customer_fullname = request.POST.get('customer_fullname')
|
||||
print(f'Customer_fullname:{customer_fullname} -> request values:{multivals}')
|
||||
print(f'Customer_fullname:{customer_fullname} -> request values:{open_sales_orders}')
|
||||
### get the SO detail
|
||||
ini=get_SalesOrderQuery(customer_fullname)
|
||||
itu = ini.get_open_sales_order(open_sales_orders)
|
||||
# print(itu)
|
||||
print(f'get_open_sales_order:{itu}')
|
||||
if itu:
|
||||
invoiceaddQBXML=ini.create_invoiceadd_QBXML()
|
||||
print(invoiceaddQBXML)
|
||||
|
||||
return render( request, "Invoice/so_list_form.html", context)
|
||||
# return HttpResponse('')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user