Top Sales sorted by item and customer.

valkatamakevalkatamake Member Posts: 38
Hi i need a tip for this report
i have to show top sales for item grouped by customer something like this:
Item A
   Customer5 : 400
   customer 2: 250
   customer 3: 200
itemB
   customer2 : 500
   customer 4: 340

So far i have this
Item - OnAfterGetRecord ()

Number1:=0;
ItemLedgerEntry.RESET;
ItemLedgerEntry.SETCURRENTKEY("Source Type","Source No.");
ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::Sale);
ItemLedgerEntry.SETRANGE("Item No.",Item."No.");

IF ItemLedgerEntry.FIND('-') THEN
  REPEAT
   ItemLedgerEntry.SETRANGE("Source No.",ItemLedgerEntry."Source No.");
   Number:= Number +1;
   ItemLedgerEntry.FIND('+');
   ItemLedgerEntry.SETRANGE("Source No.");
  UNTIL ItemLedgerEntry.NEXT=0;

Number2:=0;
ItemLedgerEntry.RESET;
ItemLedgerEntry.SETCURRENTKEY("Source Type","Source No.");
ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::Sale);
ItemLedgerEntry.SETRANGE("Item No.",Item."No.");
IF ItemLedgerEntry.FIND('-') THEN
  REPEAT
      number2:= number2 -ItemLedgerEntry.Quantity; // you know that sales in item ledger entry are negative numbers //
      ItemLedgerEntry.SETRANGE("Source No.");
  UNTIL ItemLedgerEntry.NEXT=0;
ItemAmount.INIT;
ItemAmount."Item No.":= Item."No.";
ItemAmount.Amount:= Number;
ItemAmount."Amount 2":=q1;
ItemAmount.INSERT;

and
Integer - OnPreDateItem()
ItemAmount.RESET;
ItemAmount.SETCURRENTKEY(Amount);
ItemAmount.ASCENDING(FALSE);

Integer - OnAfterGetRecord()
IF Number = 1 THEN ItemAmount.FIND('-')
ELSE ItemAmount.NEXT;
Item.GET(ItemAmount."Item No.");

it count all sales for item .. and sales TO DIFERENT customers ..

Comments

  • AdamRoueAdamRoue Member Posts: 1,283
    What is wrong with the standard Inventory - Customer Sales Report, 713?
    The art of teaching is clarity and the art of learning is to listen
  • valkatamakevalkatamake Member Posts: 38
    too much information in value entry mistakes are very possible in fact i found some
    just want quantity not amounts and other.
Sign In or Register to comment.