发票折扣:负行项目与内部属性

发布于 2024-08-30 00:47:13 字数 1811 浏览 3 评论 0原文

发票项目和整个发票的折扣应该是负行项目还是发票的单独属性

在类似的问题中,如果我将费用/折扣列表合并到订单类别中或将它们作为商品行,询问者会更多地关注订单而不是发票(这是一个略有不同的业务实体) )。建议将折扣与订单商品分开,因为它不等同于费用或产品,并且可能有不同的报告要求。因此,折扣不应该只是一个负项。

以前我曾成功地使用负行项目来清楚地指示和计算折扣,但从业务角度来看,这感觉不灵活且不准确。现在,我选择为每个订单项添加折扣以及发票范围内的折扣。

  • 这是正确的做法吗?
  • 每个商品是否应该有自己的折扣金额和百分比?

域模型代码示例

这是我的域模型(映射到 SQL 存储库)的样子:

public class Invoice
{
    public int ID { get; set; }
    public Guid JobID { get; set; }
    public string InvoiceNumber { get; set; }
    public Guid UserId { get; set; } // user who created it
    public DateTime Date { get; set; }

    public LazyList<InvoiceLine> InvoiceLines { get; set; }
    public LazyList<Payment> Payments { get; set; } // for payments received

    public boolean IsVoided { get; set; }   // Invoices are immutable.
                                            // To change: void -> new invoice.

    public decimal Total
    {
        get {
            return InvoiceLines.Sum(i => i.LineTotal);
        }
    }
}

public class InvoiceLine
{
    public int ID { get; set; }
    public int InvoiceID { get; set; }
    public string Title { get; set; }
    public decimal Quantity { get; set; }
    public decimal LineItemPrice { get; set; }

    public decimal DiscountPercent { get; set; } // line discount %?
    public decimal DiscountAmount { get; set; } // line discount amount?

    public decimal LineTotal {
        get {
            return (1.0M - DiscountPercent)
                    * (this.Quantity * (this.LineItemPrice))
                    - DiscountAmount;
        }
    }
}

Should discount on invoice items and entire invoices be negative line items or separate properties of an invoice?

In a similar question, Should I incorporate list of fees/discounts into an order class or have them be itemlines, the asker focuses more on orders than invoices (which is a slightly different business entity). Discount is proposed to be separate from order items since it is not equivalent to a fee or product and may have different reporting requirements. Hence, discount should not simply be a negative line item.

Previously I have successfully used negative line items to clearly indicate and calculate discount, but this feels inflexible and inaccurate from a business perspective. Now I am opting to add discount to each line item, along with an invoice-wide discount.

  • Is this the right way to do it?
  • Should each item have its own discount amount and percentage?

Domain Model Code Sample

This is what my domain model, which maps to an SQL repository, looks like:

public class Invoice
{
    public int ID { get; set; }
    public Guid JobID { get; set; }
    public string InvoiceNumber { get; set; }
    public Guid UserId { get; set; } // user who created it
    public DateTime Date { get; set; }

    public LazyList<InvoiceLine> InvoiceLines { get; set; }
    public LazyList<Payment> Payments { get; set; } // for payments received

    public boolean IsVoided { get; set; }   // Invoices are immutable.
                                            // To change: void -> new invoice.

    public decimal Total
    {
        get {
            return InvoiceLines.Sum(i => i.LineTotal);
        }
    }
}

public class InvoiceLine
{
    public int ID { get; set; }
    public int InvoiceID { get; set; }
    public string Title { get; set; }
    public decimal Quantity { get; set; }
    public decimal LineItemPrice { get; set; }

    public decimal DiscountPercent { get; set; } // line discount %?
    public decimal DiscountAmount { get; set; } // line discount amount?

    public decimal LineTotal {
        get {
            return (1.0M - DiscountPercent)
                    * (this.Quantity * (this.LineItemPrice))
                    - DiscountAmount;
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江湖彼岸 2024-09-06 00:47:13

排除订单项

您将如何处理积分?例如,您向某人开具三件商品的发票,但其中两件有缺陷,因此您将冲销两件有缺陷的商品的费用。有几种方法可以完成此操作。一种解决方案是贷记,它是发票的一种变体,只不过金额会贷记给发票开具人。如果您不允许负数,那么您将需要找到一种方法来单独存储贷项或将发票标记为贷项。在后面的场景中,他们将开具另一张发票,标记为信用。当然,另一个解决方案是允许存储负行项目。如何处理积分实际上将决定使用负行项目是否是正确的方法。

费用和折扣

一种方法是将折扣和费用分为两种类型:

  1. 适用于特定订单项目
  2. 的折扣 作为项目枚举但不适用于特定订单项目的折扣。

请注意,我没有包含适用于订单的折扣。那是故意的。每个折扣或费用都必须作为一个项目进行枚举(但不一定适用于产品)。这样,每项折扣和费用的来源都是明确的。这可以防止有人在无人能确定其来源或授权的情况下对订单进行折扣。对于税以外的费用也是如此。

Negative line items

How are you going to handle credits? I.e., you invoice someone for three items but two are faulty so you will reverse the charge on the two faulty items. There are a couple of ways this is done. One solution is a credit which is a variant of an invoice except that the amounts are credited back to the person to whom the invoice was issued. If you do not allow negative numbers, then you will need to find a means to store credits separately or mark the invoice as being a credit. In this later scenario, they would issue another invoice, marked as being a credit. Another solution, of course, is to allow for storing negative line items. How credits are handled is really what will determine whether use of negative line items is the right approach.

Fees and Discounts

One approach is to break down discounts and fees into two types:

  1. Discounts that apply to specific order items
  2. Discounts that are enumerated as an item but do not apply to a specific order item.

Notice that I do not include a discount that applies to the order. That is intentional. Every discount or fee would have to be enumerated as an item (but not necessarily apply to a product). In this way, each discount and fee is explicit in its source. That prevents someone from throwing onto an order a discount for which no one can determine the source or authorization. The same would be true of fees other than tax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文