예제 #1
0
        private TransactionBrutoTotals calculateBruto()
        {
            TransactionBrutoTotals res = new TransactionBrutoTotals();

            foreach (var line in TransLines)
            {
                var taxDueForLine = Utils.GetSaleTaxDue(line.LineTotal, line.TaxRate, TaxMethod);

                res.TotalItems += line.Qty;
                if (TaxMethod == TaxMethods.AddTax)
                {
                    res.TotalAmountWithoutTax += line.LineTotal;
                    res.TotalAmountWithTax    += (line.LineTotal + taxDueForLine);
                }
                else
                {
                    res.TotalAmountWithoutTax += (line.LineTotal - taxDueForLine);
                    res.TotalAmountWithTax    += line.LineTotal;
                }

                res.TotalLines++;
                res.LastLine = line.LineID > res.LastLine ? line.LineID : res.LastLine;

                var c = res.TaxGroupsCalculatedFromItems.Find(x => x.TaxRate == line.TaxRate);
                if (c == null)
                {
                    c = new TaxRateGroup(line.TaxRate);
                    res.TaxGroupsCalculatedFromItems.Add(c);
                }

                c.TotalTax += taxDueForLine;
            }
            return(res);
        }
예제 #2
0
        private static void addToRateGroup(IDictionary <decimal, TaxRateGroup> target, TaxRateGroup codeGroup,
                                           int factor)
        {
            TaxRateGroup trg;

            if (false == target.TryGetValue(codeGroup.TaxRate, out trg))
            {
                target[codeGroup.TaxRate] = trg = new TaxRateGroup(codeGroup.TaxRate);
            }

            trg.TotalWithTax    += codeGroup.TotalWithTax * factor;
            trg.TotalTax        += codeGroup.TotalTax * factor;
            trg.TotalWithoutTax += codeGroup.TotalWithoutTax * factor;
        }