Exemple #1
0
        /// <summary> Combine Yusen csv Detail (ORH、ORL、ORA、FTO、FTD)  </summary>
        public virtual (StringBuilder sb, int totalLine) CombineYusenDetailForFBM(StringBuilder sb, List <SOOrder> currtOrders, int totalLine)
        {
            for (int i = 0; i < currtOrders.Count; i++)
            {
                string  line           = string.Empty;
                SOOrder _soOrder       = currtOrders[i];
                var     inventoryItems = SelectFrom <InventoryItem> .View.Select(Base).RowCast <InventoryItem>().ToList();

                var soLines = SelectFrom <SOLine> .Where <SOLine.orderType.IsEqual <P.AsString>
                                                          .And <SOLine.orderNbr.IsEqual <P.AsString> > >
                              .OrderBy <SOLine.lineNbr.Asc>
                              .View.Select(Base, _soOrder.OrderType, _soOrder.OrderNbr).RowCast <SOLine>();

                SOShipmentContact shipContact = SOShipmentContact.PK.Find(Base, _soOrder.ShipContactID);
                SOShipmentAddress shipAddress = SOShipmentAddress.PK.Find(Base, _soOrder.ShipAddressID);

                if (!soLines.Any())
                {
                    throw new Exception("Can not find SOLine");
                }

                #region OrderHeader - ORH
                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "ORH")}";
                line += $"{FillUpLen(8, _soOrder?.OrderDate?.ToString("yyyyMMdd"))}";
                line += $"{FillUpLen(8, _soOrder?.RequestDate?.ToString("yyyyMMdd"))}";
                line += $"L";
                line += $"{FillUpLen(15, _soOrder?.OrderNbr)}";
                line += $"{FillUpLen(20, _soOrder?.CustomerOrderNbr)}";
                line += $"{FillUpLen(11, " ")}";
                line += $"{FillUpLen(40, (_soOrder.OrderDesc?.Length > 40 ? _soOrder?.OrderDesc.Substring(0, 40) : _soOrder?.OrderDesc))}";
                line += $"{FillUpLen(40, (_soOrder.OrderDesc?.Length > 40 ? _soOrder?.OrderDesc.Substring(40) : " "))}";
                line += $"{FillUpLen(5, "DPD")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Physical delivery address – ORL
                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "ORL")}";
                line += $"{FillUpLen(10, " ")}";
                line += $"{FillUpLen(40, shipContact?.FullName)}";
                line += $"{FillUpLen(40, " ")}";
                line += (shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Length > 30 ? $"{(shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Substring(0, 30)}" : $"{FillUpLen(30, (shipAddress?.AddressLine1 + shipAddress?.AddressLine2))}";
                line += $"{FillUpLen(10, shipAddress?.PostalCode)}";
                line += $"{FillUpLen(30, shipAddress?.City)}";
                line += $"{FillUpLen(3, shipAddress?.CountryID)}";
                line += $"{FillUpLen(30, shipContact?.Attention)}";
                line += $"{FillUpLen(20, shipContact?.Phone1)}";
                line += $"{FillUpLen(40, shipContact?.Email)}";
                line += $"{FillUpLen(3, "DE")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Articleline - ORA

                foreach (var item in soLines)
                {
                    line  = string.Empty;
                    line += $"{FillUpLen(10, "YS_OR_V01")}";
                    line += $"{FillUpLen(3, "ORA")}";
                    line += $"{FillUpLen(10, item?.LineNbr.ToString())}";
                    line += $"{FillUpLen(20, inventoryItems?.FirstOrDefault(x => x.InventoryID == item?.InventoryID).InventoryCD)}";
                    line += $"{FillUpLen(11, item?.OpenQty?.ToString())}";
                    line += $"{FillUpLen(25, " ")}";
                    line += $"{FillUpLen(25, " ")}";
                    line += "\r\n";
                    sb.Append(line);
                    totalLine++;
                }

                #endregion

                #region  Free Text Orderpick - FTO

                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "FTO")}";
                line += $"{FillUpLen(40, "")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Free Text Delivery - FTD

                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "FTD")}";
                line += $"{FillUpLen(40, " ")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion
            }
            return(sb, totalLine);
        }
Exemple #2
0
        /// <summary> Gnerate CA/UK csv data for FBM </summary>
        public virtual (StringBuilder csvText, string OrderNbr) CombineCSVForFBM(SOOrder _soOrder, string csvType)
        {
            StringBuilder sb   = new StringBuilder();
            string        line = string.Empty;

            var inventoryItems = SelectFrom <InventoryItem> .View.Select(Base).RowCast <InventoryItem>().ToList();

            var soLines = SelectFrom <SOLine> .Where <SOLine.orderNbr.IsEqual <P.AsString>
                                                      .And <SOLine.orderType.IsEqual <P.AsString> > >
                          .OrderBy <SOLine.lineNbr.Asc>
                          .View.Select(Base, _soOrder.OrderNbr, _soOrder.OrderType).RowCast <SOLine>();

            SOShipmentContact shipContact = SOShipmentContact.PK.Find(Base, _soOrder.ShipContactID);
            SOShipmentAddress shipAddress = SOShipmentAddress.PK.Find(Base, _soOrder.ShipAddressID);

            if (!soLines.Any())
            {
                throw new Exception("Can not find SOLine");
            }

            #region Header
            line += "\"CustomerCode\";\"OrderRefNo\";\"SKUCode\";\"Qty\";\"DeliveryReqDate\";\"ReceiverName\";\"ReceiverCountry\";\"ReceiverCity\";\"ReceiverPostCode\";\"ReceiverAddress\";\"ReceiverPhone\";\"BatchNumber\";\"Notes\"";
            if (csvType == "P3PL")
            {
                line += ";\"CarrierCode\";\"CarrierServiceCode\"";
            }
            sb.AppendLine(line);
            #endregion

            #region Row

            foreach (var item in soLines)
            {
                var _cd = inventoryItems.Where(x => x.InventoryID == item.InventoryID).FirstOrDefault()?.InventoryCD;
                line = string.Empty;
                // CustomerCode
                line += $"\"IPEVOMAN\";";
                // OrderRefNo
                line += $"\"{_soOrder.CustomerOrderNbr}\";";
                // SKUCode
                line += $"\"{_cd}\";";
                // Qty
                line += $"\"{item?.ShippedQty}\";";
                // DeliveryReqDate
                line += $"\"{DateTime.Now.ToString("yyyyMMdd")}\";";
                // ReceiverName
                line += $"\"{shipContact.Attention}/{shipContact.FullName}\";";
                // ReceiverCountry
                line += $"\"{shipAddress.CountryID}\";";
                // ReceiverCity
                line += $"\"{shipAddress.City}\";";
                // ReceiverPostCode
                line += $"\"{shipAddress.PostalCode}\";";
                // ReceiverAddress
                line += $"\"{(shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Replace(',','/')}\";";
                // ReceiverPhone
                line += $"\"{shipContact.Phone1}\";";
                // BatchNumber
                line += $"\"{_soOrder.OrderNbr}\";";
                // Notes
                var note = string.Empty;
                if (_cd == "5-883-4-01-00" || _cd == "5-884-4-01-00")
                {
                    note = "VZ-R(sku#5-883-4-01-00) or VZ-X(sku#5-884-4-01-00) please scan the serial number for us.";
                }
                if (_soOrder?.OrderType == "FM" && !string.IsNullOrEmpty(_soOrder?.OrderDesc))
                {
                    note = _soOrder?.OrderDesc;
                }
                line += $"\"{note}\"";
                if (csvType == "P3PL")
                {
                    line += $";\"{string.Empty}\";\"{string.Empty}\"";
                }
                sb.AppendLine(line);
            }

            #endregion

            return(sb, _soOrder.OrderNbr);
        }