Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Purchasing.Mvc/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ public async Task<ActionResult> Review(int id)
{
return ViewHelper.NotAuthorized(Resources.Authorization_PermissionDenied);
}

await _orderService.TryPopulatePoNumberFromAggieEnterprise(model.Order);

model.Vendor = _repositoryFactory.OrderRepository.Queryable.Where(x=>x.Id == id).Select(x=>x.Vendor).Single();
if(model.Vendor != null && !string.IsNullOrWhiteSpace( model.Vendor.AeSupplierNumber ))
Expand Down
33 changes: 33 additions & 0 deletions Purchasing.Mvc/Services/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public interface IOrderService
/// <returns>String array of error messages, non-empty if completion didn't succeed</returns>
Task<string[]> Complete(Order order, OrderType newOrderType, string kfsDocType = null);

Task<bool> TryPopulatePoNumberFromAggieEnterprise(Order order);

/// <summary>
/// Get the current user's list of orders.
/// </summary>
Expand Down Expand Up @@ -648,6 +650,37 @@ public async Task<string[]> Complete(Order order, OrderType newOrderType, string
return new string[0]; //return no errors
}

public async Task<bool> TryPopulatePoNumberFromAggieEnterprise(Order order)
{
try
{
if (order.StatusCode?.Id != OrderStatusCode.Codes.Complete ||
order.OrderType?.Id?.Trim() != OrderType.Types.AggieEnterprise ||
string.IsNullOrWhiteSpace(order.ReferenceNumber) ||
!string.IsNullOrWhiteSpace(order.PoNumber))
{
return false;
}

var status = await _aggieEnterpriseService.LookupOrderStatus(order.ReferenceNumber.Trim());
if (string.IsNullOrWhiteSpace(status?.PoNumber))
{
return false;
}

order.PoNumber = status.PoNumber.Trim();
_eventService.OrderUpdated(order, $"PO # automatically populated from Aggie Enterprise: {order.PoNumber}");
_orderRepository.EnsurePersistent(order);

return true;
}
catch (Exception ex)
{
//swallow it.
return false;
}
}

/// <summary>
/// Duplicates the given order info a new order, one that doesn't include the splits, approvals, or history of the given order
/// </summary>
Expand Down
35 changes: 11 additions & 24 deletions Purchasing.Mvc/Views/Help/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
</header>

<div class="contents">

<p>Help make PrePurchasing better with your ideas</p>
<ul>
<li>See a suggestion you like? Vote for it!</li>
<li>Make your own suggestions</li>
</ul>
<p>Share ideas and vote for improvements suggested by other users.</p>
</div>

</section>
Expand All @@ -39,9 +34,7 @@
</header>

<div class="contents">

<p>Need some help? Try submitting a ticket to our help desk.</p>

<p>Submit a help ticket for technical problems or unexpected behavior.</p>
</div>

</section>
Expand All @@ -54,28 +47,19 @@
</header>

<div class="contents">

<p>Who should I contact?</p>
<ul>
<li>What Workgroups do you belong to?</li>
<li>Who are the Departmental Admins for those workgroups?</li>
<li>Have a technical questions instead? Try the other help button.</li>
</ul>

<p>Find your workgroups and the departmental admins who support them.</p>
</div>

</section>
<section id="faq" class="container split">
<header>
<a class="button" href="@faqUrl" target="_blank">
Knowledge Base
<a href="@faqUrl" target="_blank">
<img src='@Url.Content("~/Images/knowledgebase.png")' alt="knowledge base"/>
</a>
</header>

<div class="contents">

<p>Try our knowledge base.</p>

<p>Browse guides and answers to common PrePurchasing questions.</p>
</div>

</section>
Expand All @@ -86,7 +70,10 @@
<style type="text/css">
.container { display: inline-block;margin: .5em 0;padding: 1em;}
.split {width: 47%;float: left;}
.container header { margin: auto;padding: 0;color: #014A81; }
.container ul { margin: 0 20px;}
#keeper::after { content: ""; display: block; clear: both; }
.split header, .split .contents { width: 350px; margin-left: auto; margin-right: auto; }
.container header { padding: 0;color: #014A81; }
.split .contents { box-sizing: border-box; margin-top: .75em; padding: 0 .25em; color: #3f4f5a; font-size: .95em; line-height: 1.4; text-align: center; }
.split .contents p { margin: 0; }
</style>
}
4 changes: 2 additions & 2 deletions Purchasing.Mvc/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

</div>

<div id="announce">
@* <div id="announce">

<h2>Aggie Enterprise Announcement!</h2>

Expand All @@ -197,7 +197,7 @@
</p>

<p><a href="https://computing.caes.ucdavis.edu/documentation/purchasing/Aggie-Enterprise-Updates" target="_blank">This FAQ has some updates and useful information.</a></p>
</div>
</div> *@


<div id="browsers">
Expand Down
2 changes: 1 addition & 1 deletion Purchasing.Mvc/Views/Order/_ReviewSubmit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if (Model.IsPurchaser)
{
<div id="status-message">
You may now complete orders in Aggie Enterprise!
August 2026: Aggie Enterprise now supports editing orders uploaded from PrePurchasing. Complete this as Aggie Enterprise to use this feature.
</div>
}
}
Expand Down
13 changes: 13 additions & 0 deletions Purchasing.Mvc/Views/Organization/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
<div class="display-label">Type Name</div>
<div class="display-details">@Model.TypeName</div>
</li>
<li>
<div class="display-label">Parent Org</div>
<div class="display-details">
@if (Model.Parent != null)
{
@Html.ActionLink($"{Model.Parent.Name} ({Model.Parent.Id})", "Details", "Organization", new { id = Model.Parent.Id }, new { })
}
else
{
@:n/a
}
</div>
</li>
<li>
<div class="display-label">Is Active</div>
<div class="display-details">@Model.IsActive</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Purchasing.Core.Domain;
using Purchasing.Core.Models.AggieEnterprise;
using Purchasing.Tests.Core;
using UCDArch.Testing;
using UCDArch.Testing.Extensions;
Expand Down Expand Up @@ -49,5 +50,84 @@ public void TestReRouteSingleApprovalForExistingOrder()
#endregion Assert
}
#endregion ReRouteSingleApprovalForExistingOrder Tests

#region TryPopulatePoNumberFromAggieEnterprise Tests

[TestMethod]
public async System.Threading.Tasks.Task TestTryPopulatePoNumberFromAggieEnterprisePopulatesPoAndAddsHistory()
{
var order = CreateValidEntities.Order(1);
order.StatusCode.Id = OrderStatusCode.Codes.Complete;
order.OrderType = new OrderType(OrderType.Types.AggieEnterprise);
order.ReferenceNumber = " 184e9d20-f759-413e-8f42-06db62bf1e59 ";
order.PoNumber = " ";

Mock.Get(AggieEnterpriseService)
.Setup(a => a.LookupOrderStatus("184e9d20-f759-413e-8f42-06db62bf1e59"))
.ReturnsAsync(new AeResultStatus { PoNumber = " PO123456 " });

var result = await OrderService.TryPopulatePoNumberFromAggieEnterprise(order);

Assert.IsTrue(result);
Assert.AreEqual("PO123456", order.PoNumber);
Mock.Get(EventService).Verify(a => a.OrderUpdated(
order,
"PO # automatically populated from Aggie Enterprise: PO123456"));
Mock.Get(OrderRepository).Verify(a => a.EnsurePersistent(order));
}

[TestMethod]
public async System.Threading.Tasks.Task TestTryPopulatePoNumberFromAggieEnterpriseDoesNothingWhenLookupHasNoPo()
{
var order = CreateValidEntities.Order(1);
order.StatusCode.Id = OrderStatusCode.Codes.Complete;
order.OrderType = new OrderType(OrderType.Types.AggieEnterprise);
order.ReferenceNumber = "184e9d20-f759-413e-8f42-06db62bf1e59";
order.PoNumber = null;

Mock.Get(AggieEnterpriseService)
.Setup(a => a.LookupOrderStatus(order.ReferenceNumber))
.ReturnsAsync(new AeResultStatus { PoNumber = " " });

var result = await OrderService.TryPopulatePoNumberFromAggieEnterprise(order);

Assert.IsFalse(result);
Assert.IsNull(order.PoNumber);
Mock.Get(EventService).Verify(
a => a.OrderUpdated(It.IsAny<Order>(), It.IsAny<string>()),
Times.Never());
Mock.Get(OrderRepository).Verify(a => a.EnsurePersistent(It.IsAny<Order>()), Times.Never());
}

[DataTestMethod]
[DataRow(OrderStatusCode.Codes.Purchaser, OrderType.Types.AggieEnterprise, "184e9d20-f759-413e-8f42-06db62bf1e59", null)]
[DataRow(OrderStatusCode.Codes.Complete, OrderType.Types.KfsDocument, "184e9d20-f759-413e-8f42-06db62bf1e59", null)]
[DataRow(OrderStatusCode.Codes.Complete, OrderType.Types.AggieEnterprise, " ", null)]
[DataRow(OrderStatusCode.Codes.Complete, OrderType.Types.AggieEnterprise, "184e9d20-f759-413e-8f42-06db62bf1e59", "PO123456")]
public async System.Threading.Tasks.Task TestTryPopulatePoNumberFromAggieEnterpriseOnlyLooksUpEligibleOrders(
string statusCode,
string orderType,
string referenceNumber,
string poNumber)
{
var order = CreateValidEntities.Order(1);
order.StatusCode.Id = statusCode;
order.OrderType = new OrderType(orderType);
order.ReferenceNumber = referenceNumber;
order.PoNumber = poNumber;

var result = await OrderService.TryPopulatePoNumberFromAggieEnterprise(order);

Assert.IsFalse(result);
Mock.Get(AggieEnterpriseService).Verify(
a => a.LookupOrderStatus(It.IsAny<string>()),
Times.Never());
Mock.Get(EventService).Verify(
a => a.OrderUpdated(It.IsAny<Order>(), It.IsAny<string>()),
Times.Never());
Mock.Get(OrderRepository).Verify(a => a.EnsurePersistent(It.IsAny<Order>()), Times.Never());
}

#endregion TryPopulatePoNumberFromAggieEnterprise Tests
}
}