@@ -1126,6 +1126,23 @@ def create_bill_lineitems(expense_group: ExpenseGroup, configuration: Configurat
11261126 allocation_dimensions = set (allocation_detail .keys ())
11271127 user_defined_dimensions = [user_defined_dimension for user_defined_dimension in user_defined_dimensions if list (user_defined_dimension .keys ())[0 ] not in allocation_dimensions ]
11281128
1129+ if lineitem .billable and not (dimensions_values ['customer_id' ] and dimensions_values ['item_id' ]):
1130+ missing_fields = []
1131+ if not dimensions_values ['customer_id' ]:
1132+ missing_fields .append ('customer_id' )
1133+ if not dimensions_values ['item_id' ]:
1134+ missing_fields .append ('item_id' )
1135+ add_system_comment (
1136+ system_comments = system_comments ,
1137+ source = SystemCommentSourceEnum .CREATE_BILL_LINEITEMS ,
1138+ intent = SystemCommentIntentEnum .BILLABLE_DISABLED ,
1139+ entity_type = SystemCommentEntityTypeEnum .EXPENSE ,
1140+ workspace_id = expense_group .workspace_id ,
1141+ entity_id = lineitem .id ,
1142+ reason = SystemCommentReasonEnum .BILLABLE_SET_TO_FALSE_MISSING_DIMENSIONS ,
1143+ info = {'missing_fields' : missing_fields , 'original_billable' : lineitem .billable }
1144+ )
1145+
11291146 bill_lineitem_object , _ = BillLineitem .objects .update_or_create (
11301147 bill = bill ,
11311148 expense_id = lineitem .id ,
@@ -1344,6 +1361,23 @@ def create_expense_report_lineitems(expense_group: ExpenseGroup, configuration:
13441361 info = {'original_merchant' : merchant , 'vendor_used' : 'Credit Card Misc' }
13451362 )
13461363
1364+ if lineitem .billable and not (customer_id and item_id ):
1365+ missing_fields = []
1366+ if not customer_id :
1367+ missing_fields .append ('customer_id' )
1368+ if not item_id :
1369+ missing_fields .append ('item_id' )
1370+ add_system_comment (
1371+ system_comments = system_comments ,
1372+ source = SystemCommentSourceEnum .CREATE_EXPENSE_REPORT_LINEITEMS ,
1373+ intent = SystemCommentIntentEnum .BILLABLE_DISABLED ,
1374+ entity_type = SystemCommentEntityTypeEnum .EXPENSE ,
1375+ workspace_id = expense_group .workspace_id ,
1376+ entity_id = lineitem .id ,
1377+ reason = SystemCommentReasonEnum .BILLABLE_SET_TO_FALSE_MISSING_DIMENSIONS ,
1378+ info = {'missing_fields' : missing_fields , 'original_billable' : lineitem .billable }
1379+ )
1380+
13471381 expense_report_lineitem_object , _ = ExpenseReportLineitem .objects .update_or_create (
13481382 expense_report = expense_report ,
13491383 expense_id = lineitem .id ,
@@ -1568,6 +1602,23 @@ def create_journal_entry_lineitems(expense_group: ExpenseGroup, configuration: C
15681602
15691603 allocation_id , _ = get_allocation_id_or_none (expense_group = expense_group , lineitem = lineitem )
15701604
1605+ if lineitem .billable and not (customer_id and item_id ):
1606+ missing_fields = []
1607+ if not customer_id :
1608+ missing_fields .append ('customer_id' )
1609+ if not item_id :
1610+ missing_fields .append ('item_id' )
1611+ add_system_comment (
1612+ system_comments = system_comments ,
1613+ source = SystemCommentSourceEnum .CREATE_JOURNAL_ENTRY_LINEITEMS ,
1614+ intent = SystemCommentIntentEnum .BILLABLE_DISABLED ,
1615+ entity_type = SystemCommentEntityTypeEnum .EXPENSE ,
1616+ workspace_id = expense_group .workspace_id ,
1617+ entity_id = lineitem .id ,
1618+ reason = SystemCommentReasonEnum .BILLABLE_SET_TO_FALSE_MISSING_DIMENSIONS ,
1619+ info = {'missing_fields' : missing_fields , 'original_billable' : lineitem .billable }
1620+ )
1621+
15711622 journal_entry_lineitem_object , _ = JournalEntryLineitem .objects .update_or_create (
15721623 journal_entry = journal_entry ,
15731624 expense_id = lineitem .id ,
@@ -1795,6 +1846,23 @@ def create_charge_card_transaction_lineitems(expense_group: ExpenseGroup, config
17951846 info = {'original_merchant' : lineitem .vendor , 'vendor_used' : 'Credit Card Misc' }
17961847 )
17971848
1849+ if lineitem .billable and not (customer_id and item_id ):
1850+ missing_fields = []
1851+ if not customer_id :
1852+ missing_fields .append ('customer_id' )
1853+ if not item_id :
1854+ missing_fields .append ('item_id' )
1855+ add_system_comment (
1856+ system_comments = system_comments ,
1857+ source = SystemCommentSourceEnum .CREATE_CHARGE_CARD_TRANSACTION_LINEITEMS ,
1858+ intent = SystemCommentIntentEnum .BILLABLE_DISABLED ,
1859+ entity_type = SystemCommentEntityTypeEnum .EXPENSE ,
1860+ workspace_id = expense_group .workspace_id ,
1861+ entity_id = lineitem .id ,
1862+ reason = SystemCommentReasonEnum .BILLABLE_SET_TO_FALSE_MISSING_DIMENSIONS ,
1863+ info = {'missing_fields' : missing_fields , 'original_billable' : lineitem .billable }
1864+ )
1865+
17981866 charge_card_transaction_lineitem_object , _ = ChargeCardTransactionLineitem .objects .update_or_create (
17991867 charge_card_transaction = charge_card_transaction ,
18001868 expense_id = lineitem .id ,
0 commit comments