|
@@ -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;
|