@appcorp/stellar-solutions-invoice-module 0.1.6 → 0.1.8

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.
@@ -87,7 +87,7 @@ exports.staticCompanySection = (_a = {},
87
87
  handleOnChange: function () { return void 0; },
88
88
  label: 'Company',
89
89
  listItems: [],
90
- nodeQueryKey: '',
90
+ nodeQueryKey: 'companyQuery',
91
91
  nodeSelectKey: 'companyId',
92
92
  order: 1,
93
93
  query: '',
@@ -107,8 +107,8 @@ exports.staticCompanySection = (_a = {},
107
107
  order: 4,
108
108
  query: '',
109
109
  required: true,
110
- selectKey1: 'label',
111
- selectedItem: { label: '' },
110
+ selectKey1: 'option',
111
+ selectedItem: { option: 'PKR' },
112
112
  },
113
113
  // {
114
114
  // enabled: false,
@@ -519,7 +519,7 @@ var useInvoiceState = function () {
519
519
  });
520
520
  };
521
521
  var dynamicCompanyFormElements = (0, react_1.useMemo)(function () {
522
- var _a, _b, _c, _d, _e, _f;
522
+ var _a, _b;
523
523
  var elements = __assign({}, constants_1.staticCompanySection);
524
524
  var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
525
525
  if (textInputElements) {
@@ -533,58 +533,43 @@ var useInvoiceState = function () {
533
533
  textInputElements[2].handleOnChange = handleChange;
534
534
  textInputElements[2].error = state.errors.note;
535
535
  textInputElements[3].value = state.ref || (0, util_functions_1.generateRef)({ refLength: 5 });
536
- var comboboxElements_1 = (_b = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
537
- if (comboboxElements_1) {
538
- comboboxElements_1[0].selectedItem = {};
539
- comboboxElements_1[0].listItems = companies;
540
- }
541
- return elements;
542
- }
543
- var textAreaElements = (_c = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_AREA_V1]) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) { return a.order - b.order; });
544
- if (textAreaElements) {
545
- textAreaElements === null || textAreaElements === void 0 ? void 0 : textAreaElements.forEach(function (_a, i) {
546
- var id = _a.id;
547
- textAreaElements[i].value = state[id];
548
- textAreaElements[i].handleOnChange = handleChange;
549
- textAreaElements[i].error = state.errors.description;
550
- });
551
- }
552
- var selectElements = (_d = elements[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1]) === null || _d === void 0 ? void 0 : _d.sort(function (a, b) { return a.order - b.order; });
553
- if (selectElements) {
554
- selectElements === null || selectElements === void 0 ? void 0 : selectElements.forEach(function (_a, i) {
555
- var nodeSelectKey = _a.nodeSelectKey;
556
- selectElements[i].handleOnChange = handleSelectChange;
557
- selectElements[i].selectedItem = { option: state[nodeSelectKey] };
558
- });
559
536
  }
560
- var comboboxElements = (_e = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) { return a.order - b.order; });
537
+ var comboboxElements = (_b = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
561
538
  if (comboboxElements) {
562
- // comboboxElements?.forEach(({ nodeSelectKey }, i) => {
563
- // comboboxElements[i].handleOnChange = handleSelectChange;
564
- // comboboxElements[i].selectedItem = { id: state[nodeSelectKey as 'productCategoryId'] };
565
- // comboboxElements[i].listItems = productCategories.map((item) => ({ ...item, option: item.name }));
566
- // comboboxElements[i].query = state.productCategoryQuery;
567
- // comboboxElements[i].handleInputOnChange = handleSelectInputChange;
568
- // comboboxElements[i].handleOnBlur = handleSelectInputChange;
569
- // });
570
- }
571
- var uploadElements = (_f = elements[form_schema_1.VISTA_FORM_ELEMENTS.UPLOAD_V1]) === null || _f === void 0 ? void 0 : _f.sort(function (a, b) { return a.order - b.order; });
572
- if (uploadElements) {
573
- // uploadElements?.forEach((_, i) => {
574
- // uploadElements[i].imageUrls = state.images;
575
- // uploadElements[i].handleOnChange = handleFileChange;
576
- // uploadElements[i].handleClearImage = () => dispatch({
577
- // type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
578
- // payload: { key: 'images', value: [] },
579
- // });
580
- // });
539
+ comboboxElements[0].selectedItem = { id: state.companyId };
540
+ comboboxElements[0].listItems = companies;
541
+ comboboxElements[0].query = state.companyQuery;
542
+ comboboxElements[0].handleOnChange = handleSelectChange;
543
+ comboboxElements[0].handleInputOnChange = handleChange;
544
+ comboboxElements[0].handleOnBlur = handleChange;
545
+ comboboxElements[1].selectedItem = { option: state.currency };
546
+ comboboxElements[1].listItems = [];
581
547
  }
582
548
  return elements;
583
549
  }, [state, handleChange, companies]);
584
550
  var dynamicPricingFormElements = (0, react_1.useMemo)(function () {
551
+ var _a, _b, _c, _d;
585
552
  var elements = __assign({}, constants_1.staticPricingSection);
553
+ var textElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
554
+ if (textElements) {
555
+ textElements[0].value = state.subTotal;
556
+ textElements[0].error = (_b = state.errors) === null || _b === void 0 ? void 0 : _b.subTotal;
557
+ textElements[0].handleOnChange = handleChange;
558
+ textElements[1].value = state.discount;
559
+ textElements[1].error = (_c = state.errors) === null || _c === void 0 ? void 0 : _c.discount;
560
+ textElements[1].handleOnChange = handleChange;
561
+ textElements[2].value = state.totalDiscount ? String(state.totalDiscount) : '0';
562
+ textElements[2].label = 'Total Discounted Price';
563
+ textElements[3].value = isNaN(Number(state.totalTax)) ? '0' : state.totalTax;
564
+ textElements[3].label = 'After Tax';
565
+ textElements[4].value = isNaN(Number(state.total))
566
+ ? '0'
567
+ : String(state.total);
568
+ textElements[4].error = (_d = state.errors) === null || _d === void 0 ? void 0 : _d.total;
569
+ textElements[4].handleOnChange = handleChange;
570
+ }
586
571
  return elements;
587
- }, []);
572
+ }, [handleChange, state]);
588
573
  var dynamicServiceFormElements = (0, react_1.useMemo)(function () {
589
574
  var _a, _b;
590
575
  var elements = __assign({}, constants_1.staticServiceSection);
@@ -47,7 +47,8 @@ exports.initialInvoiceState = {
47
47
  },
48
48
  // btnDisableInvoice: false,
49
49
  companyId: '',
50
- currency: '',
50
+ companyQuery: '',
51
+ currency: 'PKR',
51
52
  currentPage: 1,
52
53
  date: new Date().toISOString(),
53
54
  discount: '',
@@ -67,6 +68,8 @@ exports.initialInvoiceState = {
67
68
  subTotal: '',
68
69
  taxValue: '',
69
70
  total: '',
71
+ totalDiscount: '',
72
+ totalTax: '',
70
73
  services: [
71
74
  {
72
75
  mode: 'Create',
@@ -117,6 +117,7 @@ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updated
117
117
  };
118
118
  modal: null | PRODUCT_MODAL;
119
119
  pageLimit: number;
120
+ companyQuery: string;
120
121
  invoices: InvoiceTypeBE[];
121
122
  products: Product[];
122
123
  searchQuery: string;
@@ -128,6 +129,8 @@ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updated
128
129
  email: string;
129
130
  city: string;
130
131
  address: string;
132
+ totalTax: string;
133
+ totalDiscount: string;
131
134
  }
132
135
  export interface FetchInvoicesArgs {
133
136
  currentPage: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/stellar-solutions-invoice-module",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib",
6
6
  "build:next": "next build",