Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Add multiple line-items/vendors #1151

Closed
rememberlenny opened this issue Apr 7, 2016 · 1 comment
Closed

Add multiple line-items/vendors #1151

rememberlenny opened this issue Apr 7, 2016 · 1 comment

Comments

@rememberlenny
Copy link
Contributor

Proposals require a way to depict having multiple line-items and multiple vendors.

Reference doc: https://docs.google.com/document/d/1_gjq_3m16Ug7_JcfsV28Lt4dCQTDnEhvWVFofbNaw4g/edit

Reference issue: 18F/C2: Issue #1151

@pkarman
Copy link
Contributor

pkarman commented Apr 7, 2016

There are multiple ways to implement a one-to-many model relationship like this.

  1. The least invasive approach would be to follow the example of related steps, and create a proposals.parent_id column so that proposals can be grouped together into a set. The assumption there is that there is enough difference amongst the client_data attribute values on each proposal that we aren't simply duplicating N values on each proposal in the set. If that assumption were false, that would be a disadvantage of this approach. The advantages include: minimal db change, no need to affect existing data, maximum flexibility for different client_data values on each line, ability to approve/disapprove steps on lines independently (line-item veto), and no need to duplicate aggregate values (like total amount) since they can be calculated dynamically.
  2. Create a new client_data_items table with a client_data_id column. These rows would each represent a single line item. Advantages include: "true-er" representation of business case. Disadvantages: potentially duplicated data in client_data and client_data_items, need to keep them in sync.
  3. Create a JSON column on client_data called items. This gives us the most flexibility in terms of the data model, since the internal structure of that column would be managed entirely in code. Advantages: near-zero data duplication. Disadvantages: managing data in code means we cannot rely on db constraints.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants