Rounding Concept

199 views
Skip to first unread message

norber...@multimageweb.com

unread,
Dec 10, 2015, 6:22:28 AM12/10/15
to iDempiere, Michal Žilinčár
hi,

i need to setup the following scenario

A. cost rounding 5 decimal
B. tax rounding 2 decimal
C. doc unit price 5 decimal
D. doc line  - row amt 2 decimal
E. total 0 decimal

atm looks me that is not possible. i'm able to setup for A. costs 5 decimal places, C document(from pricelist) but B, D,E is rounded based on standard precision(including accounting dec. places)
if i'm right we miss: Tax Rounding, D Row Amt Rounding El Total Rounding.

also payment term, doctype dependency missing. (e.g. POS invoices could be rounded to 2 dec places but Regular Credit/Bank Transfer could be up to 5 dec places.

any experience ?
norbert



Daniel Tamm

unread,
Dec 10, 2015, 7:01:00 AM12/10/15
to idem...@googlegroups.com
Rounding is a constant recurring issue for my clients.

What I normally do is to just create a document validator that rounds based on specific rules (such as round to zero decimals on all SEK sales invoices).

Sometimes I mark sales pricelists as "use rounding" and sometimes I just hard code as in below example (ROUNDING_CHARGE is defined outside the code example):

    @Override
    public String docValidate(PO po, int timing) {
       
        if (po instanceof X_C_Invoice) {
       
            if (timing==ModelValidator.TIMING_BEFORE_COMPLETE) {
               
                MInvoice invoice = (MInvoice)po;
                // Never round non-sales invoices
                if (!invoice.isSOTrx())
                    return null;
               
                if (!"SEK".equals(invoice.getC_Currency().getISO_Code())) {
                    return null;
                }
               
                double grandTotal = invoice.getGrandTotal().doubleValue();
               
                double rounded = Math.round(grandTotal);
               
                if (rounded!=grandTotal) {
                    double roundWith = rounded - grandTotal;
                    MInvoiceLine il = new MInvoiceLine(invoice.getCtx(), 0, invoice.get_TrxName());
                    il.setC_Invoice_ID(invoice.get_ID());
                    il.setQty(1);
                    il.setC_Charge_ID(ROUNDING_CHARGE);
                    roundWith = Math.round(roundWith * 100) / 100.0;
                    il.setPrice(BigDecimal.valueOf(roundWith));
                    il.saveEx();
                    invoice.setGrandTotal(BigDecimal.valueOf(rounded));
                }
               
            }
           
        }
       
        return null;
    }

A good standardized concept for this would be great to have out of the box in iDempiere.

/Daniel
This e-mail is confidential and may contain legally privileged information. It is intended only for the addressees and may not be reviewed or used in any way by other recipients. If you have received this e-mail in error, kindly notify us immediately by telephone or e-mail and delete the message and any attachments thereto from your system. --
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/303e2deb-6580-48b9-b1a5-bebda9a0b31b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
--
Notima AB
Lärjungevägen 6
SE-136 69 Vendelsö
Tel: +46 8 776 31 30
Web: http://www.notima.se/
--
Reply all
Reply to author
Forward
0 new messages