Misc. charges bug

I noticed a bug in the routine for printing out misc. charges on the SalesInvoice_SE document. The problem is that the label that are printed is always “Amount currency”, and the routine doesn’t calculate the amount correctly when the category is set to Pcs or Percent. I Haven’t tested if the SalesInvoice document has the same problem, but the markupSpec method seams to have the same errors so I think it shares the same problems.

bug description:

As shown below the executeSection method is trying to set the labelvalue to markupTrans.Txt

1
2
3
4
5
6
7
8
9
10
public void executeSection()
{
    ReportRealControl       markupValue;
    ReportSection           markupGroup;
    ;
 
    markupValue = this.controlNo(1);
    markupValue.label(markupTrans.Txt);
 
[....]

And the showMarkupValue method is trying to do calculate the amount depending on what MarkupCategory has been set.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
display AmountCur showMarkupValue()
{
    if (markupTrans.ModuleCategory == HeadingLine::Linie)
    {
        if (markupTrans.MarkupCategory == 
            MarkupCategory::Fixed)
        {
            return markupTrans.Value;
        }
 
        if (markupTrans.MarkupCategory == 
            MarkupCategory::Percent)
        {
            return (custInvoiceTrans.LineAmount + 
                    custInvoiceTrans.LineAmountTax) *  
                    markupTrans.Value / 100;
        }
 
        return custInvoiceTrans.Qty * markupTrans.Value;
    }
    else
    {
[....]

This would all be fine if the markupSpec method had sent the correct information which both of these methods are expecting to recive. The problem is that it doesn’t, .Txt and .MarkupCategory is never sent from it which is causing this bug.

solution: (Mine anyway)

First of all the tmpMarkupTrans table needs to have the fields “Txt” and “MarkupCategory” added. Below you can see what changes are needed in the code, I have made comments where I have changed the standard code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private void markupSpec()
[....]
 
tmpMarkupTrans.TransTableId = markupTrans.TransTableId;
tmpMarkupTrans.TransRecId     = markupTrans.TransRecId;
tmpMarkupTrans.LineNum        = markupTrans.LineNum;
tmpMarkupTrans.MarkupCode     = markupTrans.MarkupCode;
tmpMarkupTrans.MarkupValue    = markupTrans.Value;
tmpMarkupTrans.TaxGroup       = markupTrans.TaxGroup;
tmpMarkupTrans.TaxItemGroup   = markupTrans.TaxItemGroup;
// START  FO/OC
// -- The new fields need to be asign values from the  
//     markupTrans table
tmpMarkupTrans.Txt            = markupTrans.Txt;
tmpMarkupTrans.MarkupCategory = markupTrans.MarkupCategory;
// END  FO/OC 
[....]
1
2
3
4
5
6
7
8
9
10
11
[....]
// START  FO/OC
// -- The new fields must also be added to the select query
while select SalesId, MarkupCode, TaxGroup, TaxItemGroup,
             MarkupCategory, Txt, 
             sum(MarkupValue) from tmpMarkupTrans
group by SalesId, MarkupCode, TaxGroup, TaxItemGroup, 
         MarkupCategory, Txt
where tmpMarkupTrans.SalesId == custInvoiceJour.SalesId
// END  FO/OC
[....]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[....]
 
// START FO/OC 
// -- We need to send markupTrans and not tmpMarkupTrans
//    althought its tmpMarkupTrans that has the data.       
markupTrans.Value          = tmpMarkupTrans.MarkupValue;
markupTrans.TaxGroup       = tmpMarkupTrans.TaxGroup;
markupTrans.TaxItemGroup   = tmpMarkupTrans.TaxItemGroup;
markupTrans.MarkupCode     = tmpMarkupTrans.MarkupCode;
markupTrans.Txt            = tmpMarkupTrans.Txt;
markupTrans.MarkupCategory = tmpMarkupTrans.MarkupCategory;
// END  FO/OC
this.send(MarkupTrans);
 
[....]

These changes need to be done on the other select querys in the method aswell but I hope you get the point.

Last 5 posts in Bugs

Leave a Reply

Your email address will not be published. Required fields are marked *