Skip to content

Commit

Permalink
PT-6745: Order returns creation (#2)
Browse files Browse the repository at this point in the history
* Initial commit of returns creation

* Code smells fix

* Code smells fix

* package-lock.json is added

* Quantity validation is fixed

* Search instruments are added to the order selection blade

* Some visual changes

* Code smell fix
  • Loading branch information
getmansky authored Mar 9, 2022
1 parent 2878af2 commit feb392d
Show file tree
Hide file tree
Showing 20 changed files with 816 additions and 2,013 deletions.
6 changes: 6 additions & 0 deletions src/VirtoCommerce.ReturnModule.Core/Models/ReturnLineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public class ReturnLineItem : AuditableEntity, ICloneable

public string OrderLineItemId { get; set; }

public int Quantity { get; set; }

public decimal Price { get; set; }

public string Reason { get; set; }

#region ICloneable members

public virtual object Clone()
Expand Down
19 changes: 18 additions & 1 deletion src/VirtoCommerce.ReturnModule.Core/ModuleConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class General
public static SettingDescriptor ReturnEnabled { get; } = new SettingDescriptor
{
Name = "Return.ReturnEnabled",
GroupName = "Return|General",
GroupName = "Return|Return",
ValueType = SettingValueType.Boolean,
DefaultValue = false
};
Expand All @@ -39,12 +39,21 @@ public static class General
DefaultValue = "qwerty"
};

public static SettingDescriptor ReturnNewNumberTemplate { get; } = new SettingDescriptor
{
Name = "Return.ReturnNewNumberTemplate",
ValueType = SettingValueType.ShortText,
GroupName = "Return|Return",
DefaultValue = "RET{0:yyMMdd}-{1:D5}"
};

public static IEnumerable<SettingDescriptor> AllSettings
{
get
{
yield return ReturnEnabled;
yield return ReturnPassword;
yield return ReturnNewNumberTemplate;
}
}
}
Expand All @@ -56,6 +65,14 @@ public static IEnumerable<SettingDescriptor> AllSettings
return General.AllSettings;
}
}

public static IEnumerable<SettingDescriptor> StoreLevelSettings
{
get
{
yield return General.ReturnNewNumberTemplate;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Threading.Tasks;
using VirtoCommerce.Platform.Core.GenericCrud;
using VirtoCommerce.ReturnModule.Core.Models;

namespace VirtoCommerce.ReturnModule.Core.Services
{
public interface IReturnService : ICrudService<Return>
{
Task SaveChangesAsync(Return[] returns);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace VirtoCommerce.ReturnModule.Data.Migrations
{
public partial class LineItemFields : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "Price",
table: "ReturnLineItem",
type: "Money",
nullable: false,
defaultValue: 0m);

migrationBuilder.AddColumn<int>(
name: "Quantity",
table: "ReturnLineItem",
type: "int",
nullable: false,
defaultValue: 0);

migrationBuilder.AddColumn<string>(
name: "Reason",
table: "ReturnLineItem",
type: "nvarchar(1024)",
maxLength: 1024,
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Price",
table: "ReturnLineItem");

migrationBuilder.DropColumn(
name: "Quantity",
table: "ReturnLineItem");

migrationBuilder.DropColumn(
name: "Reason",
table: "ReturnLineItem");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<decimal>("Price")
.HasColumnType("Money");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<string>("Reason")
.HasMaxLength(1024)
.HasColumnType("nvarchar(1024)");
b.Property<string>("ReturnId")
.IsRequired()
.HasMaxLength(128)
Expand Down
18 changes: 18 additions & 0 deletions src/VirtoCommerce.ReturnModule.Data/Models/ReturnLineItemEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Domain;
using VirtoCommerce.ReturnModule.Core.Models;
Expand All @@ -18,6 +19,14 @@ public class ReturnLineItemEntity : AuditableEntity, IDataEntity<ReturnLineItemE
[StringLength(128)]
public string OrderLineItemId { get; set; }

[Column(TypeName = "Money")]
public decimal Price { get; set; }

public int Quantity { get; set; }

[StringLength(1024)]
public string Reason { get; set; }

public ReturnLineItem ToModel(ReturnLineItem model)
{
if (model == null)
Expand All @@ -31,6 +40,9 @@ public ReturnLineItem ToModel(ReturnLineItem model)

model.ReturnId = ReturnId;
model.OrderLineItemId = OrderLineItemId;
model.Price = Price;
model.Quantity = Quantity;
model.Reason = Reason;

return model;
}
Expand All @@ -50,6 +62,9 @@ public ReturnLineItemEntity FromModel(ReturnLineItem model, PrimaryKeyResolvingM

ReturnId = model.ReturnId;
OrderLineItemId = model.OrderLineItemId;
Price = model.Price;
Quantity = model.Quantity;
Reason = model.Reason;

return this;
}
Expand All @@ -61,6 +76,9 @@ public void Patch(ReturnLineItemEntity target)

target.ReturnId = ReturnId;
target.OrderLineItemId = OrderLineItemId;
target.Price = Price;
target.Quantity = Quantity;
target.Reason = Reason;
}
}
}
Loading

0 comments on commit feb392d

Please sign in to comment.