SalesFormLetter – nu facturez liniile cu valoare zero

Lasă un comentariu

19 Mai 2010 de liviustoica55


protected boolean  createParmLine(SalesLine         _salesLineOrig,
                                  TradeLineRefId    _tableRef       = '')
{
    PurchParmLine   purchParmLine;
    SalesParmLine   localSalesParmLine;
    boolean         lineCreated = false;
    // <GIN>
    RealBase        factor;
    // </GIN>

    boolean         createLine;
    ;
    if (_salesLineOrig.RecId && this.checkCreateParmLine(_salesLineOrig))
    {
        this.interCompanyUpdateSalesPrice(_salesLineOrig);

        localSalesParmLine.clear();

        if (interCompanyParmId
        && !this.interCompanyParmSelectFromJournal())
        {
            localSalesParmLine.Closed = this.interCompanyParmLineClosed(_salesLineOrig);
            [localSalesParmLine.DeliverNow, localSalesParmLine.RemainBefore      , localSalesParmLine.RemainAfter]        = this.qtySales  (_salesLineOrig, this.interCompanyParmLineQty(_salesLineOrig));
            [localSalesParmLine.InventNow , localSalesParmLine.RemainBeforeInvent, localSalesParmLine.RemainAfterInvent]  = this.qtyInvent (_salesLineOrig, this.interCompanyParmLineQty(_salesLineOrig, true));
            salesLine.SalesDeliverNow = localSalesParmLine.DeliverNow;
            salesLine.setInventDeliverNow();
            if (localSalesParmLine.Closed)
            {
                localSalesParmLine.RemainAfter = 0;
                localSalesParmLine.setRemainAfterInvent();
            }
        }
        else
        {
            [localSalesParmLine.DeliverNow, localSalesParmLine.RemainBefore      , localSalesParmLine.RemainAfter      ]   = this.qtySales  (_salesLineOrig, naReal());
            [localSalesParmLine.InventNow , localSalesParmLine.RemainBeforeInvent, localSalesParmLine.RemainAfterInvent]   = this.qtyInvent (_salesLineOrig, naReal());

            if ((_salesLineOrig.DeliveryType == TradeLineDlvType::DropShip) && parmIdSynched)
            {
                purchParmLine = PurchParmLine::findInventTransId(parmIdSynched,_salesLineOrig.InventRefTransId);

                if (purchParmLine.Closed)
                {
                    localSalesParmLine.Closed = purchParmLine.Closed;
                    localSalesParmLine.RemainAfter = 0;
                    localSalesParmLine.setRemainAfterInvent();
                }

            }
        }

        // Kumon: Invoice layout - begin
        // For mexic invoice: don't show the sales lines with amount zero
        if(KUMParameters::useInvoiceLayouts() && (CompanyInfo::invoiceFormat() == KUMInvoiceFormat::Mexic))
        {
            createLine = ((localSalesParmLine.DeliverNow || (localSalesParmLine.RemainBefore && backorder)) && _salesLineOrig.LineAmount);
        }
        else
        {
            createLine = (localSalesParmLine.DeliverNow || (localSalesParmLine.RemainBefore && backorder));
        }

        // Delete original condition
        //  if (localSalesParmLine.DeliverNow || (localSalesParmLine.RemainBefore && backorder))
        if(createLine)
        // Kumon: Invoice layout - end

        {
            localSalesParmLine.ParmId     = salesParmUpdate.ParmId;
            localSalesParmLine.initFromSalesLine(_salesLineOrig);
            localSalesParmLine.setLineAmount(_salesLineOrig);
            localSalesParmLine.calcPackingUnitQty();
            localSalesParmLine.TableRefId = _tableRef;

            // <GIN>
            if (TaxParameters::checkTaxParameters_IN())
            {
                if (_salesLineOrig.SalesQty != 0)
                {
                    factor = _salesLineOrig.AssessableValue_IN / _salesLineOrig.SalesQty;
                    localSalesParmLine.AssessableValue_IN = factor * localSalesParmLine.DeliverNow;
                }
            }
            // </GIN>

//RecId is needed if salesParmSubLines is going to be created.
            localSalesParmLine.RecId  = systemSequence.reserveValues(1,tablenum(SalesParmLine));

            salesParmLineMap.insert(this.salesParmLineMapKey(localSalesParmLine.OrigSalesId,localSalesParmLine.InventTransId),localSalesParmLine);
            recordInsertSalesParmLine.add(localSalesParmLine);

            lineCreated = true;

            this.allowCreateParmTable(true);

            #if.never //#Speedtest
            if (speedExecute_Sales)
                speedExecute_Sales.timing(SpeedSalesTiming::ParmLineInsert, strfmt(salesParmLine.parmId, salesParmLine.itemId));
            #endif
        }
    }

    return lineCreated;
}

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: