0
votes

I've been looking for a method on the chart to achieve this, but I don't know where to start. I need someone to tell me with what event I can achieve what is stated.

  1. In any given day or week, there may be multiple deliveries or pickups of material that become sales orders for a customer that reference different Projects. Customer A has 5 sales orders in a week with same location, Terms and tax zone and no PO/Customer Order Nbr. 2 are for Project 1234 and 3 are for Project 5678. When we process for “Prepare Invoice” we need 2 invoices created, 1 for Project 1234 and 1 for Project 5678. Current logic would create one invoice for all 5 orders.

Thanks in advance.

enter image description here

1

1 Answers

0
votes

If you do a bit of investigation, you'll notice a couple things.

First, Orders is the grid data view.

enter image description here

Browsing the source code for that screen, you'll notice that that data view has a data view delegate called orders with the line below:

    public virtual IEnumerable orders()
    {
        // ... //
        PXSelectBase<SOOrder> cmd = GetSelectCommand(filter);
        // ... //
    }

The method GetSelectCommand(filter) is defined like this:

    protected virtual PXSelectBase<SOOrder> GetSelectCommand(SOOrderFilter filter)
    {
        PXSelectBase<SOOrder> cmd;

        switch (filter.Action)
        {
            // ... //
            case WellKnownActions.SOOrderScreen.PrepareInvoice:
                cmd = BuildCommandPrepareInvoice();
                break;
            // ... //
        }

        return cmd;
    }

The method BuildCommandPrepareInvoice() is defined like this, which further filters the orders returned:

    protected virtual PXSelectBase<SOOrder> BuildCommandPrepareInvoice()
    {
        var cmd =
            new PXSelectJoinGroupBy<SOOrder,
                    InnerJoin<SOOrderType, On<SOOrderType.orderType, Equal<SOOrder.orderType>, And<SOOrderType.aRDocType, NotEqual<ARDocType.noUpdate>>>,
                    LeftJoin<Carrier, On<SOOrder.shipVia, Equal<Carrier.carrierID>>,
                    LeftJoin<SOOrderShipment, On<SOOrderShipment.orderType, Equal<SOOrder.orderType>, And<SOOrderShipment.orderNbr, Equal<SOOrder.orderNbr>>>,
                    LeftJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<SOOrderShipment.invoiceType>, And<ARInvoice.refNbr, Equal<SOOrderShipment.invoiceNbr>>>,
                    LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>>>>>>>,
                Where<SOOrder.hold, Equal<boolFalse>, And<SOOrder.cancelled, Equal<boolFalse>,
                    And<Where<Customer.bAccountID, IsNull, Or<Match<Customer, Current<AccessInfo.userName>>>>>>>,
                Aggregate<
                    GroupBy<SOOrder.orderType,
                    GroupBy<SOOrder.orderNbr,
                    GroupBy<SOOrder.approved>>>>>(this);

        if (PXAccess.FeatureInstalled<FeaturesSet.inventory>())
        {
            cmd.WhereAnd<
                Where<Sub<Sub<Sub<SOOrder.shipmentCntr,
                                                                SOOrder.openShipmentCntr>,
                                                                SOOrder.billedCntr>,
                                                                SOOrder.releasedCntr>, Greater<short0>,
                    Or2<Where<SOOrder.orderQty, Equal<decimal0>,
                                And<SOOrder.curyUnbilledMiscTot, Greater<decimal0>>>,
                    Or<Where<SOOrderType.requireShipping, Equal<boolFalse>, And<ARInvoice.refNbr, IsNull>>>>>>();
        }
        else
        {
            cmd.WhereAnd<
                Where<SOOrder.curyUnbilledMiscTot, Greater<decimal0>, And<SOOrderShipment.shipmentNbr, IsNull,
                    Or<Where<SOOrderType.requireShipping, Equal<boolFalse>, And<ARInvoice.refNbr, IsNull>>>>>>();
        }

        return cmd;
    }

I believe you could override this method with one that defines what you're looking for, specifically the last section.

I realize this is not a working answer; however, I hope it is helpful.