vault backup: 2023-11-10 02:59:19
This commit is contained in:
		
							parent
							
								
									5e0a1186d8
								
							
						
					
					
						commit
						1250c671e7
					
				| @ -118,22 +118,28 @@ export function apply_guidance(doc: any) { | |||||||
|     //}
 |     //}
 | ||||||
| 
 | 
 | ||||||
|      |      | ||||||
|     doc.targetPrice = doc.v1tp ?? doc.v0tp ?? null; |     doc.targetPrice = doc.v1tp ?? doc.v0tp; | ||||||
|     // Determine the anchor price and source
 |     // Determine the anchor price and source
 | ||||||
|     if (doc.targetPrice !== undefined && (doc.hist.cust.early_price  === undefined || doc.targetPrice < doc.hist.cust.early_price)) { |     if (doc.hist.cust?.early_price !== undefined ) { | ||||||
|         doc.anchorPrice = doc.targetPrice; |  | ||||||
|         doc.anchorSource = 'Target Price'; |  | ||||||
|     } else if (doc.hist.cust.early_price !== undefined) { |  | ||||||
|         if (doc.hist.cust.relevance !== 'customer exact') { |         if (doc.hist.cust.relevance !== 'customer exact') { | ||||||
|             doc.anchorPrice = doc.hist.cust.early_price * doc.bridgePremium; |             doc.anchorPrice = Number((doc.hist.cust.early_price * doc.bridgePremium).toFixed(5)); | ||||||
|  |             if (doc.targetPrice < doc.anchorPrice) { | ||||||
|  |                 doc.anchorPrice = doc.targetPrice; | ||||||
|  |                 doc.anchorSource = 'Target Price' | ||||||
|  |             } else { | ||||||
|                 doc.anchorSource = doc.hist.cust.early_season + ' Similar (' + doc.hist.cust.ds + ') Customer Price ' + doc.hist.cust.early_price + ' x ' + doc.bridgePremium + ' = ' + doc.anchorPrice; |                 doc.anchorSource = doc.hist.cust.early_season + ' Similar (' + doc.hist.cust.ds + ') Customer Price ' + doc.hist.cust.early_price + ' x ' + doc.bridgePremium + ' = ' + doc.anchorPrice; | ||||||
|  |                 if (doc.targetPrice < doc.anchorPrice) { | ||||||
|  |                     doc.anchorSource = 'Target Price'; | ||||||
|  |                     doc.anchorPrice = doc.targetPrice; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } else { |         } else { | ||||||
|             doc.anchorPrice = doc.hist.cust.early_price; |             doc.anchorPrice = doc.hist.cust.early_price; | ||||||
|             doc.anchorSource = doc.hist.cust.early_season + ' Customer Price ' + doc.hist.cust.early_price; |             doc.anchorSource = doc.hist.cust.early_season + ' Customer Price ' + doc.hist.cust.early_price; | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         doc.anchorPrice = null; |         doc.anchorPrice = doc.targetPrice; | ||||||
|         doc.anchorSource = 'none'; // or any other default value you wish to indicate no anchor price was found
 |         doc.anchorSource = 'Target Price'; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const inflation = Math.max(...Object.keys(doc.iidx).map(Number)); |     const inflation = Math.max(...Object.keys(doc.iidx).map(Number)); | ||||||
| @ -145,10 +151,10 @@ export function apply_guidance(doc: any) { | |||||||
|     if (calcPrice >= doc.list) { |     if (calcPrice >= doc.list) { | ||||||
|         doc.calcCeiling = "Cap At List"; |         doc.calcCeiling = "Cap At List"; | ||||||
|         doc.finalPrice = doc.list; |         doc.finalPrice = doc.list; | ||||||
|         finalReason = `${doc.anchorSource} ${doc.anchorPrice} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`; |         finalReason = `${doc.anchorSource} x ${inflationFactor} = ${calcPrice} but cap at list ${doc.list}`; | ||||||
|     } else { |     } else { | ||||||
|         doc.finalPrice = calcPrice; |         doc.finalPrice = calcPrice; | ||||||
|         finalReason = `${doc.anchorSource} ${doc.anchorPrice} x ${inflationFactor} = ${calcPrice}`; |         finalReason = `${doc.anchorSource} x ${inflationFactor} = ${calcPrice}`; | ||||||
|     } |     } | ||||||
|     doc.finalReason = finalReason; |     doc.finalReason = finalReason; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user