18
18
import com .intuit .ipp .data .Customer ;
19
19
import com .intuit .ipp .data .DiscountLineDetail ;
20
20
import com .intuit .ipp .data .Estimate ;
21
+ import com .intuit .ipp .data .IntuitEntity ;
21
22
import com .intuit .ipp .data .Invoice ;
22
23
import com .intuit .ipp .data .Item ;
23
24
import com .intuit .ipp .data .ItemTypeEnum ;
@@ -121,10 +122,8 @@ public String callJobsConcept(HttpSession session) {
121
122
122
123
//return response back
123
124
return createResponse (updatedInvoice );
124
-
125
- }
126
- catch (InvalidTokenException e ) {
127
- return new JSONObject ().put ("response" ,"InvalidToken - Refreshtoken and try again" ).toString ();
125
+ } catch (InvalidTokenException e ) {
126
+ return new JSONObject ().put ("response" ,"InvalidToken - Refresh token and try again" ).toString ();
128
127
} catch (FMSException e ) {
129
128
List <Error > list = e .getErrorList ();
130
129
list .forEach (error -> logger .error ("Error while calling the API :: " + error .getMessage ()));
@@ -136,7 +135,7 @@ private Line createDiscountLine(DataService service) throws FMSException {
136
135
DiscountLineDetail discountLineDetail = new DiscountLineDetail ();
137
136
138
137
discountLineDetail .setPercentBased (false );
139
- discountLineDetail .setDiscountAccountRef (createAccountRef (findAccountByType (AccountTypeEnum .INCOME , service )));
138
+ discountLineDetail .setDiscountAccountRef (createRef (findAccountByType (AccountTypeEnum .INCOME , service )));
140
139
141
140
Line discountLine = new Line ();
142
141
@@ -222,7 +221,7 @@ private Estimate getEstimateWithMandatoryFields(Item item, Customer customer, Da
222
221
line1 .setDetailType (LineDetailTypeEnum .SALES_ITEM_LINE_DETAIL );
223
222
224
223
SalesItemLineDetail salesItemLineDetail1 = new SalesItemLineDetail ();
225
- salesItemLineDetail1 .setItemRef (createItemRef (item ));
224
+ salesItemLineDetail1 .setItemRef (createRef (item ));
226
225
227
226
ReferenceType taxCodeRef1 = new ReferenceType ();
228
227
taxCodeRef1 .setValue ("NON" );
@@ -235,9 +234,9 @@ private Estimate getEstimateWithMandatoryFields(Item item, Customer customer, Da
235
234
236
235
237
236
Account depositAccount = findAccountByType (AccountTypeEnum .BANK , service );
238
- estimate .setDepositToAccountRef (createAccountRef (depositAccount ));
237
+ estimate .setDepositToAccountRef (createRef (depositAccount ));
239
238
240
- estimate .setCustomerRef (createCustomerRef (customer ));
239
+ estimate .setCustomerRef (createRef (customer ));
241
240
242
241
estimate .setApplyTaxAfterDiscount (false );
243
242
estimate .setTotalAmt (new BigDecimal ("300.00" ));
@@ -274,31 +273,30 @@ private Item getItemWithMandatoryFields(DataService service) throws FMSException
274
273
item .setUnitPrice (new BigDecimal ("200" ));
275
274
item .setType (ItemTypeEnum .SERVICE );
276
275
277
- item .setIncomeAccountRef (createAccountRef (findAccountByType (AccountTypeEnum .INCOME , service )));
278
- item .setExpenseAccountRef (createAccountRef (findAccountByType (AccountTypeEnum .EXPENSE , service )));
276
+ item .setIncomeAccountRef (createRef (findAccountByType (AccountTypeEnum .INCOME , service )));
277
+ item .setExpenseAccountRef (createRef (findAccountByType (AccountTypeEnum .EXPENSE , service )));
279
278
return item ;
280
279
}
281
280
282
- private ReferenceType createAccountRef (Account account ) {
283
- ReferenceType referenceType = new ReferenceType ();
284
- referenceType .setName (account .getName ());
285
- referenceType .setValue (account .getId ());
286
- return referenceType ;
287
- }
288
-
289
- private ReferenceType createItemRef (Item item ) {
281
+ private ReferenceType createRef (IntuitEntity entity ) {
290
282
ReferenceType referenceType = new ReferenceType ();
291
- referenceType .setName (item .getName ());
292
- referenceType .setValue (item .getId ());
283
+ referenceType .setValue (entity .getId ());
293
284
return referenceType ;
294
285
}
295
286
296
- private ReferenceType createCustomerRef (Customer customer ) {
297
- ReferenceType referenceType = new ReferenceType ();
298
- referenceType .setName (customer .getFullyQualifiedName ());
299
- referenceType .setValue (customer .getId ());
300
- return referenceType ;
301
- }
287
+ // private ReferenceType createItemRef(Item item) {
288
+ // ReferenceType referenceType = new ReferenceType();
289
+ // referenceType.setName(item.getName());
290
+ // referenceType.setValue(item.getId());
291
+ // return referenceType;
292
+ // }
293
+ //
294
+ // private ReferenceType createCustomerRef(Customer customer) {
295
+ // ReferenceType referenceType = new ReferenceType();
296
+ // referenceType.setName(customer.getFullyQualifiedName());
297
+ // referenceType.setValue(customer.getId());
298
+ // return referenceType;
299
+ // }
302
300
303
301
private String createResponse (Object entity ) {
304
302
ObjectMapper mapper = new ObjectMapper ();
0 commit comments