invoice item total and subtotal
This commit is contained in:
@@ -2831,6 +2831,16 @@
|
||||
"nullable": false,
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"sub_total": {
|
||||
"name": "sub_total",
|
||||
"type": "int",
|
||||
"generated": "(COALESCE(unit_price, 0) * quantity) STORED",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"discount": {
|
||||
"name": "discount",
|
||||
"type": "int",
|
||||
@@ -2840,6 +2850,16 @@
|
||||
"nullable": true,
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"total": {
|
||||
"name": "total",
|
||||
"type": "int",
|
||||
"generated": "((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "integer"
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20260516121012 extends Migration {
|
||||
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(`alter table "invoice_items" add column "sub_total" int generated always as (COALESCE(unit_price, 0) * quantity) STORED not null, add column "total" int generated always as ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED not null;`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user