I've done a plugin which works out the gross profit %.
It's quite easy. Just created a custom field on the line. This is the crux of the code:
- Code: Select all
private void SalesOrderLineChanged(object sender, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine line, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!line.CommentLine && line.CostIn != 0)
{
decimal GP = (line.DiscountedPrice - line.CostIn)/line.DiscountedPrice * 100;
line.CustomFieldValues.get_ItemFromSettingName("SOGP%").Contents = GP.ToString();
}
}
and (for the whole order)
- Code: Select all
private void ShowOrderGP(object sender, System.EventArgs e)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesorder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
decimal GP = 0;
decimal totalcost = 0;
foreach(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine line in salesorder.SalesOrderLines)
{
totalcost += line.LastCost*line.QuantityThisDelivery;
}
GP = (salesorder.SalesOrderLines.ExGSTTotal-totalcost)/salesorder.SalesOrderLines.ExGSTTotal * 100;
}
After the GP has been calculated, you can chuck it in a custom field, or maybe on the Reference, or where ever you want.