将1行分为多个分数行

发布于 2025-02-11 05:17:55 字数 959 浏览 4 评论 0原文

我正在使用餐厅的POS系统工作,并且正在尝试设计一个分裂系统,以便在多个订单上将物品分成数量。

这是我到目前为止所拥有的简单摘要:

我有一个带有“ table_id”和“ table_number”的“表”表。每个餐桌可以使用“客户端_id”和“ client_number”具有多个“客户端”。每个客户端与表“订单”的订单与“ order_id”相关联,并且与'client_id'相关。每个订单都有来自表'line_items'的多个行项目,其中'line_item_id'和“数量”与“ order_id”相关。

因此,现在,我有一个喜欢的数据结构:

tables: {
    table_id,
    table_number,

    clients: {
        client_id,
        client_number,
        table_id,

        orders: {
            order_id,
            client_id,

            line_items: {
                line_item_id,
                quantity,
                order_id,
            }
        }
    }
}

我现在需要做的是能够将行项目分为多个订单。

因此,一个例子是:我在顺序1中有line_item 1,我想按顺序1和1/2分开为1/2。 3订单2,1/3订单3

  1. ,1 / 另一个订单上的额外line_item并每次更新分母。

  2. 我为称为“ sub_line_items'的分割项目”创建一个表,当我首先将line_item分为两个半部分时,我将两个记录添加到'sub_line_items'中,并将它们与'order_it_id'和'line_item_id'相关联。

I'm working on a restaurant POS system and I'm trying to devise a splitting system in order to split items into fractional quantities over multiple orders.

Here is simple summary of what I have so far:

I have a table of 'tables' with 'table_id' and 'table_number'. Each dining table can have multiple 'clients' with 'client_id' and 'client_number'. Each client is associated with an order from the table 'orders' with 'order_id' and, related with 'client_id'. Each order has multiple line items from the table 'line_items' with 'line_item_id' and 'quantity' related with 'order_id'.

So right now, I have a data structure of the likes:

tables: {
    table_id,
    table_number,

    clients: {
        client_id,
        client_number,
        table_id,

        orders: {
            order_id,
            client_id,

            line_items: {
                line_item_id,
                quantity,
                order_id,
            }
        }
    }
}

What I need to do now is to be able to split the line items into fractional quantities over multiple orders.

So an example would be: I have line_item 1 in order 1, and I'd like to split it as 1/2 in order 1 and 1/2 in order 2. If I split it again, I get 1/3 order 1, 1/3 order 2, 1/3 order 3.

I'm thinking of 2 solutions in order to achieve this:

  1. I add an extra column for line_items for the 'denominator' and each time I split it, I create an extra line_item on the other order and update the denominator each time.

  2. I create a table for the divided items called 'sub_line_items', when I first split the line_item into 2 halves, I add two records into 'sub_line_items' and relate them back with 'order_id' and 'line_item_id'.

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

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

发布评论

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

评论(1

酒浓于脸红 2025-02-18 05:17:55

听起来您需要一张客户为每个Line_Item付款的表。它可能只有2列:client_id and line_item_id。

给定LINE_ITEM_ID的客户端数将确定1/2 vs 1/3等

SELECT COUNT(*) AS denominator
    FROM splits
    WHERE line_item_id = 1234;

要从1/3恢复到1/2,只需删除一行即可。

Sounds like you need a table of which clients are paying for each line_item. It would have (perhaps) just 2 columns: client_id and line_item_id.

The number of clients for a given line_item_id would determine 1/2 vs 1/3, etc.

SELECT COUNT(*) AS denominator
    FROM splits
    WHERE line_item_id = 1234;

To revert from 1/3 to 1/2, simply delete a row.

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