hi
currently i am doing this car booking website. i would like to only update our inventory one day before customer's start booking time, thus before that, i am still able to rent to other customers. E.g. if she book two month before, i can still rent this car to others within this 2 month, but one day before i need to deduct this car inventory as the next day i have to give this car to that customer.
the following is my car inventory update function. but it seems did not work in my way, as i loop through my Booking1 table to get all the start_datetime and update my inventory only if it is one day before this start_datetime. my start_datetime is in the format of "2007-12-21 17:05:05", i have changed it into seconds by using Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S")). but it seems not work. can anyone help me with this. can update my car inventory only one day before the start_datetime. thanks for any kind help:) -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
#t=str(invtime).split('.')[0]
-
Bktime=time.mktime(time.strptime(invtime,"%Y-%m-%d %H:%M:%S"))
-
#now=datetime.datetime.now()
-
one_day=60*60*24
-
#diff=comp_dates(t,str(now).split('.')[0])
-
#print diff
-
onebefore=Bktime-one_day------>>>Error,where is wrong?date type?
-
if str(onebefore):
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not str(onebefore):
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
12 1842 bvdet 2,851
Recognized Expert Moderator Specialist
hi
currently i am doing this car booking website. i would like to only update our inventory one day before customer's start booking time, thus before that, i am still able to rent to other customers. E.g. if she book two month before, i can still rent this car to others within this 2 month, but one day before i need to deduct this car inventory as the next day i have to give this car to that customer.
the following is my car inventory update function. but it seems did not work in my way, as i loop through my Booking1 table to get all the start_datetime and update my inventory only if it is one day before this start_datetime. my start_datetime is in the format of "2007-12-21 17:05:05", i have changed it into seconds by using Bktime=time.mkt ime(time.strpti me(invtime,"%Y-%m-%d %H:%M:%S")). but it seems not work. can anyone help me with this. can update my car inventory only one day before the start_datetime. thanks for any kind help:) -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
#t=str(invtime).split('.')[0]
-
Bktime=time.mktime(time.strptime(invtime,"%Y-%m-%d %H:%M:%S"))
-
#now=datetime.datetime.now()
-
one_day=60*60*24
-
#diff=comp_dates(t,str(now).split('.')[0])
-
#print diff
-
onebefore=Bktime-one_day------>>>Error,where is wrong?date type?
-
if str(onebefore):
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not str(onebefore):
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
The way you have calculated onebefore, it will always evaluate to True. I think you should calculate the difference between the date the car has been rented and the present date, and if the difference is greater than one day, keep the car in inventory, otherwise remove it.
The way you have calculated onebefore, it will always evaluate to True. I think you should calculate the difference between the date the car has been rented and the present date, and if the difference is greater than one day, keep the car in inventory, otherwise remove it.
hi, thanks for it, i have done according to this logic and i feel it is correct. but it got small error. my code is in the following: -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
now=datetime.datetime.now()
-
one_day=60*60*24
-
diff=comp_dates(invtime,str(now).split('.')[0])
-
print diff
-
print"LLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPJ"
-
if diff < one_day:
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not diff < one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
my error is:
Request Method: GET
Request URL: http://localhost:8000/inventoryupdate/
Exception Type: TypeError
Exception Value: expected string or buffer
Exception Location: C:\Python25\lib \_strptime.py in strptime, line 328
Python Executable: C:\Python25\pyt hon.exe
i think there is some TypeError, but i am not sure where? can help me with this, thanks in advance. i believe it is just a small step to success..haha
The way you have calculated onebefore, it will always evaluate to True. I think you should calculate the difference between the date the car has been rented and the present date, and if the difference is greater than one day, keep the car in inventory, otherwise remove it.
hi, thanks for it, i have done according to this logic and i feel it is correct. but it got small error. my code is in the following: -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
now=datetime.datetime.now()
-
one_day=60*60*24
-
diff=comp_dates(invtime,str(now).split('.')[0])
-
print diff
-
print"LLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPJ"
-
if diff < one_day:
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not diff < one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
my error is:
Request Method: GET
Request URL: http://localhost:8000/inventoryupdate/
Exception Type: TypeError
Exception Value: expected string or buffer
Exception Location: C:\Python25\lib \_strptime.py in strptime, line 328
Python Executable: C:\Python25\pyt hon.exe
i think there is some TypeError, but i am not sure where? can help me with this, thanks in advance. i believe it is just a small step to success..haha
The way you have calculated onebefore, it will always evaluate to True. I think you should calculate the difference between the date the car has been rented and the present date, and if the difference is greater than one day, keep the car in inventory, otherwise remove it.
hi, thanks for it, i have done according to this logic and i feel it is correct. but it got small error. my code is in the following: -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
now=datetime.datetime.now()
-
one_day=60*60*24
-
diff=comp_dates(invtime,str(now).split('.')[0])
-
print diff
-
print"LLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPJ"
-
if diff < one_day:
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not diff < one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
my error is:
Request Method: GET
Request URL: http://localhost:8000/inventoryupdate/
Exception Type: TypeError
Exception Value: expected string or buffer
Exception Location: C:\Python25\lib \_strptime.py in strptime, line 328
Python Executable: C:\Python25\pyt hon.exe
i think there is some TypeError, but i am not sure where? can help me with this, thanks in advance. i believe it is just a small step to success..haha
bvdet 2,851
Recognized Expert Moderator Specialist
Check the type of object returned by:
Check the type of object returned by:
i have checked its datatype, it is datetime.dateti me. so i use str() to change its data type back to string and thus can compare: my change code is in the following and it works. however, i think there is an logic error, as everytime i click update inventory link, it will deduct inventory one more time. this function is mainly for admin or staff user. if one staff click this link to see the inventory in warehouse, it deduct one already, then within next second, another staff come and click again to view inventory. it deduct one again, which is wrong and inventory is not accurate. how can i solve this issue.....can kindly help me with this..... -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
#print i.booking_time
-
invtime=i.start_datetime
-
#start_datetime = datetime.datetime(*strptime(invtime,"%Y-%m-%dT%H:%M:%S")[0:6])
-
print invtime
-
print type(invtime)
-
print"KKKKKKKKKKKKKKKK"
-
now=datetime.datetime.now()
-
one_day=60*60*24
-
diff=comp_dates(str(invtime),str(now).split('.')[0])
-
print diff
-
print"LLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPJ"
-
-
if diff < one_day:
-
for a in CarModel.objects.all():
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.save()
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if not diff < one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
-
thanks so much for your kind help.
bvdet 2,851
Recognized Expert Moderator Specialist
It seems to me that you need a Booking1.object attribute that can be checked to determine if it has been applied to the existing inventory. -
if diff < one_day and Booking1.object.deducted_from_inventory == False:
It seems to me that you need a Booking1.object attribute that can be checked to determine if it has been applied to the existing inventory. -
if diff < one_day and Booking1.object.deducted_from_inventory == False:
i think i need to create one more datebase table and its type should boolean.so when it deducts, i should turn it to true. and when it does not deducts, the default setting should be false. if my understanding is not wrong, i believe this should be the correct way. i will try to do now, thanks so much for giving me this bright idea. i will try now and let you know later. :)
i have tried it, in fact car inventory is in CarModel table which is separated from Booking1 table, as i have normalized the database table. Thus i edited the code in the following and i think it works. -
def inventory(request):
-
-
allObj=[]
-
for i in Booking1.objects.all():
-
invtime=i.start_datetime
-
#print invtime
-
#print type(invtime)
-
now=datetime.datetime.now()
-
one_day=60*60*24
-
diff=comp_dates(str(invtime),str(now).split('.')[0])
-
print diff
-
print"LLLLLLLLLLLLLLLLLPPPPPPPPPPPPPPPPPJ"
-
-
#if diff < one_day and CarModel.objects.filter(inventory_deduct=0):
-
for a in CarModel.objects.all():
-
if a.inventory_deduct==0 and diff<one_day:
-
qtyInStock=a.car_inventory
-
orderQuantity = 1
-
qtyLeft = int(qtyInStock) - int(orderQuantity)
-
a.car_inventory=qtyLeft
-
a.inventory_deduct=1
-
a.save()
-
-
allObj=CarModel.objects.all()
-
print allObj
-
print "LLLLLLLLLLLLLLLLLL"
-
return render_to_response("inventoryupdate.html", {'allObj':allObj})
-
if a.inventory_deduct==1 and diff < one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
if diff > one_day:
-
all=CarModel.objects.all()
-
return render_to_response("inventory.html",{'all':all})
-
-
i have added one field called inventory_deduc t and if it is true, it is 1 else it is 0. thus as you can see in my if statement, i have covered three possible situation. this logic is correct, right?? am i lack of any scenario?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Melissa |
last post by:
Products appear on multiple orders in a batch of orders. I created a totals
query with the fields, ProductID and SumOfQuantity. I have a TblProduct table of
products with the fields ProductID, Inventory, and other fields not relevant
here. My intent was to join the query and the table on the ProductID fields in
an update query to update...
|
by: ralph_noble |
last post by:
Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ralph_noble@hotmail.com)
================
UPDATE INVENTORY
INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)
|
by: qt1504 |
last post by:
I have two small stores in two different building which is not a LAN
network. However, each has an internet access. I am trying to write
an inventory program which manage inventory two stores. Can anyone
help or guide me how to start? Please advise.
Thanks,
QT
|
by: Jeff |
last post by:
I have a simple database with Table Inventory and Order.
In Table Order, I have fields SKU#......QtySold
Where Inventory-SKU# related to Order-SKU# (One SKU# to many Order)
Now I want to calculate the percentage of QtySold>5 to Total number of
Order.
And I want to put the result into a field in Inventory.
Anyone can help?
|
by: SamDev |
last post by:
I have a table that lists inventory items with prices and suppler and
inventory description. There are times when a supplier will have a %
increase of prices for all items so I want to be able to enter the price %
increase and have a query update all inventory items for that supplier by
the specified % increase.
Not sure what is the best...
| |
by: arion |
last post by:
Hello,
I am working on a very complex database and now I am trying to create an update query. The query is showing too few records. I am trying to update data in the table "inventory" with data from "workorder" table. The query is just copying the last workorder. I would like to update all new workorders to the inventory (can be until 100...
|
by: cblank |
last post by:
I'm having some trouble with my inventory program. Its due tom and my teacher is not wanting to help. He keeps giving me a soluction that is not related to my code. I have everything working except the Delete and Modify Button. The Search button works but it only searchs the new .dat file or what is set in the array. Not sure what is going on...
|
by: deltamami0999 |
last post by:
I just received this e-mail from a colleague of mine that got stuck and she sent it to me and i'm stuck....we're wondering what this is all about.....can anyone help?
Inventory Management System
The inventory management system is designed to be used primarily by warehouse workers. The system must use a simple command line driven...
|
by: 100grand |
last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one
product at a time, including the item number, the name of the product, the number of
units in stock, the price of each unit, and the value of the inventory of that product. In
addition, the GUI should display the value of the entire inventory, the additional...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |