@paprflare/tally 0.1.0 → 0.1.1
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/dist/index.cjs +68 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -9
- package/dist/index.d.ts +79 -9
- package/dist/index.js +68 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -306,8 +306,55 @@ interface EnvelopeOptions {
|
|
|
306
306
|
* from the report/collection definition Tally already knows about via
|
|
307
307
|
* REPORTNAME, not from anything we send. Passing bodyXml on an export
|
|
308
308
|
* request is a no-op by design, not an oversight.
|
|
309
|
+
*
|
|
310
|
+
* IMPORTANT: this only works for requests where REPORTNAME refers to a
|
|
311
|
+
* report Tally already has registered (e.g. "Vouchers", "All Masters",
|
|
312
|
+
* "Trial Balance", "Bills Receivable" — confirmed against a live instance).
|
|
313
|
+
* It does NOT support inline TDL for ad-hoc field lists — for that, use
|
|
314
|
+
* buildCollectionEnvelope() below.
|
|
309
315
|
*/
|
|
310
316
|
declare function buildEnvelope(options: EnvelopeOptions, bodyXml?: string): string;
|
|
317
|
+
interface CollectionEnvelopeOptions {
|
|
318
|
+
/**
|
|
319
|
+
* Both the TDL <COLLECTION NAME="..."> and the <ID> Tally resolves the
|
|
320
|
+
* request by — these must be identical, since Tally looks the inline
|
|
321
|
+
* definition up by this name within the same request.
|
|
322
|
+
*/
|
|
323
|
+
name: string;
|
|
324
|
+
/** Tally's internal object type the collection walks — e.g. "Ledger",
|
|
325
|
+
* "StockItem", "Company", "Group", "VoucherType". Verified against
|
|
326
|
+
* Tally's own Developer Reference (Case Study I) and a live TallyXML
|
|
327
|
+
* Postman collection for Ledger/Company specifically. */
|
|
328
|
+
type: string;
|
|
329
|
+
company?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Native field names to pull per record (become <NATIVEMETHOD> entries).
|
|
332
|
+
* "*" is a valid Tally wildcard for "everything natively available" —
|
|
333
|
+
* it's included by default *alongside* explicit names, because in
|
|
334
|
+
* practice "*" alone has been observed to omit fields that explicit
|
|
335
|
+
* NATIVEMETHOD entries still return. Defensive, not just decorative.
|
|
336
|
+
*/
|
|
337
|
+
fields?: string[];
|
|
338
|
+
/** Extra STATICVARIABLES beyond SVEXPORTFORMAT/SVCURRENTCOMPANY — e.g.
|
|
339
|
+
* SVFROMDATE/SVTODATE for period-scoped collections. */
|
|
340
|
+
staticVariables?: Record<string, string>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Builds a TYPE=Collection export request with an inline TDL <COLLECTION>
|
|
344
|
+
* definition. This is Tally's documented mechanism for pulling arbitrary
|
|
345
|
+
* entity lists (ledgers, stock items, companies, ...) — unlike
|
|
346
|
+
* buildEnvelope()'s REPORTNAME path, it does not depend on Tally already
|
|
347
|
+
* having a report by that name; the shape is defined entirely in the
|
|
348
|
+
* request itself, so it works the same way regardless of Tally version or
|
|
349
|
+
* which UI reports happen to be registered locally.
|
|
350
|
+
*
|
|
351
|
+
* Source: Tally Developer Reference, "Case Study I – XML Request and
|
|
352
|
+
* Response Formats" → Request to Export Collection & Corresponding
|
|
353
|
+
* Response. Field-list behavior (NATIVEMETHOD, "*") cross-checked against
|
|
354
|
+
* a published Tally XML Postman collection using this exact shape for
|
|
355
|
+
* "List of Companies" and "Ledgers".
|
|
356
|
+
*/
|
|
357
|
+
declare function buildCollectionEnvelope(options: CollectionEnvelopeOptions): string;
|
|
311
358
|
|
|
312
359
|
/**
|
|
313
360
|
* Tally master imports are wrapped in a TALLYMESSAGE envelope, with the
|
|
@@ -329,17 +376,37 @@ declare function buildCreateStockItemXml(input: StockItemInput): string;
|
|
|
329
376
|
declare function buildVoucherXml(input: VoucherInput): string;
|
|
330
377
|
|
|
331
378
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
379
|
+
* Earlier version of this file guessed free-text REPORTNAME values
|
|
380
|
+
* ("List of Companies", "List of Ledgers", "List of Stock Items") against
|
|
381
|
+
* buildEnvelope(). Confirmed live against a real TallyPrime instance that
|
|
382
|
+
* those names aren't registered reports — Tally returned a bare
|
|
383
|
+
* <RESPONSE><LINEERROR>Could not find Report '...'!</LINEERROR></RESPONSE>
|
|
384
|
+
* for all three.
|
|
385
|
+
*
|
|
386
|
+
* Entity lists now go through buildCollectionEnvelope(), Tally's documented
|
|
387
|
+
* TYPE=Collection + inline TDL mechanism, which doesn't depend on a
|
|
388
|
+
* pre-registered report existing at all — the shape is fully self-describing
|
|
389
|
+
* in the request. buildEnvelope()'s REPORTNAME path is kept for
|
|
390
|
+
* getOutstanding(), since "Bills Receivable" *is* a real registered report
|
|
391
|
+
* (confirmed: no LINEERROR), it just needs a static-variable fix (below).
|
|
338
392
|
*/
|
|
339
393
|
declare function buildGetCompaniesXml(): string;
|
|
340
394
|
declare function buildGetLedgersXml(company?: string): string;
|
|
341
395
|
declare function buildGetStockItemsXml(company?: string): string;
|
|
342
|
-
|
|
396
|
+
/**
|
|
397
|
+
* "Bills Receivable" is confirmed as a real registered report (no
|
|
398
|
+
* LINEERROR), but came back as an empty <ENVELOPE></ENVELOPE> in testing —
|
|
399
|
+
* most likely because, without an explicit date range, Tally fell back to
|
|
400
|
+
* a default period with nothing in it. Pass `dateRange` to scope it
|
|
401
|
+
* explicitly. UNVERIFIED beyond this reasoning — confirm against your
|
|
402
|
+
* instance with the updated raw-test script before relying on it; if it's
|
|
403
|
+
* still empty with a date range supplied, this report may need to be
|
|
404
|
+
* queried as its own TDL Collection rather than as a named report at all.
|
|
405
|
+
*/
|
|
406
|
+
declare function buildGetOutstandingXml(company?: string, dateRange?: {
|
|
407
|
+
from: Date;
|
|
408
|
+
to: Date;
|
|
409
|
+
}): string;
|
|
343
410
|
declare function buildPingXml(): string;
|
|
344
411
|
|
|
345
412
|
/**
|
|
@@ -366,7 +433,10 @@ declare class Tally {
|
|
|
366
433
|
/** Alias matching the original product sketch's naming. */
|
|
367
434
|
getCustomers(): Promise<Result<Ledger[], TallyError>>;
|
|
368
435
|
getStockItems(): Promise<Result<StockItem[], TallyError>>;
|
|
369
|
-
getOutstanding(
|
|
436
|
+
getOutstanding(dateRange?: {
|
|
437
|
+
from: Date;
|
|
438
|
+
to: Date;
|
|
439
|
+
}): Promise<Result<OutstandingEntry[], TallyError>>;
|
|
370
440
|
createLedger(input: LedgerInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
371
441
|
createStockItem(input: StockItemInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
372
442
|
createVoucher(input: VoucherInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
@@ -475,4 +545,4 @@ declare class TallyTransport {
|
|
|
475
545
|
send(requestXml: string): Promise<Result<string, TallyError>>;
|
|
476
546
|
}
|
|
477
547
|
|
|
478
|
-
export { type Company, CompanySchema, EMPTY_MARKER, type EnvelopeOptions, type EnvelopeRequestType, type JournalVoucherInput, JournalVoucherInputSchema, type Ledger, type LedgerInput, LedgerInputSchema, LedgerSchema, type LineItem, type OutstandingEntry, OutstandingEntrySchema, type PaymentVoucherInput, PaymentVoucherInputSchema, type PurchaseVoucherInput, PurchaseVoucherInputSchema, type ReceiptVoucherInput, ReceiptVoucherInputSchema, type Result, type SalesVoucherInput, SalesVoucherInputSchema, type StockItem, type StockItemInput, StockItemInputSchema, StockItemSchema, Tally, type TallyConfig, type TallyError, type TallyErrorCode, TallyTransport, type VoucherCreateResult, type VoucherInput, VoucherInputSchema, assertNever, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
|
548
|
+
export { type CollectionEnvelopeOptions, type Company, CompanySchema, EMPTY_MARKER, type EnvelopeOptions, type EnvelopeRequestType, type JournalVoucherInput, JournalVoucherInputSchema, type Ledger, type LedgerInput, LedgerInputSchema, LedgerSchema, type LineItem, type OutstandingEntry, OutstandingEntrySchema, type PaymentVoucherInput, PaymentVoucherInputSchema, type PurchaseVoucherInput, PurchaseVoucherInputSchema, type ReceiptVoucherInput, ReceiptVoucherInputSchema, type Result, type SalesVoucherInput, SalesVoucherInputSchema, type StockItem, type StockItemInput, StockItemInputSchema, StockItemSchema, Tally, type TallyConfig, type TallyError, type TallyErrorCode, TallyTransport, type VoucherCreateResult, type VoucherInput, VoucherInputSchema, assertNever, buildCollectionEnvelope, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -306,8 +306,55 @@ interface EnvelopeOptions {
|
|
|
306
306
|
* from the report/collection definition Tally already knows about via
|
|
307
307
|
* REPORTNAME, not from anything we send. Passing bodyXml on an export
|
|
308
308
|
* request is a no-op by design, not an oversight.
|
|
309
|
+
*
|
|
310
|
+
* IMPORTANT: this only works for requests where REPORTNAME refers to a
|
|
311
|
+
* report Tally already has registered (e.g. "Vouchers", "All Masters",
|
|
312
|
+
* "Trial Balance", "Bills Receivable" — confirmed against a live instance).
|
|
313
|
+
* It does NOT support inline TDL for ad-hoc field lists — for that, use
|
|
314
|
+
* buildCollectionEnvelope() below.
|
|
309
315
|
*/
|
|
310
316
|
declare function buildEnvelope(options: EnvelopeOptions, bodyXml?: string): string;
|
|
317
|
+
interface CollectionEnvelopeOptions {
|
|
318
|
+
/**
|
|
319
|
+
* Both the TDL <COLLECTION NAME="..."> and the <ID> Tally resolves the
|
|
320
|
+
* request by — these must be identical, since Tally looks the inline
|
|
321
|
+
* definition up by this name within the same request.
|
|
322
|
+
*/
|
|
323
|
+
name: string;
|
|
324
|
+
/** Tally's internal object type the collection walks — e.g. "Ledger",
|
|
325
|
+
* "StockItem", "Company", "Group", "VoucherType". Verified against
|
|
326
|
+
* Tally's own Developer Reference (Case Study I) and a live TallyXML
|
|
327
|
+
* Postman collection for Ledger/Company specifically. */
|
|
328
|
+
type: string;
|
|
329
|
+
company?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Native field names to pull per record (become <NATIVEMETHOD> entries).
|
|
332
|
+
* "*" is a valid Tally wildcard for "everything natively available" —
|
|
333
|
+
* it's included by default *alongside* explicit names, because in
|
|
334
|
+
* practice "*" alone has been observed to omit fields that explicit
|
|
335
|
+
* NATIVEMETHOD entries still return. Defensive, not just decorative.
|
|
336
|
+
*/
|
|
337
|
+
fields?: string[];
|
|
338
|
+
/** Extra STATICVARIABLES beyond SVEXPORTFORMAT/SVCURRENTCOMPANY — e.g.
|
|
339
|
+
* SVFROMDATE/SVTODATE for period-scoped collections. */
|
|
340
|
+
staticVariables?: Record<string, string>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Builds a TYPE=Collection export request with an inline TDL <COLLECTION>
|
|
344
|
+
* definition. This is Tally's documented mechanism for pulling arbitrary
|
|
345
|
+
* entity lists (ledgers, stock items, companies, ...) — unlike
|
|
346
|
+
* buildEnvelope()'s REPORTNAME path, it does not depend on Tally already
|
|
347
|
+
* having a report by that name; the shape is defined entirely in the
|
|
348
|
+
* request itself, so it works the same way regardless of Tally version or
|
|
349
|
+
* which UI reports happen to be registered locally.
|
|
350
|
+
*
|
|
351
|
+
* Source: Tally Developer Reference, "Case Study I – XML Request and
|
|
352
|
+
* Response Formats" → Request to Export Collection & Corresponding
|
|
353
|
+
* Response. Field-list behavior (NATIVEMETHOD, "*") cross-checked against
|
|
354
|
+
* a published Tally XML Postman collection using this exact shape for
|
|
355
|
+
* "List of Companies" and "Ledgers".
|
|
356
|
+
*/
|
|
357
|
+
declare function buildCollectionEnvelope(options: CollectionEnvelopeOptions): string;
|
|
311
358
|
|
|
312
359
|
/**
|
|
313
360
|
* Tally master imports are wrapped in a TALLYMESSAGE envelope, with the
|
|
@@ -329,17 +376,37 @@ declare function buildCreateStockItemXml(input: StockItemInput): string;
|
|
|
329
376
|
declare function buildVoucherXml(input: VoucherInput): string;
|
|
330
377
|
|
|
331
378
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
379
|
+
* Earlier version of this file guessed free-text REPORTNAME values
|
|
380
|
+
* ("List of Companies", "List of Ledgers", "List of Stock Items") against
|
|
381
|
+
* buildEnvelope(). Confirmed live against a real TallyPrime instance that
|
|
382
|
+
* those names aren't registered reports — Tally returned a bare
|
|
383
|
+
* <RESPONSE><LINEERROR>Could not find Report '...'!</LINEERROR></RESPONSE>
|
|
384
|
+
* for all three.
|
|
385
|
+
*
|
|
386
|
+
* Entity lists now go through buildCollectionEnvelope(), Tally's documented
|
|
387
|
+
* TYPE=Collection + inline TDL mechanism, which doesn't depend on a
|
|
388
|
+
* pre-registered report existing at all — the shape is fully self-describing
|
|
389
|
+
* in the request. buildEnvelope()'s REPORTNAME path is kept for
|
|
390
|
+
* getOutstanding(), since "Bills Receivable" *is* a real registered report
|
|
391
|
+
* (confirmed: no LINEERROR), it just needs a static-variable fix (below).
|
|
338
392
|
*/
|
|
339
393
|
declare function buildGetCompaniesXml(): string;
|
|
340
394
|
declare function buildGetLedgersXml(company?: string): string;
|
|
341
395
|
declare function buildGetStockItemsXml(company?: string): string;
|
|
342
|
-
|
|
396
|
+
/**
|
|
397
|
+
* "Bills Receivable" is confirmed as a real registered report (no
|
|
398
|
+
* LINEERROR), but came back as an empty <ENVELOPE></ENVELOPE> in testing —
|
|
399
|
+
* most likely because, without an explicit date range, Tally fell back to
|
|
400
|
+
* a default period with nothing in it. Pass `dateRange` to scope it
|
|
401
|
+
* explicitly. UNVERIFIED beyond this reasoning — confirm against your
|
|
402
|
+
* instance with the updated raw-test script before relying on it; if it's
|
|
403
|
+
* still empty with a date range supplied, this report may need to be
|
|
404
|
+
* queried as its own TDL Collection rather than as a named report at all.
|
|
405
|
+
*/
|
|
406
|
+
declare function buildGetOutstandingXml(company?: string, dateRange?: {
|
|
407
|
+
from: Date;
|
|
408
|
+
to: Date;
|
|
409
|
+
}): string;
|
|
343
410
|
declare function buildPingXml(): string;
|
|
344
411
|
|
|
345
412
|
/**
|
|
@@ -366,7 +433,10 @@ declare class Tally {
|
|
|
366
433
|
/** Alias matching the original product sketch's naming. */
|
|
367
434
|
getCustomers(): Promise<Result<Ledger[], TallyError>>;
|
|
368
435
|
getStockItems(): Promise<Result<StockItem[], TallyError>>;
|
|
369
|
-
getOutstanding(
|
|
436
|
+
getOutstanding(dateRange?: {
|
|
437
|
+
from: Date;
|
|
438
|
+
to: Date;
|
|
439
|
+
}): Promise<Result<OutstandingEntry[], TallyError>>;
|
|
370
440
|
createLedger(input: LedgerInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
371
441
|
createStockItem(input: StockItemInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
372
442
|
createVoucher(input: VoucherInput): Promise<Result<VoucherCreateResult, TallyError>>;
|
|
@@ -475,4 +545,4 @@ declare class TallyTransport {
|
|
|
475
545
|
send(requestXml: string): Promise<Result<string, TallyError>>;
|
|
476
546
|
}
|
|
477
547
|
|
|
478
|
-
export { type Company, CompanySchema, EMPTY_MARKER, type EnvelopeOptions, type EnvelopeRequestType, type JournalVoucherInput, JournalVoucherInputSchema, type Ledger, type LedgerInput, LedgerInputSchema, LedgerSchema, type LineItem, type OutstandingEntry, OutstandingEntrySchema, type PaymentVoucherInput, PaymentVoucherInputSchema, type PurchaseVoucherInput, PurchaseVoucherInputSchema, type ReceiptVoucherInput, ReceiptVoucherInputSchema, type Result, type SalesVoucherInput, SalesVoucherInputSchema, type StockItem, type StockItemInput, StockItemInputSchema, StockItemSchema, Tally, type TallyConfig, type TallyError, type TallyErrorCode, TallyTransport, type VoucherCreateResult, type VoucherInput, VoucherInputSchema, assertNever, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
|
548
|
+
export { type CollectionEnvelopeOptions, type Company, CompanySchema, EMPTY_MARKER, type EnvelopeOptions, type EnvelopeRequestType, type JournalVoucherInput, JournalVoucherInputSchema, type Ledger, type LedgerInput, LedgerInputSchema, LedgerSchema, type LineItem, type OutstandingEntry, OutstandingEntrySchema, type PaymentVoucherInput, PaymentVoucherInputSchema, type PurchaseVoucherInput, PurchaseVoucherInputSchema, type ReceiptVoucherInput, ReceiptVoucherInputSchema, type Result, type SalesVoucherInput, SalesVoucherInputSchema, type StockItem, type StockItemInput, StockItemInputSchema, StockItemSchema, Tally, type TallyConfig, type TallyError, type TallyErrorCode, TallyTransport, type VoucherCreateResult, type VoucherInput, VoucherInputSchema, assertNever, buildCollectionEnvelope, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
package/dist/index.js
CHANGED
|
@@ -196,6 +196,18 @@ function buildEnvelope(options, bodyXml) {
|
|
|
196
196
|
const sectionTag = isImport ? "IMPORTDATA" : "EXPORTDATA";
|
|
197
197
|
return `<ENVELOPE><HEADER><TALLYREQUEST>${escapeXml(options.requestType)}</TALLYREQUEST></HEADER><BODY><${sectionTag}><REQUESTDESC><REPORTNAME>${escapeXml(options.id)}</REPORTNAME>` + (staticVarsXml ? `<STATICVARIABLES>${staticVarsXml}</STATICVARIABLES>` : "") + `</REQUESTDESC>` + (isImport && bodyXml ? `<REQUESTDATA>${bodyXml}</REQUESTDATA>` : "") + `</${sectionTag}></BODY></ENVELOPE>`;
|
|
198
198
|
}
|
|
199
|
+
function buildCollectionEnvelope(options) {
|
|
200
|
+
const staticVars = {
|
|
201
|
+
SVEXPORTFORMAT: "$$SysName:XML",
|
|
202
|
+
...options.company ? { SVCURRENTCOMPANY: options.company } : {},
|
|
203
|
+
...options.staticVariables ?? {}
|
|
204
|
+
};
|
|
205
|
+
const staticVarsXml = Object.entries(staticVars).map(([key, value]) => `<${key}>${escapeXml(value)}</${key}>`).join("");
|
|
206
|
+
const fields = options.fields && options.fields.length > 0 ? options.fields : ["*"];
|
|
207
|
+
const nativeMethodsXml = fields.map((f) => `<NATIVEMETHOD>${escapeXml(f)}</NATIVEMETHOD>`).join("");
|
|
208
|
+
const safeName = escapeXml(options.name);
|
|
209
|
+
return `<ENVELOPE><HEADER><VERSION>1</VERSION><TALLYREQUEST>Export</TALLYREQUEST><TYPE>Collection</TYPE><ID>${safeName}</ID></HEADER><BODY><DESC><STATICVARIABLES>${staticVarsXml}</STATICVARIABLES><TDL><TDLMESSAGE><COLLECTION NAME="${safeName}" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="Yes" ISOPTION="No" ISINTERNAL="No"><TYPE>${escapeXml(options.type)}</TYPE>` + nativeMethodsXml + `</COLLECTION></TDLMESSAGE></TDL></DESC></BODY></ENVELOPE>`;
|
|
210
|
+
}
|
|
199
211
|
|
|
200
212
|
// src/xml/builders/ledger.ts
|
|
201
213
|
function buildCreateLedgerXml(input) {
|
|
@@ -319,31 +331,62 @@ function buildVoucherXml(input) {
|
|
|
319
331
|
|
|
320
332
|
// src/xml/builders/collection.ts
|
|
321
333
|
function buildGetCompaniesXml() {
|
|
322
|
-
return
|
|
334
|
+
return buildCollectionEnvelope({
|
|
335
|
+
name: "List of Companies",
|
|
336
|
+
type: "Company",
|
|
337
|
+
fields: ["Name", "Guid", "StartingFrom", "BooksFrom", "*"],
|
|
338
|
+
// Newer TallyPrime releases distinguish "Simple" companies from full
|
|
339
|
+
// ones; without this some installs omit Simple companies from the
|
|
340
|
+
// collection. Harmless no-op on installs that don't have the concept.
|
|
341
|
+
staticVariables: { SVIsSimpleCompany: "No" }
|
|
342
|
+
});
|
|
323
343
|
}
|
|
324
344
|
function buildGetLedgersXml(company) {
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
|
|
345
|
+
return buildCollectionEnvelope({
|
|
346
|
+
name: "Ledgers",
|
|
347
|
+
type: "Ledger",
|
|
328
348
|
company,
|
|
329
|
-
|
|
349
|
+
fields: [
|
|
350
|
+
"Name",
|
|
351
|
+
"Parent",
|
|
352
|
+
"OpeningBalance",
|
|
353
|
+
"ClosingBalance",
|
|
354
|
+
"GSTIN",
|
|
355
|
+
"LedStateName",
|
|
356
|
+
"*"
|
|
357
|
+
]
|
|
330
358
|
});
|
|
331
359
|
}
|
|
332
360
|
function buildGetStockItemsXml(company) {
|
|
333
|
-
return
|
|
334
|
-
|
|
335
|
-
|
|
361
|
+
return buildCollectionEnvelope({
|
|
362
|
+
name: "StockItems",
|
|
363
|
+
type: "StockItem",
|
|
336
364
|
company,
|
|
337
|
-
|
|
365
|
+
fields: [
|
|
366
|
+
"Name",
|
|
367
|
+
"Guid",
|
|
368
|
+
"BaseUnits",
|
|
369
|
+
"ClosingBalance",
|
|
370
|
+
"ClosingValue",
|
|
371
|
+
"HSNCode",
|
|
372
|
+
"GSTRate",
|
|
373
|
+
"*"
|
|
374
|
+
]
|
|
338
375
|
});
|
|
339
376
|
}
|
|
340
|
-
function buildGetOutstandingXml(company) {
|
|
377
|
+
function buildGetOutstandingXml(company, dateRange) {
|
|
341
378
|
return buildEnvelope({
|
|
342
379
|
requestType: "Export Data",
|
|
343
380
|
id: "Bills Receivable",
|
|
344
381
|
// swap to "Bills Payable" for AP outstanding
|
|
345
382
|
company,
|
|
346
|
-
staticVariables: {
|
|
383
|
+
staticVariables: {
|
|
384
|
+
SVEXPORTFORMAT: "$$SysName:XML",
|
|
385
|
+
...dateRange ? {
|
|
386
|
+
SVFROMDATE: formatTallyDate(dateRange.from),
|
|
387
|
+
SVTODATE: formatTallyDate(dateRange.to)
|
|
388
|
+
} : {}
|
|
389
|
+
}
|
|
347
390
|
});
|
|
348
391
|
}
|
|
349
392
|
function buildPingXml() {
|
|
@@ -374,6 +417,15 @@ function parseImportResponse(rawXml) {
|
|
|
374
417
|
})
|
|
375
418
|
);
|
|
376
419
|
}
|
|
420
|
+
const bareLineErrors = parsed.RESPONSE?.LINEERROR;
|
|
421
|
+
if (bareLineErrors && bareLineErrors.length > 0) {
|
|
422
|
+
return err(
|
|
423
|
+
tallyError("TALLY_REJECTED", "Tally rejected the request", {
|
|
424
|
+
tallyMessage: bareLineErrors.join("; "),
|
|
425
|
+
responseXml: rawXml
|
|
426
|
+
})
|
|
427
|
+
);
|
|
428
|
+
}
|
|
377
429
|
const body = parsed.ENVELOPE?.BODY;
|
|
378
430
|
const lineErrors = body?.LINEERROR;
|
|
379
431
|
if (lineErrors && lineErrors.length > 0) {
|
|
@@ -633,8 +685,10 @@ var Tally = class {
|
|
|
633
685
|
if (!res.ok) return res;
|
|
634
686
|
return parseStockItemCollection(res.value);
|
|
635
687
|
}
|
|
636
|
-
async getOutstanding() {
|
|
637
|
-
const res = await this.transport.send(
|
|
688
|
+
async getOutstanding(dateRange) {
|
|
689
|
+
const res = await this.transport.send(
|
|
690
|
+
buildGetOutstandingXml(this.company, dateRange)
|
|
691
|
+
);
|
|
638
692
|
if (!res.ok) return res;
|
|
639
693
|
return parseOutstandingCollection(res.value);
|
|
640
694
|
}
|
|
@@ -745,6 +799,6 @@ var Tally = class {
|
|
|
745
799
|
}
|
|
746
800
|
};
|
|
747
801
|
|
|
748
|
-
export { CompanySchema, EMPTY_MARKER, JournalVoucherInputSchema, LedgerInputSchema, LedgerSchema, OutstandingEntrySchema, PaymentVoucherInputSchema, PurchaseVoucherInputSchema, ReceiptVoucherInputSchema, SalesVoucherInputSchema, StockItemInputSchema, StockItemSchema, Tally, TallyTransport, VoucherInputSchema, assertNever, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
|
802
|
+
export { CompanySchema, EMPTY_MARKER, JournalVoucherInputSchema, LedgerInputSchema, LedgerSchema, OutstandingEntrySchema, PaymentVoucherInputSchema, PurchaseVoucherInputSchema, ReceiptVoucherInputSchema, SalesVoucherInputSchema, StockItemInputSchema, StockItemSchema, Tally, TallyTransport, VoucherInputSchema, assertNever, buildCollectionEnvelope, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };
|
|
749
803
|
//# sourceMappingURL=index.js.map
|
|
750
804
|
//# sourceMappingURL=index.js.map
|