瀏覽代碼

Added rounding for timberline posters

Kenric Nugteren 9 月之前
父節點
當前提交
17a1242d6b

+ 71 - 66
prs.shared/Posters/Timberline/BillTimberlinePoster.cs

@@ -349,13 +349,19 @@ public class BillTimberlinePoster : ITimberlinePoster<Bill, BillTimberlineSettin
 
         foreach (var bill in bills)
         {
+            if(bill.Number.Length > 15)
+            {
+                result.AddFailed(bill, "Bill Number cannot be more than 15 digits in length.");
+                continue;
+            }
+
             var apif = new BillTimberlineHeader
             {
                 Vendor = bill.SupplierLink.Code,
                 Invoice = bill.Number,
                 Description = bill.Description,
-                Amount = bill.IncTax,
-                Tax = bill.Tax,
+                Amount = Math.Round(bill.IncTax, 4),
+                Tax = Math.Round(bill.Tax, 4),
                 // DiscountOffered
                 // Misc. Deduction
                 InvoiceDate = bill.BillDate,
@@ -375,80 +381,79 @@ public class BillTimberlinePoster : ITimberlinePoster<Bill, BillTimberlineSettin
             if (!ProcessHeader(model, bill, apif))
             {
                 result.AddFailed(bill, "Failed by script.");
+                continue;
             }
-            else
+
+            var success = true;
+            var billLines = lines.GetValueOrDefault(bill.ID) ?? new List<BillLine>();
+            foreach (var billLine in billLines)
             {
-                var success = true;
-                var billLines = lines.GetValueOrDefault(bill.ID) ?? new List<BillLine>();
-                foreach (var billLine in billLines)
+                var apdf = new BillTimberlineDistribution
                 {
-                    var apdf = new BillTimberlineDistribution
-                    {
-                        // Equipment
-                        // EQ Cost Code
-                        // Extra
-                        // Cost Code
-                        // Category
-                        /// BL STd Item
-                        // Reserved
-                        ExpenseAccount = billLine.PurchaseGL.Code,
-                        // AP Account
-                        // Taxable Payments
-                        TaxGroup = billLine.TaxCode.Code,
-                        Amount = billLine.IncTax,
-                        Tax = billLine.Tax,
-                        // Tax Liability
-                        // Discount OFfered
-                        // Retainage
-                        // MIsc Deduction
-                        // Tax Payments Exempt
-                        // Dist Code
-                        // Misc Entry 1
-                        // Misc Units 1
-                        // Misc Entry 2
-                        // Misc Units 2
-                        // Meter
-                        Description = billLine.Description,
-                        // Authorization
-                        // Joint Payee
-                    };
-                    if (purchaseOrderItems.TryGetValue(billLine.OrderItem.ID, out var poItem))
-                    {
-                        apdf.Commitment = poItem.PurchaseOrderLink.PONumber;
-                        apdf.Job = poItem.Job.JobNumber;
-                        if (int.TryParse(poItem.PostedReference, out var itemNumber))
-                        {
-                            apdf.CommitmentLineItem = itemNumber;
-                            billLine.PostedReference = poItem.PostedReference;
-                        }
-                        apdf.Units = poItem.Qty;
-                        apdf.UnitCost = poItem.Cost;
-                        apdf.Description = poItem.Description.NotWhiteSpaceOr(apdf.Description);
-                    }
-                    else
-                    {
-                        apdf.Job = billLine.Job.JobNumber;
-                    }
-
-                    if (!ProcessLine(model, billLine, apdf))
-                    {
-                        success = false;
-                        break;
-                    }
-                    apif.Distributions.Add(apdf);
-                }
-                if (success)
+                    // Equipment
+                    // EQ Cost Code
+                    // Extra
+                    // Cost Code
+                    // Category
+                    /// BL STd Item
+                    // Reserved
+                    ExpenseAccount = billLine.PurchaseGL.Code,
+                    // AP Account
+                    // Taxable Payments
+                    TaxGroup = billLine.TaxCode.Code,
+                    Amount = Math.Round(billLine.IncTax, 4),
+                    Tax = Math.Round(billLine.Tax, 4),
+                    // Tax Liability
+                    // Discount OFfered
+                    // Retainage
+                    // MIsc Deduction
+                    // Tax Payments Exempt
+                    // Dist Code
+                    // Misc Entry 1
+                    // Misc Units 1
+                    // Misc Entry 2
+                    // Misc Units 2
+                    // Meter
+                    Description = billLine.Description,
+                    // Authorization
+                    // Joint Payee
+                };
+                if (purchaseOrderItems.TryGetValue(billLine.OrderItem.ID, out var poItem))
                 {
-                    foreach(var billLine in billLines)
+                    apdf.Commitment = poItem.PurchaseOrderLink.PONumber;
+                    apdf.Job = poItem.Job.JobNumber;
+                    if (int.TryParse(poItem.PostedReference, out var itemNumber))
                     {
-                        result.AddFragment(billLine);
+                        apdf.CommitmentLineItem = itemNumber;
+                        billLine.PostedReference = poItem.PostedReference;
                     }
-                    result.AddSuccess(bill, apif);
+                    apdf.Units = Math.Round(poItem.Qty, 4);
+                    apdf.UnitCost = Math.Round(poItem.Cost, 4);
+                    apdf.Description = poItem.Description.NotWhiteSpaceOr(apdf.Description);
                 }
                 else
                 {
-                    result.AddFailed(bill, "Failed by script.");
+                    apdf.Job = billLine.Job.JobNumber;
+                }
+
+                if (!ProcessLine(model, billLine, apdf))
+                {
+                    success = false;
+                    break;
+                }
+                apif.Distributions.Add(apdf);
+            }
+            if (success)
+            {
+                foreach(var billLine in billLines)
+                {
+                    result.AddFragment(billLine);
                 }
+                result.AddSuccess(bill, apif);
+            }
+            else
+            {
+                result.AddFailed(bill, "Failed by script.");
             }
         }
         return result;

+ 3 - 3
prs.shared/Posters/Timberline/PurchaseOrderTimberlinePoster.cs

@@ -328,10 +328,10 @@ public class Module
                             CostCode = purchaseOrderItem.CostCentre.Code,
                             //Category = purchaseOrderItem.cat
                             TaxGroup = purchaseOrderItem.TaxCode.Code,
-                            Units = purchaseOrderItem.Qty,
-                            UnitCost = purchaseOrderItem.Cost,
+                            Units = Math.Round(purchaseOrderItem.Qty, 4),
+                            UnitCost = Math.Round(purchaseOrderItem.Cost, 4),
                             UnitDescription = purchaseOrderItem.Dimensions.UnitSize,
-                            Amount = purchaseOrderItem.IncTax,
+                            Amount = Math.Round(purchaseOrderItem.IncTax, 4),
                             // BoughtOut
                         };
 

+ 3 - 3
prs.shared/Posters/Timberline/StockMovementTimberlinePoster.cs

@@ -298,8 +298,8 @@ public class StockMovementTimberlinePoster : ITimberlinePoster<StockMovement, St
                 Extra = "",
                 CostCode = product.CostCentre.Code,
                 Category = "",
-                Units = movement.Units,
-                UnitCost = movement.Cost,
+                Units = Math.Round(movement.Units, 4),
+                UnitCost = Math.Round(movement.Cost, 4),
                 TransactionType = StockMovementTimberlineTransactionType.IVCost
             };
             return ModifyLine(directCost, movement);
@@ -312,7 +312,7 @@ public class StockMovementTimberlinePoster : ITimberlinePoster<StockMovement, St
             line.TransactionDate = movement.Date;
             line.AccountingDate = movement.Date;
             line.Description = product.Name;
-            line.Amount = movement.Value;
+            line.Amount = Math.Round(movement.Value, 4);
             line.CreditAccount = product.PurchaseGL.Code;
             line.DebitAccount = product.SellGL.Code;
             return line;