Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it be added as a Shipment Status to admin order list as Shipped and Arrived? #782

Closed
suatsuphi opened this issue Aug 12, 2023 · 11 comments
Assignees
Milestone

Comments

@suatsuphi
Copy link
Contributor

Hi,

Can it be added as a Shipment Status to admin order list as Shipped and Arrived? Like Order Status and Payment Status
https://ibb.co/wSN30jC

In addition, despite the shipping arrangement, the Order Status still shows as processing...
https://ibb.co/64fbWt7

Also, can Total Weight be changed manually in the admin shipment edit section? Sometimes it can be kilogram or desi...
https://ibb.co/3YXDH1L

@mgesing mgesing self-assigned this Aug 13, 2023
@mgesing mgesing added this to the 5.1.0 milestone Aug 13, 2023
@mgesing
Copy link
Contributor

mgesing commented Aug 13, 2023

Can it be added as a Shipment Status to admin order list as Shipped and Arrived? Like Order Status and Payment Status

Yes.

In addition, despite the shipping arrangement, the Order Status still shows as processing

Yes, it does. There is one of x shipments shipped. The order is still in processing.... until you set it to complete.

Also, can Total Weight be changed manually in the admin shipment edit section? Sometimes it can be kilogram or desi...

Yes, the numeric value is calculated automatically and could well be made editable by the admin.

@suatsuphi
Copy link
Contributor Author

suatsuphi commented Aug 13, 2023

Do you think it is too exaggerated to add shipping stages to the order status and finally complete it?
https://imgbb.com/64fbWt7

Different shipping companies may use different measurement units for the same product. It seems necessary to set the unit on the basis of cargo (the default can still be, but it can be changed on the basis of cargo), for example, some cargoes calculate in kilograms and some calculate with measurements.
https://imgbb.com/3YXDH1L

@mgesing
Copy link
Contributor

mgesing commented Aug 14, 2023

Do you think it is too exaggerated to add shipping stages to the order status and finally complete it?

I wouldn't do that. There does not necessarily have to be a relationship between the two.

It seems necessary to set the unit on the basis of cargo (the default can still be, but it can be changed on the basis of cargo)...

No. Weights must be maintained consistently based on the base weight unit, otherwise shipping charges cannot be calculated for the total weight.

@suatsuphi
Copy link
Contributor Author

suatsuphi commented Aug 14, 2023

I wouldn't do that. There does not necessarily have to be a relationship between the two.

you are right. After the order is completed, it is considered as the shipping stage.

No. Weights must be maintained consistently based on the base weight unit, otherwise shipping charges cannot be calculated for the total weight.

Of course. What I mean is that some cargo companies use the weight unit. It uses desi, which is one of the box sizes. Desi = (Width cm X Height cm X Height cm) / 3000 = ..... desi
Therefore, depending on the cargo (whether weight or measurement is selected in the cargo), the unit of measurement should come... So a Tracking Company section can be added here.
Note: The price lists of the cargo companies are calculated over kg or desi.

@mgesing
Copy link
Contributor

mgesing commented Aug 14, 2023

I have never heard of a measuring unit called desi before. I think this is too special to be included in the core. It should be implemented via a separate plugin.

@suatsuphi
Copy link
Contributor Author

In Turkey, If the weight of the product is heavy, the cargo company wants to give the prices over the weight. If the weight of the product is light and the dimensions are large, cargo campanies want to use the desi size depending on the size.

Also I can see which cargo was sent via the shipping link. No shipping company... There are Tracking number and Tracking URL. There no Tracking Company

@suatsuphi
Copy link
Contributor Author

Hi,
This manually entered value does not appear in the printout.

Can we add the difference as tare (+/-) plus or minus

https://ibb.co/xjNqsWk

@mgesing
Copy link
Contributor

mgesing commented Aug 21, 2023

You need to extend \Areas\Admin\Views\Shipment\PdfPackagingSlips.Print.cshtml for the total weight to be displayed in the shipment PDF. TotalWeight is already included in ShipmentModel.

@suatsuphi
Copy link
Contributor Author

thanks... can be added to the main project with a few small changes

@using Microsoft.EntityFrameworkCore
@using Smartstore.Core.Data
@using Smartstore.Core.Catalog.Products

@model IEnumerable<ShipmentModel>

@{
    Layout = "_Print";

    ViewBag.Title = T("Admin.Orders.Shipments.ViewDetails");

    var showSku = (bool)ViewBag.ShowSku;
    var pdfMode = ViewBag.PdfMode == true;
    if (!pdfMode)
    {
        Assets.BodyAttributes.AppendCssClass("screen");
    }

    var db = Resolve<SmartDbContext>();
    var countries = await db.Countries.AsNoTracking().ToDictionaryAsync(x => x.Id, x => x);

    HtmlString JoinValues(string[] values, string separator = " ")
    {
        var normalized = values.Where(x => x.HasValue());
        return new HtmlString(string.Join(separator, normalized));
    }

    decimal totalWeight = 0;
}

<div class="container">
    @foreach (var shipment in Model)
    {
        var company = shipment.MerchantCompanyInfo;
        var showGtin = shipment.Items.Any(x => x.Gtin.HasValue());
        var colWidths = new[] { 50, 20, 10 };

        <div class="document">
            <zone name="shipmentdetails_top" model="@shipment"></zone>

            <!-- Address & Info -->
            <div class="clearfix">
                <div class="order-address mt-5 pull-left float-left">
                    <div>
                        <span class="header text-smallest">
                            @{
                                var country = countries.Get(company.CountryId);
                                var countryName = country?.GetLocalized(x => x.Name) ?? string.Empty;
                                var city = JoinValues(new[] { company.ZipCode, company.City }).ToString();
                                var countryAndState = JoinValues(new[] { countryName, company.StateName }, ", ").ToString();
                            }
                            @JoinValues(new[] { company.CompanyName, company.Street, company.Street2, city, countryAndState }, " &middot; ")
                        </span>
                    </div>
                    <div class="mt-2">
                        @Html.Raw(shipment.ShippingAddress.FormattedAddress)
                    </div>
                </div>

                <zone name="shipmentdetails_orderinfo_top" model="@shipment"></zone>

                <div class="order-info text-small float-right">
                    <table>
                        <tr>
                            <td class="label">@T("PDFPackagingSlip.Shipment").Value.FormatInvariant(string.Empty):</td>
                            <td class="value">@shipment.Id</td>
                        </tr>
                        <tr>
                            <td class="label">@T("PDFPackagingSlip.Order").Value.FormatInvariant(string.Empty):</td>
                            <td class="value">@shipment.OrderId</td>
                        </tr>
                        <tr>
                            <td class="label">@T("PDFPackagingSlip.DeliveryDate"):</td>
                            <td class="value">
                                @if (shipment.DeliveryDate.HasValue)
                                {
                                    @shipment.DeliveryDate.Value.ToString()
                                }
                                else
                                {
                                    <span>@T("Admin.Orders.Shipments.DeliveryDate.NotYet")</span>
                                }
                            </td>
                        </tr>
                        <tr sm-if="shipment.TrackingNumber.HasValue()">
                            <td class="label">@T("PDFPackagingSlip.TrackingNumber"):</td>
                            <td class="value">@shipment.TrackingNumber</td>
                        </tr>
                        <tr>
                            <td class="label">@T("PDFPackagingSlip.ShippingMethod"):</td>
                            <td class="value">@shipment.ShippingMethod</td>
                        </tr>
                    </table>

                    <zone name="shipmentdetails_orderinfotable_after" model="@shipment"></zone>
                </div>
                <zone name="shipmentdetails_orderinfo_bottom" model="@shipment"></zone>
            </div>

            <zone name="shipmentdetails_lines_before" model="@shipment"></zone>

            <h3 style="margin-top: 100px">@T("PDFPackagingSlip.ProductListHeadline")</h3>

            <div class="table-responsive">
                <table class="table order-summary">
                    <thead>
                        <tr>
                            <th class="text-left" style="width: @(colWidths[0])%">@T("PDFPackagingSlip.ProductName")</th>
                            <th sm-if="showSku" class="text-left" style="width: @(colWidths[2])%">@T("PDFPackagingSlip.SKU")</th>
                            <th sm-if="showGtin" class="text-left" style="width: @(colWidths[2])%">@T("PDFPackagingSlip.Gtin")</th>
                            <th class="text-center" style="width: @(colWidths[2])%">@T("PDFPackagingSlip.QTY")</th>
                            <th class="text-right" style="width: @(colWidths[1])%">@T("PDFPackagingSlip.Weight")</th>
                        </tr>
                    </thead>
                    @foreach (var item in shipment.Items)
                    {
                        totalWeight += decimal.Parse(item.ItemWeight.Split("[")[0].Trim());
                        <tbody>
                            <tr>
                                <td class="text-left">
                                    <span>@item.ProductName</span>
                                    <div sm-if="item.AttributeInfo.HasValue()" class="attributes text-small">
                                        @Html.Raw(item.AttributeInfo)
                                    </div>
                                </td>
                                <td sm-if="showSku" class="text-left">
                                    @item.Sku
                                </td>
                                <td sm-if="showGtin" class="text-left">
                                    @item.Gtin
                                </td>
                                <td class="text-center">
                                    @item.QuantityInThisShipment
                                </td>
                                <td class="text-right">
                                    @item.ItemWeight
                                </td>
                            </tr>
                            @if (item.ProductType == ProductType.BundledProduct)
                            {
                                foreach (var bundleItem in item.BundleItems.OrderBy(x => x.DisplayOrder))
                                {
                                    <tr class="child-row">
                                        <td>
                                            <div class="associated-product">
                                                <div dir="auto">@bundleItem.ProductName</div>
                                                <div sm-if="bundleItem.AttributeInfo.HasValue()" class="attributes text-small">
                                                    @Html.Raw(bundleItem.AttributeInfo)
                                                </div>
                                            </div>
                                        </td>
                                        <td sm-if="showSku">&nbsp;</td>
                                        <td sm-if="showGtin">&nbsp;</td>
                                        <td class="text-center text-small">
                                            @(item.BundlePerItemShoppingCart ? bundleItem.Quantity.ToString() : "&nbsp;")
                                        </td>
                                        <td>&nbsp;</td>
                                    </tr>
                                }
                            }
                        </tbody>
                    }
                    <tbody>
                        @if (totalWeight != shipment.TotalWeight)
                        {
                            <tr>
                                <td class="text-left">
                                </td>
                                <td sm-if="showSku" class="text-left">
                                </td>
                                <td sm-if="showSku" class="text-left">
                                </td>
                                <td class="text-right border-bottom" style="min-width: 100px;">
                                    <b>@T("PDFPackagingSlip.Tare")</b>
                                </td>
                                <td class="text-right text-bg-light">
                                    <b>@((shipment.TotalWeight.Value - totalWeight).ToString("N2")) [@shipment.BaseWeight]</b>
                                </td>
                            </tr>
                        }
                        <tr>
                            <td class="text-left">
                            </td>
                            <td sm-if="showSku" class="text-left">
                            </td>
                            <td sm-if="showSku" class="text-left">
                            </td>
                            <td class="text-right border-bottom" style="min-width: 100px;">
                                <b>@T("PDFPackagingSlip.TotalWeight")</b>
                            </td>
                            <td class="text-right text-bg-light">
                                <b>@shipment.TotalWeight.Value.ToString("N2") [@shipment.BaseWeight]</b>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    }
</div>

@suatsuphi
Copy link
Contributor Author

Hi, mgesing,

if there is no transportation record, can it be created as a blank record? for ship
a new shipment to order
admin/shipment/create/?orderId=*

                        case "ship":
                        case "deliver":
                            if (o.ShippingStatus != ShippingStatus.ShippingNotRequired && o.ShippingAddressId != 0)
                            {
                                var ship = operation == "ship";
                                if (o.Shipments.Count > 0)
                                {
                                    foreach (var shipment in o.Shipments)
                                    {
                                        if (ship && shipment.ShippedDateUtc == null)
                                        {
                                            await _orderProcessingService.ShipAsync(shipment, true);
                                        }
                                        else if (!ship && shipment.ShippedDateUtc != null && shipment.DeliveryDateUtc == null)
                                        {
                                            await _orderProcessingService.DeliverAsync(shipment, true);
                                        }
                                    }

                                    ++numSuccess;
                                    succeededOrderNumbers.Add(o.GetOrderNumber());
                                }
                                else
                                {
                                    ++numSkipped;
                                }
                            }
                            else
                            {
                                ++numSkipped;
                            }
                            break;

@suatsuphi
Copy link
Contributor Author

I have prepared the relevant section. if there is no record and the status is marked as shipped, record is ok.

case "ship":
case "deliver":
if (o.ShippingStatus != ShippingStatus.ShippingNotRequired && o.ShippingAddressId != 0)
{
    var ship = operation == "ship";
    if (o.Shipments.Count > 0)
    {
        foreach (var shipment in o.Shipments)
        {
            if (ship && shipment.ShippedDateUtc == null)
            {
                await _orderProcessingService.ShipAsync(shipment, true);
            }
            else if (!ship && shipment.ShippedDateUtc != null && shipment.DeliveryDateUtc == null)
            {
                await _orderProcessingService.DeliverAsync(shipment, true);
            }
        }

        ++numSuccess;
        succeededOrderNumbers.Add(o.GetOrderNumber());
    }
    else
    {
        if(ship)
        {
            var order = await _db.Orders.IncludeCustomer(true)
                                        .IncludeOrderItems()
                                        .IncludeShipments()
                                        .FindByIdAsync(o.Id);
            if (order == null)
            {
                ++numSkipped;
            }
            else
            {
                var quantities = new Dictionary<int, int>();
                foreach (var orderItem in order.OrderItems)
                {
                    quantities.Add(orderItem.Id, orderItem.Quantity);
                }

                var shipmentRecord = await _orderProcessingService.AddShipmentAsync(order, "", "", quantities);
                if (shipmentRecord != null)
                {
                    Services.ActivityLogger.LogActivity(KnownActivityLogTypes.EditOrder, T("ActivityLog.EditOrder"), order.GetOrderNumber());
                    foreach (var shipment in o.Shipments)
                    {
                        if (ship && shipment.ShippedDateUtc == null)
                        {
                            await _orderProcessingService.ShipAsync(shipment, true);
                        }
                    }

                    ++numSuccess;
                    succeededOrderNumbers.Add(o.GetOrderNumber());
                }
                else
                {
                    ++numSkipped;
                }
            }
        }
        else
        {
            ++numSkipped;
        }
    }
}
else
{
    ++numSkipped;
}
break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants