Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT ALLOWED
- Accounts.Entity AS Entity,
- Companies.Ref AS Company,
- Accounts.Contract AS Contract,
- Accounts.Document AS Document,
- Accounts.Document.Date AS DocumentDate,
- Accounts.Document.Number AS DocumentNumber,
- Accounts.Contract.AccountsCurrency AS Currency,
- DATEDIFF(Accounts.Document.Date, &EndOfPeriod, DAY) AS DaysOverdue,
- SUM(Accounts.AmountBalance) AS Amount,
- SUM(Accounts.AmountCurBalance) AS AmountCur,
- Accounts.Document.Responsible AS ResponsibleDoc,
- Accounts.Document.SalesExecutive AS SalesExecutiveDoc,
- Accounts.Document.Department AS DepartmentDoc
- INTO Accounts
- FROM
- AccumulationRegister.CustomerAccounts.Balance(&EndOfPeriod {(&EndOfPeriod)}, ) AS Accounts
- LEFT JOIN Catalog.Companies AS Companies
- ON Accounts.Company = Companies.Ref
- WHERE
- Accounts.Document <> UNDEFINED
- AND Accounts.AccountsType = VALUE(Enum.PaymentTypes.Debt)
- GROUP BY
- Accounts.Document,
- Accounts.Entity,
- Accounts.Contract,
- Accounts.Document.Date,
- Accounts.Document.Number,
- Accounts.Contract.AccountsCurrency,
- DATEDIFF(Accounts.Document.Date, &EndOfPeriod, DAY),
- Companies.Ref
- UNION ALL
- SELECT
- AccountsReceivableDeferredBalance.Entity,
- Companies.Ref,
- AccountsReceivableDeferredBalance.Contract,
- AccountsReceivableDeferredBalance.Document,
- AccountsReceivableDeferredBalance.Document.Date,
- AccountsReceivableDeferredBalance.Document.Number,
- AccountsReceivableDeferredBalance.Contract.AccountsCurrency,
- DATEDIFF(AccountsReceivableDeferredBalance.Document.Date, &EndOfPeriod, DAY),
- SUM(AccountsReceivableDeferredBalance.AmountBalance),
- SUM(AccountsReceivableDeferredBalance.AmountCurBalance),
- AccountsReceivableDeferredBalance.Document.Responsible,
- AccountsReceivableDeferredBalance.Document.SalesExecutive,
- AccountsReceivableDeferredBalance.Document.Department
- FROM
- AccumulationRegister.AccountsReceivableDeferred.Balance(&EndOfPeriod {(&EndOfPeriod)}, ) AS AccountsReceivableDeferredBalance
- LEFT JOIN Catalog.Companies AS Companies
- ON AccountsReceivableDeferredBalance.Company = Companies.Ref
- WHERE
- AccountsReceivableDeferredBalance.Document <> UNDEFINED
- AND AccountsReceivableDeferredBalance.AccountsType = VALUE(Enum.PaymentTypes.Debt)
- AND &IncludingCheques
- GROUP BY
- AccountsReceivableDeferredBalance.Entity,
- AccountsReceivableDeferredBalance.Contract,
- AccountsReceivableDeferredBalance.Document,
- AccountsReceivableDeferredBalance.Document.Date,
- AccountsReceivableDeferredBalance.Document.Number,
- AccountsReceivableDeferredBalance.Contract.AccountsCurrency,
- DATEDIFF(AccountsReceivableDeferredBalance.Document.Date, &EndOfPeriod, DAY),
- Companies.Ref
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement