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
|
from datetime import date
|
||||||
import timeit
|
import timeit
|
||||||
import os
|
import os
|
||||||
|
import pythoncom
|
||||||
|
|
||||||
class SalesOrderQuery:
|
class SalesOrderQuery:
|
||||||
def __init__(self, **kwargs) -> None:
|
def __init__(self, **kwargs) -> None:
|
||||||
@ -215,7 +216,7 @@ class SalesOrderQuery:
|
|||||||
# enumfodnc= win32com.client.Dispatch('QBXMLRP2.RequestProcessor')
|
# enumfodnc= win32com.client.Dispatch('QBXMLRP2.RequestProcessor')
|
||||||
# print(enumfodnc)
|
# print(enumfodnc)
|
||||||
# print(enumfodnc.qbFileOpenDoNotCare)
|
# print(enumfodnc.qbFileOpenDoNotCare)
|
||||||
sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")
|
sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor", pythoncom.CoInitialize())
|
||||||
sessionManager.OpenConnection('', 'DASA2')
|
sessionManager.OpenConnection('', 'DASA2')
|
||||||
# ticket = sessionManager.BeginSession("z:\\DBW Bogor.qbw", 2)
|
# ticket = sessionManager.BeginSession("z:\\DBW Bogor.qbw", 2)
|
||||||
|
|
||||||
|
|||||||
@ -13,47 +13,67 @@ from django.core.serializers.json import DjangoJSONEncoder
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
import os
|
import os
|
||||||
import pandas as pd
|
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):
|
def show_customer(request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
thispath = os.getcwd()
|
# thispath = os.getcwd()
|
||||||
print(thispath)
|
# print(thispath)
|
||||||
parent = os.path.dirname(thispath)
|
basedir = settings.BASE_DIR
|
||||||
print(parent)
|
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")
|
customers_file = os.path.join(parent, "ItemInventory", "CustomerList.xlsx")
|
||||||
df = pd.read_excel(customers_file, usecols=["FullName"])
|
df = pd.read_excel(customers_file, usecols=["FullName"])
|
||||||
|
|
||||||
context={"customers": df.values.tolist()}
|
context={"customers": df.values.tolist()}
|
||||||
if request.method =="POST":
|
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")
|
customer_name = request.POST.get("customerreffullname")
|
||||||
print(f'customer_name: {customer_name}')
|
print(f'customer_name: {customer_name}')
|
||||||
context['objects'] = ['abc', 'def', 'ghi', 'jkl']
|
context['objects'] = [['abc', 'def', 'ghi', 'jkl']]
|
||||||
|
context['objects'] = []
|
||||||
|
|
||||||
if customer_name:
|
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)
|
||||||
print("after ini")
|
if ini:
|
||||||
# qbxml = ini.create_QBXML()
|
print("after ini")
|
||||||
# print(qbxml)
|
qbxml = ini.create_QBXML()
|
||||||
response_string = ini.connect_to_quickbooks(ini.create_QBXML())
|
print(qbxml)
|
||||||
print(response_string)
|
response_string = ini.connect_to_quickbooks(qbxml)
|
||||||
open_sales_orders = ini.get_open_so()
|
print(response_string)
|
||||||
print(f'open sales orders:{open_sales_orders}')
|
open_sales_orders = ini.get_open_so()
|
||||||
ini=None
|
print(f'open sales orders:{open_sales_orders}')
|
||||||
if open_sales_orders:
|
ini=None
|
||||||
context['objects'] = open_sales_orders
|
if open_sales_orders:
|
||||||
|
context['objects'] = open_sales_orders
|
||||||
|
|
||||||
|
|
||||||
context['customer_fullname'] = customer_name
|
context['customer_fullname'] = customer_name
|
||||||
return render(request, "Invoice/so_list_form.html", context)
|
return render(request, "Invoice/so_list_form.html", context)
|
||||||
# print(df.values.tolist())
|
# print(df.values.tolist())
|
||||||
|
|
||||||
|
|
||||||
@ -71,9 +91,18 @@ def show_inv(request):
|
|||||||
print(request.POST)
|
print(request.POST)
|
||||||
if ('so_field' in request.POST) and ('customer_fullname' in request.POST):
|
if ('so_field' in request.POST) and ('customer_fullname' in request.POST):
|
||||||
# print(request.POST.getlist('so_field'))
|
# 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')
|
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 render( request, "Invoice/so_list_form.html", context)
|
||||||
# return HttpResponse('')
|
# return HttpResponse('')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user