File size: 19,979 Bytes
2cf3347
 
df646cb
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
4fc98af
2cf3347
 
4fc98af
 
2cf3347
 
 
1324e6f
2bba469
1324e6f
 
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1324e6f
 
2bba469
1324e6f
 
2cf3347
df646cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e805b9
2cf3347
 
 
 
 
 
df646cb
 
 
 
 
 
 
 
 
 
6917493
df646cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cf3347
df646cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4fc98af
 
2cf3347
 
 
2bba469
 
 
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bba469
 
 
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e805b9
2cf3347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e805b9
df646cb
6e805b9
 
 
 
 
 
 
df646cb
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
from pydantic import BaseModel, Field
from typing import Optional,List
from langchain_core.output_parsers import JsonOutputParser # type: ignore

class Noc_Residential_TimeSheetInformation(BaseModel):
    """Details of a timesheet entry."""
    full_name: str = Field(..., description="Full name of the person.")
    position_title: str = Field(..., description="Position title of the person.")
    work_location: str = Field(..., description="Work location of the person.")
    contractor: str = Field(..., description="Contractor's name.")
    noc_id: str = Field(..., description="NOC ID of the person.")
    month_year: str = Field(..., description="Month and year in MM/YYYY format.")
    
    service_days_onshore: int = Field(0, description="Number of service days onshore.")
    standby_days_onshore: int = Field(0, description="Number of standby days onshore in Doha.")
    service_days_offshore: int = Field(0, description="Number of service days offshore.")
    service_days_weekend_public_holiday: int = Field(0, description="Number of service days during weekends or public holidays.")
    standby_extended_hitch_days_offshore: int = Field(0, description="Number of standby and extended hitch days offshore.")
    extended_hitch_days_onshore: int = Field(0, description="Number of extended hitch days onshore for rotational personnel.")
    overtime_Hourly_Rate_ONSHORE:int = Field(0,description="number of over time hours onshore (Over 8 hours) ")
    overtime_Hourly_Rate_OFFSHORE:int = Field(0,description="number of over time hours offshore (Over 12 hours) ")
    per_diem_days: int = Field(0, description="Number of Per Diem days for onshore/offshore rotational personnel.")
    training_days: int = Field(0, description="Number of training days.")
    travel_days: int = Field(0, description="Number of travel days.")
    
    approval_status: str = Field("not approved",description="Indicates whether the NOC representative's name and date are present on the document (e.g., 'approved', 'not approved').")
    approved_on : str = Field(...,description="DD/MM/YY of the stamp")
    approved_by : str = Field(...,description="Name of the person who approved the document")

class Noc_Rotational_TimeSheetInformation(BaseModel):
    """Details of a timesheet entry."""
    full_name: str = Field(..., description="Full name of the person.")
    position_title: str = Field(..., description="Position title of the person.")
    work_location: str = Field(..., description="Work location of the person.")
    contractor: str = Field(..., description="Contractor's name.")
    PO_number:  Optional[str] = Field(None,description="Purchase order")
    noc_id: str = Field(..., description="NOC ID of the person.")
    month_year: str = Field(..., description="Month and year in MM/YYYY format.")
    
    service_days_onshore: int = Field(0, description="Number of service days onshore.")
    standby_days_onshore: int = Field(0, description="Number of standby days onshore in Doha.")
    service_days_offshore: int = Field(0, description="Number of service days offshore.")
    service_days_weekend_public_holiday: int = Field(0, description="Number of service days during weekends or public holidays.")
    standby_extended_hitch_days_offshore: int = Field(0, description="Number of standby and extended hitch days offshore.")
    extended_hitch_days_onshore: int = Field(0, description="Number of extended hitch days onshore for rotational personnel.")
    overtime_Hourly_Rate_ONSHORE:int = Field(0,description="number of over time hours onshore (Over 8 hours) ")
    overtime_Hourly_Rate_OFFSHORE:int = Field(0,description="number of over time hours offshore (Over 12 hours) ")
    per_diem_days: int = Field(0, description="Number of Per Diem days for onshore/offshore rotational personnel.")
    training_days: int = Field(0, description="Number of training days.")
    travel_days: int = Field(0, description="Number of travel days.")  
    
    approval_status: str = Field("not approved",description="Indicates whether the NOC representative's name and date are present on the document (e.g., 'approved', 'not approved').")
    approved_on : str = Field(...,description="DD/MM/YY of the stamp")
    approved_by : str = Field(...,description="Name of the person who approved the document") 

class Noc_TimeSheetInformation(BaseModel):
    """Details of a timesheet entry."""
    position_title: str = Field(..., description="Position title of the person.")
    work_location: str = Field(..., description="Work location ")
    agency: str = Field(..., description="the agency")
    noc_id: str = Field(..., description="NOC ID of the person.")
    full_name: str = Field(..., description="Full name of the person.")
    approval_status: str = Field("not approved",description="(e.g., 'approved', 'not approved').")
    approved_on : str = Field(...,description="DD/MM/YY of the stamp")
    approved_by : str = Field(...,description="Name of the person who approved the document")
    
    service_days_onshore: int = Field(0, description="Number of service days onshore.")
    standby_days_onshore: int = Field(0, description="Number of standby days onshore in Doha.")
    service_days_offshore: int = Field(0, description="Number of service days offshore.")
    service_days_weekend_public_holiday: int = Field(0, description="Number of service days during weekends or public holidays.")
    standby_extended_hitch_days_offshore: int = Field(0, description="Number of standby and extended hitch days offshore.")
    extended_hitch_days_onshore: int = Field(0, description="Number of extended hitch days onshore for rotational personnel.")
    overtime_Hourly_Rate_ONSHORE:int = Field(0,description="number of over time hours onshore (Over 8 hours) ")
    overtime_Hourly_Rate_OFFSHORE:int = Field(0,description="number of over time hours offshore (Over 12 hours) ")
    per_diem_days: int = Field(0, description="Number of Per Diem days for onshore/offshore rotational personnel.")
    training_days: int = Field(0, description="Number of training days.")
    travel_days: int = Field(0, description="Number of travel days.")

class Noc_Item_Information(BaseModel):
    """Details of each item in the document."""
    item_number : int = Field(...,description="the number of the item")
    service_description_code: str = Field(..., description="Service description code for the item.")
    completion_date: str = Field(..., description="Completion date of the service in DD/MM/YYYY format.")
    quantity: float = Field(..., description="Quantity of the service or item provided.")
    unit: str = Field(..., description="Unit of measurement, e.g., Days.")
    unit_price: float = Field(..., description="Unit price.")
    net_amount: float = Field(..., description="Total net amount for this item, calculated as quantity * unit price.")                             
    service_details: str = Field(..., description="Detailed description of the service provided.")

class Noc_Document_Information(BaseModel):
    """Details of the entire document."""
    position_title: str = Field(..., description="Position title of the person.")
    location: Optional[str] = Field(None, description="Location where the service is rendered.")
    mobilization_date: str = Field(..., description="Mobilization date in DD/MM/YYYY format.")
    end_date: str = Field(..., description="End date of the contract in DD/MM/YYYY format.")
    notice_period: Optional[str] = Field(None, description="Notice period for resignation, if applicable")
    items: List[Noc_Item_Information] = Field(..., description="List of items or services provided in the document.")
    
class Noc_items(BaseModel):
    items: List[Noc_Item_Information] = Field(None, description="List of items or services provided in the document.")
    
class Noc_total(BaseModel):
    """totals of the invoice"""
    total_amount_wo_taxes : float = Field(...,description="total amount without taxes")
    total_net_amount_of_order: float = Field(..., description="total net amount of order.")
    total_amount_of_order: float = Field(..., description="total amount of order.")

class Noc_PurchaseOrderInformation(BaseModel):
    """Details of a purchase order entry."""
    purchase_order_number: str = Field(..., description="The unique identifier for the purchase order.")
    date: str = Field(..., description="Date of the purchase order in DD/MM/YYYY format.")
    company_name: str = Field(..., description="Name of the company issuing the purchase order.")
    address: str = Field(..., description="Address of the company issuing the purchase order.")
    tel: Optional[str] = Field(None, description="Telephone number of the company.")
    email: Optional[str] = Field(None, description="Email address of the company.")
    final_shipping_address: Optional[str] = Field(None, description="Final shipping address for the order.")
    buyer_contact_name: str = Field(..., description="Full name of the buyer contact.")
    buyer_contact_company: str = Field(..., description="Company name of the buyer contact.")
    buyer_contact_tel: Optional[str] = Field(None, description="Telephone number of the buyer contact.")
    buyer_contact_email: Optional[str] = Field(None, description="Email address of the buyer contact.")
    our_reference: Optional[str] = Field(None, description="under Our reference title.")
    your_reference: Optional[str] = Field(None, description="under Your reference title.")
    incoterms: Optional[str] = Field(None, description="Incoterms applicable to the order.")
    total_value_of_order: str = Field(..., description="Total value of the purchase order.")
    signed: bool = Field(..., description="Whether the document has been signed or not.")
    signature_released_by: str = Field(None, description="Name of the person who released the purchase order.")
    signature_date: Optional[str] = Field(None, description="Date the order was signed.")

class Noc_Clauses(BaseModel):
    Clauses: str = Field(..., description="the contract clauses.")

class service(BaseModel):
    service: str = Field(..., description="the service name.")
    from_date: str = Field(None,description="starting date in DD/MM/YYYY format..")
    to_date: str = Field(None,description="ending date in DD/MM/YYYY format.")
    currency : str =Field(...,description="currency of the rate.")
    fx: str = Field(None,description="foreign exchange.")
    Number_of_days_hours: int = Field(...,description="number of hours or days for the service.")
    rate: float = Field(..., description="the rate of the service.")
    total: float = Field(...,description="total which is the rate* No of days/hours .")
    
class bank_details(BaseModel):
    bank_name: str = Field(..., description="Name of the bank.")
    swift_bic_code: str = Field(None, description=" SWIFT/BIC CODE.")
    iban_number: str = Field(...,description="IBAN Number.")
    beneficiary_name:str = Field(...,description="full name")
    account_currency: str = Field(...,description="Account currency.")
    expected_amount: str = Field(...,description="the amount.")
    
class Noc_Invoice(BaseModel):
    """Details of an invoice."""
    invoice_date: str = Field(..., description="Date of the invoice in DD/MM/YYYY format")
    invoice_number: str = Field(..., description="Unique identifier for the invoice.")
    full_name: str = Field(..., description="Full name of the person.")
    invoice_to:str = Field(...,description="email to send the invoice forward to.")    
    company_name:str = Field(...,description="company name")
    address: str = Field(..., description="Address of the company.")
    
    services : List[service] = Field(None,description="list of services in the table.")
    sub_total: float = Field(...,description="the sub total.")
    vat: float = Field(None, description="the vat.")
    total_due:float= Field(...,description="the total due.")
    
    first_bank : List[bank_details]=Field(...,description="first bank informations.")
    second_details : List[bank_details]=Field(...,description="second bank details") 
    

Noc_timesheet_prompt = """
Based on the provided timesheet details, extract the following information:
- Position title of the person.
- Work location .
- the agency.
- NOC ID of the person.
- Name of the person.
- approval status
- date of the approval
- approved by
- Number of service days onshore
- Number of standby days onshore in Doha
- Number of service days offshore
- Number of service days during weekends or public holidays
- Number of standby and extended hitch days offshore
- Number of extended hitch days onshore for rotational personnel
- Number of over time hours onshore (Over 8 hours)
- Number of over time hours offshore (Over 12 hours) 
- Number of Per Diem days for onshore/offshore rotational personnel
- Number of training days
- Number of travel days

"""

Noc_invoice_prompt ="""
Based on the provided timesheet details, extract the following information:
- Invoice date
- Invoice number
- Full name of the person
- Email to send the invoice forward to.
- Company name
- Address of the company
- List of services,for each existing service provide:
    - the service name.
    - starting date in DD/MM/YYYY format.
    - ending date in DD/MM/YYYY format.
    - currency of the rate.
    - foreign exchange.
    - number of hours or days for the service.
    - the rate of the service.
    - total which is the rate* No of days/hours .
- Sub total
- VAT
- Total due
- First bank informations, for each existing bank provide, do not mess up the iban:
    - Name of the bank.
    - SWIFT/BIC CODE.
    - IBAN Number.
    - full name.
    - Account currency.
    - the amount.
- Second bank informations, for each existing bank provide,do not mess up the iban:
    - Name of the bank.
    - SWIFT/BIC CODE.
    - IBAN Number.
    - full name.
    - Account currency.
    - the amount. 
"""
    
Noc_Res_timesheet_prompt = """
   Based on the provided timesheet details, extract the following information:
   - Full name of the person
   - Position title of the person
   - Work location
   - Contractor's name
   - NOC ID
   - Month and year (in MM/YYYY format)
   And from the bottom table : 
   - Number of service days onshore
   - Number of standby days onshore in Doha
   - Number of service days offshore
   - Number of service days during weekends or public holidays
   - Number of standby and extended hitch days offshore
   - Number of extended hitch days onshore for rotational personnel
   - Number of over time hours onshore (Over 8 hours)
   - Number of over time hours offshore (Over 12 hours) 
   - Number of Per Diem days for onshore/offshore rotational personnel
   - Number of training days
   - Number of travel days
   - Indicates whether the NOC representative's name and date are present on the document (e.g., 'approved', 'not approved').
   - DD/MM/YY of the stamp
   - Name of the person who approved the document
"""

Noc_Rot_timesheet_prompt = """
   Based on the provided timesheet details, extract the following information:
   - Full name of the person
   - Position title of the person
   - Work location
   - Contractor's name
   - PO number which is the Purchase order
   - NOC ID
   - Month and year (in MM/YYYY format)
   And from the bottom table : 
   - Number of service days onshore
   - Number of standby days onshore in Doha
   - Number of service days offshore
   - Number of service days during weekends or public holidays
   - Number of standby and extended hitch days offshore
   - Number of extended hitch days onshore for rotational personnel
   - ONSHORE Overtime Hourly Rate (Over 8 hours)
   - OFFSHORE Overtime Hourly Rate (Over 12 hours)
   - Number of Per Diem days for onshore/offshore rotational personnel
   - Number of training days
   - Number of travel days
   - Indicates whether the NOC representative's name and date are present on the document (e.g., 'approved', 'not approved').
   - DD/MM/YY of the stamp
   - Name of the person who approved the document
"""

invoice_first_page_prompt="""
Extract the following details from the provided purchase order document:
- Purchase Order Number: The unique identifier for the purchase order.
- Date: The date the purchase order was issued (format: DD/MM/YYYY).
- Company Name: The name of the company issuing the purchase order.
- Address: The address of the company issuing the purchase order.
- Telephone Number: The company's telephone number (if provided).
- Email: The company's email address (if provided).
- Final Shipping Address: The destination shipping address (if specified).
- Buyer Contact Name: The full name of the buyer's contact person.
- Buyer Contact Company: The company name of the buyer contact.
- Buyer Contact Telephone Number: The buyer contact's telephone number (if provided).
- Buyer Contact Email: The buyer contact's email address (if provided).
- Our Reference: Reference specified under the "Our Reference" section (if present).
- Your Reference: Reference specified under the "Your Reference" section (if present).
- Incoterms: Any applicable incoterms mentioned in the document (e.g., FOB, CIF).
- Total Value of the Order: The total monetary value of the purchase order (include currency).
- signed: Whether the document has been signed or not.
- Signature Released By: The name of the person who authorized or released the purchase order.
- Signature Date: The date when the order was signed (format: DD/MM/YYYY).
"""

invoice_item_page1_prompt = """ 
Given the document, extract the following information:
- Position Title: The role or title mentioned in the document.
- Location: The place where the service is being provided.
- Mobilization Date: The date work begins in DD-MM-YYYY format.
- End Date: The date the work ends in DD-MM-YYYY format.
- Notice Period: The required notice period for resignation or termination.
- Items: For each item in the document, provide:
  - Service Description Code: A code identifying the service.
  - Completion Date: The date the service was completed in DD-MM-YYYY format.
  - Quantity: The amount of the item/service provided.
  - Unit: The unit of measurement (e.g., Days, Hours).
  - Unit Price: The price per unit.
  - Net Amount: The total value for the item.
  - Service Details:A description of the service, which follows the corresponding row for the item.

"""

invoice_item_pages_prompt = """ 
Given the document, extract the following information:
- Items:
  - Service Description Code: A code identifying the service.
  - Completion Date: The date the service was completed in DD-MM-YYYY format.
  - Quantity: The amount of the item/service provided.
  - Unit: The unit of measurement (e.g., Days, Hours).
  - Unit Price: The price per unit.
  - Net Amount: The total value for the item.
  - Service Details:A description of the service, which follows the corresponding row for the item.

"""

invoice_total_page_prompt = """
extract from the document:
- Total Amount without taxes.
- Total net amount of order.
- Total amount of order.
"""

invoice_clauses_page_prompt = """ 
extract from the document the clauses  """


# CHOOSING PARSER DEPENDING ON THE TYPE OF DOCUMENT
Noc_Res_timeSheet_parser = JsonOutputParser(pydantic_object=Noc_Residential_TimeSheetInformation)
Noc_Rot_timeSheet_parser = JsonOutputParser(pydantic_object=Noc_Rotational_TimeSheetInformation)
Noc_PurchaseOrder_information_parser = JsonOutputParser(pydantic_object=Noc_PurchaseOrderInformation)
Noc_PurchaseOrder_item1_parser = JsonOutputParser(pydantic_object=Noc_Document_Information)
Noc_PurchaseOrder_items_parser = JsonOutputParser(pydantic_object=Noc_items)
Noc_PurchaseOrder_total_parser = JsonOutputParser(pydantic_object=Noc_total)
Noc_PurchaseOrder_clauses_parser = JsonOutputParser(pydantic_object=Noc_Clauses)
Noc_invoice_parser_v1 = JsonOutputParser(pydantic_object=Noc_Invoice)
Noc_timesheet_parser_v1 = JsonOutputParser(pydantic_object=Noc_TimeSheetInformation)