本文介绍了将发票项目转换为帐户表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 今天我有点复杂的问题。 现在举个例子我有这张发票: Hi all,Today i have a little bit complicated issue .Now for example i have this invoice :Item Code | Qty | Unit Price | Discount | Totalbook-1 | 1 | 5 | 2 | 3book-2 | 2 | 5 | 2 | 8Accessories| 1 | 2 | 1 | 1 我有以下sql表 *items,其中包含item_Code为PK。 item_code | book-1 book-2 配件 *帐户,其中包含account_id为PK。 b $ b account_id | I have the following sql tables* "items" which contains item_Code as PK.item_code |book-1book-2Accessories* "accounts" which contains account_id as PK .account_id |books sales accountbooks discount accountaccessories sales accountaccessories discount account *item_account_type包含以下内容: 1- type_id为PK。 2- type_name。 此表填写如下: * "item_account_type" which contains the following : 1- type_id As PK. 2- type_name.this table is filled as follows :type_id | type_name1 | Sales account2 | discount account *item_account,其中包含以下内容: 1- type_id为FK 2 item_code如FK 3- account_id作为FK 例如,这是上述相同发票的item_account。 type_id | item_code | acount_id * "item_account" which contain the following : 1- type_id As FK 2- item_code As FK 3- account_id As FKFor examples , this is the item_account for the same above invoice .type_id | item_code | acount_id1 | book-1 | books sales account2 | book-1 | books discount account1 | book-2 | books sales account2 | book-2 | books discount account1 | Accessories | accessories sales account2 | Accessories | accessories discount account 现在,您可能会注意到书籍1和书籍2具有相同的帐户。 以上发票应通过检查每个项目帐户以及是否为销售或折扣并计算account_id和类型相同的金额来转换为以下形式。这就是我想知道的(如何使它成为这样): 最终形式应如下: Now, you may noticed that book-1 and book-2 had the same accounts .the above invoice should be translated to the following form by checking each item account and if it''s sales or discount and calculating the sums where account_id and type is the same . this is what i want to know ( how to make it like this ) :the final form should be like this :Account_id | total books sales account | 15 books discount account | 4accessories sales account | 2accessories discount account | 1 我的表格构建正确,但我如何达到这一点并将其保存在名为Entry的sql表中。 我希望我的问题很清楚,如果您有任何疑问,请告诉我。 感谢您试图帮助我:):)My tables are built correctly , but how do i reach to this point and save it in sql tables called " Entry" ..I hope that my question is clear and please let me know if you have any questions ..Thanks for trying to help me :) :)推荐答案 这将取决于您的申请要求,而不是我们的意见。 你在开始之前就写了一套完整的要求,不是吗?你知道吗,一步一步记录你正在编写代码的确切业务流程?That would be dictated by your application requirements, not our opinions.You DID write up a complete set of requirements before you started this, didn''t you? You know, something that documents the exact business processes, step-by-step, that you''re writing code against?? 这篇关于将发票项目转换为帐户表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-25 09:58