@invoicebox/ui 0.1.0-alpha.181 → 0.1.0-alpha.182

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.
@@ -4,5 +4,7 @@ export declare class Validate {
4
4
  static website(value: string, createError: TCreateErrorFunc): any;
5
5
  static vatNumber(value: string, countryId: string, createError: TCreateErrorFunc): any;
6
6
  static taxRegistrationReasonCode(value: string, createError: TCreateErrorFunc): any;
7
+ static settlementAccount(value: string, bic: string, createError: TCreateErrorFunc): any;
8
+ static correspondentAccount(value: string, bic: string, createError: TCreateErrorFunc): any;
7
9
  static registrationNumber(value: string, vatNumber: string, countryId: string, createError: TCreateErrorFunc): any;
8
10
  }
@@ -95,6 +95,60 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
95
95
  }
96
96
  return true;
97
97
  }
98
+ }, {
99
+ key: "settlementAccount",
100
+ value: function settlementAccount(value, bic, createError) {
101
+ if (!bic) {
102
+ // eslint-disable-next-line no-console
103
+ console.error('Form dont have bic');
104
+ }
105
+ if (value === '') {
106
+ return true;
107
+ }
108
+ if (/[^0-9]/.test(value)) {
109
+ return createError('Расчётный счёт может состоять только из цифр');
110
+ }
111
+ if (value.length !== 20) {
112
+ return createError('Расчётный счёт может состоять только из 20 цифр');
113
+ }
114
+ var checksum = 0;
115
+ var bikRs = bic.toString().slice(-3) + value;
116
+ var coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];
117
+ coefficients.forEach(function (coefficient, i) {
118
+ checksum += coefficient * (Number(bikRs[i]) % 10);
119
+ });
120
+ if (checksum % 10 !== 0) {
121
+ return createError('Неправильное контрольное число');
122
+ }
123
+ return true;
124
+ }
125
+ }, {
126
+ key: "correspondentAccount",
127
+ value: function correspondentAccount(value, bic, createError) {
128
+ if (!bic) {
129
+ // eslint-disable-next-line no-console
130
+ console.error('Form dont have bic');
131
+ }
132
+ if (value === '') {
133
+ return true;
134
+ }
135
+ if (/[^0-9]/.test(value)) {
136
+ return createError('Кор. счёт может состоять только из цифр');
137
+ }
138
+ if (value.length !== 20) {
139
+ return createError('Кор. счёт может состоять только из 20 цифр');
140
+ }
141
+ var checksum = 0;
142
+ var bikKs = "0".concat(String(bic).slice(4, 6)).concat(value);
143
+ var coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];
144
+ coefficients.forEach(function (coefficient, i) {
145
+ checksum += coefficient * (Number(bikKs[i]) % 10);
146
+ });
147
+ if (checksum % 10 !== 0) {
148
+ return createError('Неправильное контрольное число');
149
+ }
150
+ return true;
151
+ }
98
152
  }, {
99
153
  key: "registrationNumber",
100
154
  value: function registrationNumber(value, vatNumber, countryId, createError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.181",
3
+ "version": "0.1.0-alpha.182",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {