@social-mail/social-mail-web-server 1.8.320 → 1.8.321

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.8.320",
3
+ "version": "1.8.321",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -111,6 +111,9 @@ export class StoreItem {
111
111
  @ReadOnlyJsonProperty
112
112
  public maxPrice: number;
113
113
 
114
+ @Column({ dataType: "Char", length: 20, nullable: true})
115
+ public taxCode: string;
116
+
114
117
  public store: WebSite;
115
118
 
116
119
  public vendor: StoreAccount;
@@ -126,6 +126,9 @@ export class StoreJournal {
126
126
  @Column({ dataType: "Char", nullable: true})
127
127
  taxExemptTaxID: string;
128
128
 
129
+ @Column({ dataType: "Char", length: 200, nullable: true})
130
+ invoiceID: string;
131
+
129
132
  buyer: StoreAccount;
130
133
  seller: StoreAccount;
131
134
 
@@ -151,6 +151,12 @@ export default class WebSite {
151
151
  @Column({ dataType:"Char", length: 10, default: () => "USD"})
152
152
  public currency: string;
153
153
 
154
+ @Column({ dataType: "Char", length: 16, nullable: true})
155
+ public invoicePrefix: string;
156
+
157
+ @Column({ dataType: "BigInt", default: () => 1})
158
+ public nextInvoiceID: number;
159
+
154
160
  public folder: AppFile;
155
161
 
156
162
  currentVersion: AppFile;
@@ -137,10 +137,26 @@ export default class StoreJournalEvents extends AuthenticatedEvents<StoreJournal
137
137
  return this.updateBalances(entity, entry);
138
138
  }
139
139
 
140
- updateBalances(entity: StoreJournal, entry: ChangeEntry<StoreJournal>) {
140
+ async updateBalances(entity: StoreJournal, entry: ChangeEntry<StoreJournal>) {
141
141
  if (!entity.posted) {
142
142
  return;
143
143
  }
144
+
145
+ if (entity.journalType === "sales-invoice") {
146
+ if (entity.invoiceID) {
147
+ const m = /(?<id>\d+)$/.exec(entity.invoiceID);
148
+ const id = m?.groups["id"];
149
+ if (id) {
150
+ const { storeID } = entity;
151
+ const nextInvoiceID = (BigInt(id) + 1n).toString() as any;
152
+ await this.db.websiteFolders.where({ storeID, nextInvoiceID }, (p) => (x) =>
153
+ x.folderID === p.storeID
154
+ && x.nextInvoiceID < p.nextInvoiceID)
155
+ .update({ nextInvoiceID }, (p) => (x) => ({ nextInvoiceID }));
156
+ }
157
+ }
158
+ }
159
+
144
160
  this.db.queuePostSaveTask(async () => {
145
161
  await entry.loadNavigationAsync((x) => x.entries);
146
162