Aggregate planning with inventory
Your objective-function seems to only concern inventory (that's the only variable aspect of your problem). Indeed $\sum x_i =12345$ is constant, your profit, excluding inventory cost, will be $5$ times this in any case ($12 - 7$). Your objective can be written more simply as $\min \sum y_i$

$b_i=\max\{0, d_i-x_i-y_{i-1}\}$ and $y_i=\max\{0, x_i+y_{i-1}-d_i\}$ should be the additional constraints.
If production + previous inventory is not enough to satisfy demand, you get a backlog at period $i$ and inventory at $i$ is what remains after satisfying the current demand with the current production + previous inventory.  

So $b_i\geq d_i-x_i-y_{i-1}$ and $y_i\geq x_i+y_{i-1}-d_i$ should do. 

Since $y_i$ are to be minimized, these variables would equal their lowest feasible bound ($0$ or the difference above).

You will just pay $\$2$ for every unit you produce above demand on a given period. However, from an inventory management point of view, the cost of inventory in your model seems unusually simplistic. A more realistic cost for inventory would consider a holding/carrying cost (cost of holding one unit of inventory for one unit of time) and an ordering cost (cost of ordering raw material or components). The difficulty of inventory problems is typically determining when and how much to order to find the best trade-off between these two costs.

PS. It may make sense at the aggregate level, and intermediate-planning time horizon, to make such a simplification regarding inventory costs. However, aggregate planning and inventory management are two strategic problems in their own rights, over two different time-horizons. They cannot be easily solved by one simple, integrated model (mostly because of different levels of uncertainty in demand over the two time-horizons and at the aggregate vs individual level).