Created
November 16, 2012 13:22
-
-
Save sauntimo/4087322 to your computer and use it in GitHub Desktop.
Calculating Costs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Declined = false; | |
| if(Notice < 3){ | |
| Declined = true; | |
| } else if (Notice <6){ | |
| NewSubmission["Notice"] = Notice.toString() + " days - £5 Fast track surcharge"; | |
| } else { | |
| NewSubmission["Notice"] = Notice.toString() + " days - No surcharge"; | |
| } | |
| // Extract the cost from the description string | |
| var CakeCost = parseInt(NewSubmission["Size"].slice(NewSubmission["Size"].indexOf("£")+1),10); | |
| var DeliveryCost = (NewSubmission["Delivery"].slice(0,8) == "Delivery") ? 3 : 0; | |
| var FastTrackCost = (Notice < 6) ? 5 : 0; | |
| // Add all chargeable elements | |
| var TotalCost = CakeCost + DeliveryCost + FastTrackCost; | |
| // Display as text for humans to read | |
| NewSubmission["Total Cost"] = "£" + TotalCost.toFixed(2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment