To calculate Miscellaneous charges calculation by code in axapta you can get code hint by below method
AmountCur LineMiscValue;
MarkupTrans markupTrans;
MarkupTable markTable;
while select markupTrans
where markupTrans.TransTableId ==CustInvoiceTrans.TableId
&& markupTrans.TransRecId == CustInvoiceTrans.RecId
join markTable
where markTable.MarkupCode == markupTrans.MarkupCode
&& markTable.ModuleType == ModuleInventCustVend::Cust
{
LineMiscValue = totalLineValue + MarkUp::calcTrans(markupTrans,CustInvoiceTrans.Qty, CustInvoiceTrans.LineAmout);
}
return LineMiscValue