[web2py] Re: Calculations on values extracted from several database tables not displaying some values

2021-12-01 Thread Jim S
Just need to move around where we're getting the variables.




Quantity
Description
Order Price
Value


{{tourism_levy = 10.00}}
{{for invoice in room:}}

{{=invoice.No_Days}} (days)
{{=invoice.Room.Room_Number}}
BWP {{=invoice.roomAmount}}
BWP {{=invoice.Amount}}

{{total = float(invoice.Amount)}}

{{for add_r in add_room:}}

{{=add_r.No_Days}} (days)
{{=add_r.Room.Room_Number}}
BWP {{=add_r.roomAmount}}
BWP {{=add_r.Amount}}

{{total += float(add_r.Amount)
{{pass}}

{{for orders in room_service:}}

{{=orders.quantity}}
{{=orders.client_order}}
BWP {{=orders.price}}
BWP {{=orders.totalPrice}}

{{total += orders.totalPrice}}
{{pass}}

{{totalPrice=total + tourism_levy}}



(Levy EXCLUSIVE)
Sub-Total:
BWP {{=total}}




 Tourism Levy:
BWP {{=tourism_levy}}



(Levy INCLUSIVE)
Total:
BWP {{=totalPrice}}

{{pass}}




-Jim

On Tuesday, November 30, 2021 at 11:25:59 PM UTC-6 mostwanted wrote:

> With this approach some variables the become undetectable, I get errors 
> that:  * name 'orders' is not defined  *and  
> * 'exceptions.NameError'> name 'add_r' is not defined* 
>
> On Tuesday, November 30, 2021 at 5:23:02 PM UTC+2 Jim S wrote:
>
>> It looks to me like your nesting in your template is wrong.  Seems that 
>> your {{pass}} statements are not where they should be.  Based on how I'm 
>> reading it, you'll only get a total if there are orders for room service.  
>> You'll only get room service amounts if there are extra room bookings.
>>
>> I'd do this:
>>
>> 
>> 
>> 
>> Quantity
>> Description
>> Order Price
>> Value
>> 
>> 
>> {{for invoice in room:}}
>> 
>> {{=invoice.No_Days}} (days)
>> {{=invoice.Room.Room_Number}}
>> BWP {{=invoice.roomAmount}}
>> BWP {{=invoice.Amount}}
>> 
>> 
>> {{for add_r in add_room:}}
>> 
>> {{=add_r.No_Days}} (days)
>> {{=add_r.Room.Room_Number}}
>> BWP {{=add_r.roomAmount}}
>> BWP {{=add_r.Amount}}
>> 
>> {{pass}}
>> 
>> {{for orders in room_service:}}
>> 
>> {{=orders.quantity}}
>> {{=orders.client_order}}
>> BWP {{=orders.price}}
>> BWP {{=orders.totalPrice}}
>> 
>> {{pass}}
>> {{
>> #Total Calculations of all services rendered
>> tourism_levy=10.00
>> 
>> total=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)
>> 
>> totalPrice=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)+tourism_levy
>> }}
>> 
>> 
>> 
>> (Levy EXCLUSIVE)
>> Sub-Total:
>> BWP {{=total}}
>> 
>> 
>> 
>> 
>>  Tourism Levy:
>> BWP {{=tourism_levy}}
>> 
>> 
>> 
>> (Levy INCLUSIVE)
>> Total:
>> BWP {{=totalPrice}}
>> 
>> {{pass}}
>> 
>> 
>> 
>>
>> -Jim
>>
>> On Tuesday, November 30, 2021 at 12:58:23 AM UTC-6 mostwanted wrote:
>>
>>> In my Guest House booking system I function that is intended to do 
>>> invoice calculations for clients using values from different database 
>>> tables & display the information in a table in the view.
>>>
>>> The problem now is some information is not being displayed in the table 
>>> in the view when a client has not ordered some services. E.G; 
>>>
>>>- When a client books in and just orders meals and does not request 
>>>an extra room the meals information does not show in the invoice table 
>>> only 
>>>the room information displays but the total amount charges are not 
>>>displayed. 
>>>- When a client books a room and an extra room the total amount 
>>>charges are not displayed. 
>>>

[web2py] Re: Calculations on values extracted from several database tables not displaying some values

2021-11-30 Thread mostwanted
With this approach some variables the become undetectable, I get errors 
that:  * name 'orders' is not defined  *and  
* name 'add_r' is not defined* 

On Tuesday, November 30, 2021 at 5:23:02 PM UTC+2 Jim S wrote:

> It looks to me like your nesting in your template is wrong.  Seems that 
> your {{pass}} statements are not where they should be.  Based on how I'm 
> reading it, you'll only get a total if there are orders for room service.  
> You'll only get room service amounts if there are extra room bookings.
>
> I'd do this:
>
> 
> 
> 
> Quantity
> Description
> Order Price
> Value
> 
> 
> {{for invoice in room:}}
> 
> {{=invoice.No_Days}} (days)
> {{=invoice.Room.Room_Number}}
> BWP {{=invoice.roomAmount}}
> BWP {{=invoice.Amount}}
> 
> 
> {{for add_r in add_room:}}
> 
> {{=add_r.No_Days}} (days)
> {{=add_r.Room.Room_Number}}
> BWP {{=add_r.roomAmount}}
> BWP {{=add_r.Amount}}
> 
> {{pass}}
> 
> {{for orders in room_service:}}
> 
> {{=orders.quantity}}
> {{=orders.client_order}}
> BWP {{=orders.price}}
> BWP {{=orders.totalPrice}}
> 
> {{pass}}
> {{
> #Total Calculations of all services rendered
> tourism_levy=10.00
> 
> total=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)
> 
> totalPrice=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)+tourism_levy
> }}
> 
> 
> 
> (Levy EXCLUSIVE)
> Sub-Total:
> BWP {{=total}}
> 
> 
> 
> 
>  Tourism Levy:
> BWP {{=tourism_levy}}
> 
> 
> 
> (Levy INCLUSIVE)
> Total:
> BWP {{=totalPrice}}
> 
> {{pass}}
> 
> 
> 
>
> -Jim
>
> On Tuesday, November 30, 2021 at 12:58:23 AM UTC-6 mostwanted wrote:
>
>> In my Guest House booking system I function that is intended to do 
>> invoice calculations for clients using values from different database 
>> tables & display the information in a table in the view.
>>
>> The problem now is some information is not being displayed in the table 
>> in the view when a client has not ordered some services. E.G; 
>>
>>- When a client books in and just orders meals and does not request 
>>an extra room the meals information does not show in the invoice table 
>> only 
>>the room information displays but the total amount charges are not 
>>displayed. 
>>- When a client books a room and an extra room the total amount 
>>charges are not displayed. 
>>- Only when a client has booked a room, booked an extra room and 
>>ordered meals thats when all the information is displayed in the invoices 
>>including calculations.
>>
>>  I am doing something wrong somewhere in my code but i can not figure it 
>> out. I need assistance.
>>
>> *CONTROLLER:*
>> def viewInvoices():
>> invoice=db.ClientDetails(request.args(0, cast=int))
>> resCompany=db(db.my_company).select()
>> room=db((db.book_client2.ClientDetails==invoice.id) & 
>> (db.book_client2.determinant==1)).select()
>> add_room=db((db.additionalRooms2.book_client==invoice.id) & 
>> (db.additionalRooms2.determinant==1)).select()
>> room_service=db((db.room_service_orders.customer==invoice.id) 
>> &(db.room_service_orders.determinant==1)).select()
>> return locals()
>>
>> *VIEW:*
>> 
>> 
>> 
>> Quantity
>> Description
>> Order Price
>> Value
>> 
>> 
>> **
>> {{for invoice in room:}}
>> {{=invoice.No_Days}} (days)
>> {{=invoice.Room.Room_Number}}
>> BWP {{=invoice.roomAmount}}
>> BWP {{=invoice.Amount}}
>> 
>> 
>> **
>> {{for add_r in add_room:}}
>> {{=add_r.No_Days}} (days)
>> {{=add_r.Room.Room_Number}}
>> BWP {{=add_r.roomAmount}}
>> BWP {{=add_r.Amount}}
>> 
>> 
>> 
>> **
>> {{for orders in room_service:}}
>> {{=orders.quantity}}
>> {{=orders.client_order}}
>> BWP {{=orders.price}}
>> BWP {{=orders.totalPrice}}
>> 
>> {{
>> *#Total Calculations of all services rendered*
>>   tourism_levy=10.00
>> 
>> total=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)
>> 
>> totalPrice=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)+tourism_levy
>> }}
>> 
>> **
>> (Levy EXCLUSIVE)Sub-Total:> 

[web2py] Re: Calculations on values extracted from several database tables not displaying some values

2021-11-30 Thread Jim S
It looks to me like your nesting in your template is wrong.  Seems that 
your {{pass}} statements are not where they should be.  Based on how I'm 
reading it, you'll only get a total if there are orders for room service.  
You'll only get room service amounts if there are extra room bookings.

I'd do this:




Quantity
Description
Order Price
Value


{{for invoice in room:}}

{{=invoice.No_Days}} (days)
{{=invoice.Room.Room_Number}}
BWP {{=invoice.roomAmount}}
BWP {{=invoice.Amount}}


{{for add_r in add_room:}}

{{=add_r.No_Days}} (days)
{{=add_r.Room.Room_Number}}
BWP {{=add_r.roomAmount}}
BWP {{=add_r.Amount}}

{{pass}}

{{for orders in room_service:}}

{{=orders.quantity}}
{{=orders.client_order}}
BWP {{=orders.price}}
BWP {{=orders.totalPrice}}

{{pass}}
{{
#Total Calculations of all services rendered
tourism_levy=10.00

total=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)

totalPrice=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)+tourism_levy
}}



(Levy EXCLUSIVE)
Sub-Total:
BWP {{=total}}




 Tourism Levy:
BWP {{=tourism_levy}}



(Levy INCLUSIVE)
Total:
BWP {{=totalPrice}}

{{pass}}




-Jim

On Tuesday, November 30, 2021 at 12:58:23 AM UTC-6 mostwanted wrote:

> In my Guest House booking system I function that is intended to do invoice 
> calculations for clients using values from different database tables & 
> display the information in a table in the view.
>
> The problem now is some information is not being displayed in the table in 
> the view when a client has not ordered some services. E.G; 
>
>- When a client books in and just orders meals and does not request an 
>extra room the meals information does not show in the invoice table only 
>the room information displays but the total amount charges are not 
>displayed. 
>- When a client books a room and an extra room the total amount 
>charges are not displayed. 
>- Only when a client has booked a room, booked an extra room and 
>ordered meals thats when all the information is displayed in the invoices 
>including calculations.
>
>  I am doing something wrong somewhere in my code but i can not figure it 
> out. I need assistance.
>
> *CONTROLLER:*
> def viewInvoices():
> invoice=db.ClientDetails(request.args(0, cast=int))
> resCompany=db(db.my_company).select()
> room=db((db.book_client2.ClientDetails==invoice.id) & 
> (db.book_client2.determinant==1)).select()
> add_room=db((db.additionalRooms2.book_client==invoice.id) & 
> (db.additionalRooms2.determinant==1)).select()
> room_service=db((db.room_service_orders.customer==invoice.id) 
> &(db.room_service_orders.determinant==1)).select()
> return locals()
>
> *VIEW:*
> 
> 
> 
> Quantity
> Description
> Order Price
> Value
> 
> 
> **
> {{for invoice in room:}}
> {{=invoice.No_Days}} (days)
> {{=invoice.Room.Room_Number}}
> BWP {{=invoice.roomAmount}}
> BWP {{=invoice.Amount}}
> 
> 
> **
> {{for add_r in add_room:}}
> {{=add_r.No_Days}} (days)
> {{=add_r.Room.Room_Number}}
> BWP {{=add_r.roomAmount}}
> BWP {{=add_r.Amount}}
> 
> 
> 
> **
> {{for orders in room_service:}}
> {{=orders.quantity}}
> {{=orders.client_order}}
> BWP {{=orders.price}}
> BWP {{=orders.totalPrice}}
> 
> {{
> *#Total Calculations of all services rendered*
>   tourism_levy=10.00
> 
> total=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)
> 
> totalPrice=float(invoice.Amount)+float(add_r.Amount)+float(orders.totalPrice)+tourism_levy
> }}
> 
> **
> (Levy EXCLUSIVE)Sub-Total: style="font-weight: bold; font-size: 14px; color: green;" width: 29px>BWP 
> {{=total}}
> 
> 
>  Tourism Levy: BWP {{=tourism_levy}}
> 
> 
> (Levy INCLUSIVE)Total:  style="font-weight: bold; font-size: 14px; color: green;" width: 29px>BWP 
> {{=totalPrice}}
> 
>   {{pass}}
> {{pass}}
> {{pass}}
> 
> 
> 
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book